diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 9436e1f2..de9d76e8 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -508,6 +508,9 @@ SIMULATOR_NO_SIM_IN_HAND = §cNo simulator item selected SIMULATOR_GUI_SELECT_SIM = Simulator selection SIMULATOR_NAME_ALREADY_EXISTS = §cSimulator already exists SIMULATOR_CREATE = §aSimulator created +SIMULATOR_EDIT_LOCATION = §7Edit position +SIMULATOR_EDIT_PROPERTIES = §7Edit properties +SIMULATOR_EDIT_OTHER = §7Edit other SIMULATOR_GUI_ITEM_NAME = §eTNT Simulator SIMULATOR_START_HELP = §8/§esimulator start §8-§7 Starts the simulation @@ -558,6 +561,7 @@ SIMULATOR_GUI_TNT_SPAWN_LORE_3 = §7 SIMULATOR_GUI_TNT_SPAWN_LORE_4 = §7x§8: §e{0} SIMULATOR_GUI_TNT_SPAWN_LORE_5 = §7y§8: §e{0} SIMULATOR_GUI_TNT_SPAWN_LORE_6 = §7z§8: §e{0} +SIMULATOR_GUI_TNT_SPAWN_LORE_7 = §7Fuse-Ticks§8: §e{0} SIMULATOR_GUI_TNT_GROUP_NAME = §eTNT group SIMULATOR_GUI_TNT_GROUP_LORE_1 = §7Element count§8: §e{0} SIMULATOR_GUI_TNT_DISABLED = §cDisabled @@ -589,12 +593,14 @@ SIMULATOR_TNT_SPAWN_POSITION_Z = §7z-Position §8- §e{0} SIMULATOR_TNT_SPAWN_ACTIVATED_WITH = §7Primed by §8- §e{0} SIMULATOR_TNT_SPAWN_ACTIVATED_WITH_COMPARATOR = Comparator SIMULATOR_TNT_SPAWN_ACTIVATED_WITH_REPEATER = Repeater +SIMULATOR_TNT_SPAWN_ACTIVATED_UNKNOWN = Unknown SIMULATOR_TNT_SPAWN_MATERIAL = §eMaterial SIMULATOR_TNT_SPAWN_MATERIAL_LORE_1 = §7Current material§8: §e{0} SIMULATOR_TNT_SPAWN_MATERIAL_LORE_2 = §eLeft-Click §7to change SIMULATOR_TNT_SPAWN_MATERIAL_LORE_3 = §eRight-Click §7to reset -SIMULATOR_MATERIAL_GUI_NAME = Cahgen material +SIMULATOR_MATERIAL_GUI_NAME = Change material SIMULATOR_MATERIAL_NAME = §e{0} +SIMULATOR_MATERIAL_NAME_LORE = §7Material §8- §e{0} SIMULATOR_MATERIAL_CLICK = §eClick to choose SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE = §eAdd prime phase SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE_SHIFT = §eShift-Click§8: §7Add prime phase with 1 tick offset diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulatorn/TNTSimulator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulatorn/TNTSimulator.java index be4eb8e7..98c81500 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulatorn/TNTSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulatorn/TNTSimulator.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.simulatorn; +import de.steamwar.bausystem.features.simulatorn.gui.TNTElementGUI; import de.steamwar.bausystem.features.simulatorn.gui.TNTSimulatorGui; import de.steamwar.bausystem.features.simulatorn.show.SimulatorEntityShowMode; import de.steamwar.bausystem.features.simulatorn.tnt.SimulatorElement; @@ -126,7 +127,9 @@ public class TNTSimulator { public void edit(Player player, RayTraceResult result) { if (result == null) { - TNTSimulatorGui.open(player, this, getTntElementList()); + TNTSimulatorGui.open(player, vector -> { + + }, getTntElementList(), null); return; } @@ -137,14 +140,16 @@ public class TNTSimulator { if (elements.isEmpty()) return; if (elements.size() == 1) { - // elements.get(0).edit(player, result); + TNTElementGUI.open(player, (TNTElement) elements.get(0), null); } else { - TNTSimulatorGui.open(player, null, elements); + TNTSimulatorGui.open(player, null, elements, null); } return; } - tntElementList.add(new TNTElement(SimulatorCursor.getPos(player, result))); + TNTElement tntElement = new TNTElement(SimulatorCursor.getPos(player, result)); + tntElementList.add(tntElement); + TNTElementGUI.open(player, tntElement, null); playerShowMode.forEach((p, simulatorEntityShowMode) -> { show(p); }); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulatorn/gui/TNTElementGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulatorn/gui/TNTElementGUI.java new file mode 100644 index 00000000..ea2a8365 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulatorn/gui/TNTElementGUI.java @@ -0,0 +1,99 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 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 . + */ + +package de.steamwar.bausystem.features.simulatorn.gui; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.simulatorn.tnt.TNTElement; +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.List; + +@UtilityClass +public class TNTElementGUI { + + public void open(Player player, TNTElement tntElement, Runnable back) { + SWInventory inv = new SWInventory(player, 45, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_GUI_NAME", player)); + SWItem gray = new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§f", clickType -> {}); + for (int i = 0; i < 9; i++) { + inv.setItem(i, gray); + inv.setItem(i + 36, gray); + } + if (back != null) { + inv.setItem(36, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("SIMULATOR_BACK", player), clickType -> back.run())); + } + + List locationLore = new ArrayList<>(); + locationLore.add(""); + locationLore.add(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_X", player, tntElement.getPosition().getX())); + locationLore.add(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Y", player, tntElement.getPosition().getY())); + locationLore.add(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Z", player, tntElement.getPosition().getZ())); + inv.setItem(20, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_LOCATION", player), locationLore, false, clickType -> { + + })); + + List propertiesLore = new ArrayList<>(); + propertiesLore.add(""); + propertiesLore.add(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_COUNT", player, tntElement.getCount())); + propertiesLore.add(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK", player, tntElement.getTickOffset())); + propertiesLore.add(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_FUSE", player, tntElement.getFuseTicks())); + propertiesLore.add(""); + propertiesLore.add(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_X", player, active(player, tntElement.isXVelocity()))); + propertiesLore.add(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_Y", player, active(player, tntElement.isYVelocity()))); + propertiesLore.add(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_Z", player, active(player, tntElement.isZVelocity()))); + inv.setItem(22, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_PROPERTIES", player), propertiesLore, false, clickType -> { + + })); + + List otherLore = new ArrayList<>(); + otherLore.add(""); + otherLore.add(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ACTIVATED_WITH", player, activationType(player, tntElement.getOrder()))); + otherLore.add(BauSystem.MESSAGE.parse("SIMULATOR_MATERIAL_NAME_LORE", player, tntElement.getMaterial().name())); + inv.setItem(24, new SWItem(Material.ANVIL, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_OTHER", player), otherLore, false, clickType -> { + + })); + + inv.open(); + } + + private String active(Player p, boolean active) { + return active ? BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_ON", p) : BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_OFF", p); + } + + private String activationType(Player p, int order) { + String s; + switch (order) { + case 0: + s = "SIMULATOR_TNT_SPAWN_ACTIVATED_WITH_REPEATER"; + break; + case 1: + s = "SIMULATOR_TNT_SPAWN_ACTIVATED_WITH_COMPARATOR"; + break; + default: + s = "SIMULATOR_TNT_SPAWN_ACTIVATED_UNKNOWN"; + break; + } + return BauSystem.MESSAGE.parse(s, p); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulatorn/gui/TNTSimulatorGui.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulatorn/gui/TNTSimulatorGui.java index 4845aac7..b6e654a6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulatorn/gui/TNTSimulatorGui.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulatorn/gui/TNTSimulatorGui.java @@ -20,19 +20,25 @@ package de.steamwar.bausystem.features.simulatorn.gui; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.simulatorn.TNTSimulator; import de.steamwar.bausystem.features.simulatorn.tnt.SimulatorElement; +import de.steamwar.bausystem.features.simulatorn.tnt.TNTElement; +import de.steamwar.bausystem.features.simulatorn.tnt.TNTGroup; +import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; import lombok.experimental.UtilityClass; +import org.bukkit.Material; +import org.bukkit.block.data.type.TNT; import org.bukkit.entity.Player; +import org.bukkit.util.Vector; import java.util.ArrayList; import java.util.List; +import java.util.function.Consumer; @UtilityClass public class TNTSimulatorGui { - public void open(Player player, TNTSimulator simulator, List simulatorElements) { + public void open(Player player, Consumer moveAll, List simulatorElements, Runnable back) { List> swListEntryList = new ArrayList<>(); for (SimulatorElement element : simulatorElements) { @@ -40,7 +46,19 @@ public class TNTSimulatorGui { } SWListInv inv = new SWListInv<>(player, BauSystem.MESSAGE.parse("SIMULATOR_GUI_NAME", player), false, swListEntryList, (clickType, simulatorElement) -> { + if (simulatorElement instanceof TNTGroup) { + TNTGroup tntGroup = (TNTGroup) simulatorElement; + List elements = new ArrayList<>(tntGroup.getElements()); + open(player, vector -> { + + }, elements, () -> open(player, moveAll, simulatorElements, back)); + } else { + TNTElementGUI.open(player, (TNTElement) simulatorElement, () -> open(player, moveAll, simulatorElements, back)); + } }); + if (back != null) { + inv.setItem(47, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("SIMULATOR_BACK", player), clickType -> back.run())); + } // TODO: Add button diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulatorn/tnt/TNTElement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulatorn/tnt/TNTElement.java index 9c0c2039..d5c6df6c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulatorn/tnt/TNTElement.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulatorn/tnt/TNTElement.java @@ -31,7 +31,6 @@ import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; -import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; import yapion.hierarchy.types.YAPIONObject; @@ -111,7 +110,7 @@ public class TNTElement implements SimulatorElement { return position.clone(); } - protected int getTickOffset() { + public int getTickOffset() { if (tntGroup != null) { return tntGroup.getTickOffset() + tickOffset; }