SteamWar/BauSystem2.0
Archiviert
12
0

Add TraceShowGui

Dieser Commit ist enthalten in:
yoyosource 2021-05-03 18:46:10 +02:00
Ursprung 9148e17521
Commit 06cd255561
3 geänderte Dateien mit 132 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.tracer;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.config.ColorConfig;
import de.steamwar.bausystem.features.tracer.gui.TraceShowGui;
import de.steamwar.bausystem.features.tracer.record.RecordStateMachine;
import de.steamwar.bausystem.features.tracer.show.ShowModeParameter;
import de.steamwar.bausystem.features.tracer.show.ShowModeParameterType;
@ -154,7 +155,7 @@ public class TraceCommand extends SWCommand {
@Register({"show", "gui"})
public void showGuiCommand(Player p) {
if (!permissionCheck(p)) return;
// GuiTraceShow.openGui(p);
TraceShowGui.openGui(p);
}
@Register({"hide"})

Datei anzeigen

@ -0,0 +1,130 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.tracer.gui;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.tracer.TNTTracer_15;
import de.steamwar.bausystem.features.tracer.show.ShowModeParameter;
import de.steamwar.bausystem.features.tracer.show.TraceShowManager;
import de.steamwar.bausystem.features.tracer.show.mode.TraceEntityShowMode;
import de.steamwar.core.VersionedCallable;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import lombok.experimental.UtilityClass;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@UtilityClass
public class TraceShowGui {
private static final Map<Player, ShowModeParameter> ShowModeParameterMap = new HashMap<>();
public static void openGui(Player player) {
ShowModeParameter playerShowMode = new ShowModeParameter();
playerShowMode.setInterpolate_Y(false);
playerShowMode.setInterpolate_XZ(false);
ShowModeParameterMap.put(player, playerShowMode);
SWInventory swInventory = new SWInventory(player, 9, "Trace Show GUI");
swInventory.addCloseCallback(clickType -> ShowModeParameterMap.remove(player));
setActiveShow(player, swInventory);
SWItem water = new SWItem(Material.TNT, "§eWasser §7Positionen", Arrays.asList("§7Zeigt alles TNT, welches", "§7im Wasser explodiert ist."), false, clickType -> {
});
swInventory.setItem(5, water);
swInventory.setCallback(5, clickType -> toggleHideTNTinWaterExploded(player, swInventory, water));
SWItem interpolateY = new SWItem(Material.QUARTZ_STAIRS, "§eInterpolation §7Y-Achse", Arrays.asList("§7Zeigt die Interpolation", "§7auf der Y-Achse."), false, clickType -> {
});
swInventory.setItem(6, interpolateY);
swInventory.setCallback(6, clickType -> toggleInterpolateYPosition(player, swInventory, interpolateY));
Material xzMaterial = VersionedCallable.call(new VersionedCallable<>(TNTTracer_15::getTraceXZMaterial, 14));
SWItem interpolateXZ = new SWItem(xzMaterial, (byte) 7, "§eInterpolation §7XZ-Achse", Arrays.asList("§7Zeigt die Interpolation", "§7auf der XZ-Achse."), false, clickType -> {
});
swInventory.setItem(7, interpolateXZ);
swInventory.setCallback(7, clickType -> toggleInterpolateXZPosition(player, swInventory, interpolateXZ));
// Water Bucket (-water)
// TNT (-water-exploded)
// Quartz_Stair (-interpolate-y)
// Quartz_Slab (-interpolate-xz)
swInventory.open();
}
private static void setActiveShow(Player player, SWInventory swInventory) {
if (TraceShowManager.hasActiveShow(player)) {
Material showMaterial = VersionedCallable.call(new VersionedCallable<>(TNTTracer_15::getTraceShowMaterial, 14));
SWItem shown = new SWItem(showMaterial, "§aTraces angezeigt", new ArrayList<>(), false, clickType -> {
TraceShowManager.hide(player);
player.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen ausgeblendet");
setActiveShow(player, swInventory);
});
swInventory.setItem(1, shown);
} else {
Material hideMaterial = VersionedCallable.call(new VersionedCallable<>(TNTTracer_15::getTraceHideMaterial, 14));
SWItem hidden = new SWItem(hideMaterial, "§cTraces ausgeblendet", new ArrayList<>(), false, clickType -> {
show(player);
player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt");
setActiveShow(player, swInventory);
});
swInventory.setItem(1, hidden);
}
}
private static void toggleHideTNTinWaterExploded(Player player, SWInventory swInventory, SWItem swItem) {
ShowModeParameter showModeParameter = ShowModeParameterMap.get(player);
showModeParameter.setWater(!showModeParameter.isWater());
show(player);
swItem.setEnchanted(showModeParameter.isWater());
swInventory.setItem(5, swItem);
swInventory.setCallback(5, clickType -> toggleHideTNTinWaterExploded(player, swInventory, swItem));
}
private static void toggleInterpolateYPosition(Player player, SWInventory swInventory, SWItem swItem) {
ShowModeParameter showModeParameter = ShowModeParameterMap.get(player);
showModeParameter.setInterpolate_Y(!showModeParameter.isInterpolate_Y());
show(player);
swItem.setEnchanted(showModeParameter.isInterpolate_Y());
swInventory.setItem(6, swItem);
swInventory.setCallback(6, clickType -> toggleInterpolateYPosition(player, swInventory, swItem));
}
private static void toggleInterpolateXZPosition(Player player, SWInventory swInventory, SWItem swItem) {
ShowModeParameter showModeParameter = ShowModeParameterMap.get(player);
showModeParameter.setInterpolate_XZ(!showModeParameter.isInterpolate_XZ());
show(player);
swItem.setEnchanted(showModeParameter.isInterpolate_XZ());
swInventory.setItem(7, swItem);
swInventory.setCallback(7, clickType -> toggleInterpolateXZPosition(player, swInventory, swItem));
}
private static void show(Player player) {
TraceShowManager.show(player, new TraceEntityShowMode(player, ShowModeParameterMap.get(player)));
}
}