Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
a516363fdb
Commit
b4466e6444
@ -26,6 +26,8 @@ import de.steamwar.bausystem.features.simulator.TNTSimulator;
|
|||||||
import de.steamwar.bausystem.features.simulator.gui.components.ChangeMaterial;
|
import de.steamwar.bausystem.features.simulator.gui.components.ChangeMaterial;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.components.ChangePosition;
|
import de.steamwar.bausystem.features.simulator.gui.components.ChangePosition;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.components.Disabled;
|
import de.steamwar.bausystem.features.simulator.gui.components.Disabled;
|
||||||
|
import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement;
|
||||||
|
import de.steamwar.bausystem.features.simulator.tnt.TNTElement;
|
||||||
import de.steamwar.bausystem.features.simulator.tnt.TNTGroup;
|
import de.steamwar.bausystem.features.simulator.tnt.TNTGroup;
|
||||||
import de.steamwar.inventory.SWAnvilInv;
|
import de.steamwar.inventory.SWAnvilInv;
|
||||||
import de.steamwar.inventory.SWInventory;
|
import de.steamwar.inventory.SWInventory;
|
||||||
@ -35,15 +37,111 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.util.Consumer;
|
import org.bukkit.util.Consumer;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
|
|
||||||
|
import static de.steamwar.bausystem.features.simulator.gui.ItemUtils.unique;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class TNTGroupEditGUI {
|
public class TNTGroupEditGUI {
|
||||||
|
|
||||||
|
private static final Vector X_VECTOR = new Vector(0.0625, 0, 0);
|
||||||
|
private static final Vector Y_VECTOR = new Vector(0, 0.0625, 0);
|
||||||
|
private static final Vector Z_VECTOR = new Vector(0, 0, 0.0625);
|
||||||
|
|
||||||
|
private static final Vector FX_VECTOR = new Vector(1, 0, 0);
|
||||||
|
private static final Vector FY_VECTOR = new Vector(0, 1, 0);
|
||||||
|
private static final Vector FZ_VECTOR = new Vector(0, 0, 1);
|
||||||
|
|
||||||
|
public void open(Player player, TNTSimulator tntSimulator, List<SimulatorElement> simulatorElements, Runnable back) {
|
||||||
|
SWInventory inv = new SWInventory(player, 45, BauSystem.MESSAGE.parse("SIMULATOR_MOVE_ALL_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()));
|
||||||
|
}
|
||||||
|
|
||||||
|
String plusOneName = BauSystem.MESSAGE.parse("SIMULATOR_PLUS_ONE", player);
|
||||||
|
String minusOneName = BauSystem.MESSAGE.parse("SIMULATOR_MINUS_ONE", player);
|
||||||
|
List<String> plusOnePixelShiftLore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_PLUS_PIXEL_SHIFT", player));
|
||||||
|
List<String> minusOnePixelShiftLore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_MINUS_PIXEL_SHIFT", player));
|
||||||
|
List<String> lore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_LORE", player));
|
||||||
|
|
||||||
|
Vector vector = simulatorElements.get(0).getPosition();
|
||||||
|
|
||||||
|
// X Position
|
||||||
|
inv.setItem(12, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||||
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
|
tntSimulator.hide();
|
||||||
|
moveAll(simulatorElements, clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
|
||||||
|
tntSimulator.show();
|
||||||
|
tntSimulator.change();
|
||||||
|
})));
|
||||||
|
inv.setItem(21, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_X", player, vector.getX()), lore, false, clickType -> {}));
|
||||||
|
inv.setItem(30, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||||
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
|
tntSimulator.hide();
|
||||||
|
moveAll(simulatorElements, (clickType.isShiftClick() ? X_VECTOR : FX_VECTOR).clone().multiply(-1));
|
||||||
|
tntSimulator.show();
|
||||||
|
tntSimulator.change();
|
||||||
|
})));
|
||||||
|
|
||||||
|
// Y Position
|
||||||
|
inv.setItem(13, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||||
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
|
tntSimulator.hide();
|
||||||
|
moveAll(simulatorElements, clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
|
||||||
|
tntSimulator.show();
|
||||||
|
tntSimulator.change();
|
||||||
|
})));
|
||||||
|
inv.setItem(22, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Y", player, vector.getY()), lore, false, clickType -> {}));
|
||||||
|
inv.setItem(31, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||||
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
|
tntSimulator.hide();
|
||||||
|
moveAll(simulatorElements, (clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR).clone().multiply(-1));
|
||||||
|
tntSimulator.show();
|
||||||
|
tntSimulator.change();
|
||||||
|
})));
|
||||||
|
|
||||||
|
// Z Position
|
||||||
|
inv.setItem(14, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||||
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
|
tntSimulator.hide();
|
||||||
|
moveAll(simulatorElements, clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
|
||||||
|
tntSimulator.show();
|
||||||
|
tntSimulator.change();
|
||||||
|
})));
|
||||||
|
inv.setItem(23, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Z", player, vector.getZ()), lore, false, clickType -> {}));
|
||||||
|
inv.setItem(32, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||||
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
|
tntSimulator.hide();
|
||||||
|
moveAll(simulatorElements, (clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR).clone().multiply(-1));
|
||||||
|
tntSimulator.show();
|
||||||
|
})));
|
||||||
|
|
||||||
|
inv.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveAll(List<SimulatorElement> simulatorElements, Vector vector) {
|
||||||
|
for (SimulatorElement element : simulatorElements) {
|
||||||
|
if (element instanceof TNTGroup) {
|
||||||
|
TNTGroup group = (TNTGroup) element;
|
||||||
|
group.getPosition().add(vector);
|
||||||
|
} else if (element instanceof TNTElement) {
|
||||||
|
TNTElement tntElement = (TNTElement) element;
|
||||||
|
tntElement.getOwnPosition().add(vector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void open(Player player, TNTGroup tntGroup, Runnable back) {
|
public void open(Player player, TNTGroup tntGroup, Runnable back) {
|
||||||
SWInventory inv = new SWInventory(player, 45, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_GROUP_MENU", player));
|
SWInventory inv = new SWInventory(player, 45, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_GROUP_MENU", player));
|
||||||
SWItem gray = new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§f", clickType -> {});
|
SWItem gray = new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§f", clickType -> {});
|
||||||
|
@ -42,6 +42,8 @@ import java.util.Comparator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import static de.steamwar.bausystem.features.simulator.gui.ItemUtils.unique;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class TNTSimulatorGui {
|
public class TNTSimulatorGui {
|
||||||
|
|
||||||
@ -90,7 +92,8 @@ public class TNTSimulatorGui {
|
|||||||
SWItem swItem = new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("SIMULATOR_GUI_TOTAL_TNT", player, totalTNTCount), clickType -> {
|
SWItem swItem = new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("SIMULATOR_GUI_TOTAL_TNT", player, totalTNTCount), clickType -> {
|
||||||
});
|
});
|
||||||
swItem.getItemStack().setAmount(totalTNTCount);
|
swItem.getItemStack().setAmount(totalTNTCount);
|
||||||
inv.setItem(currentTntSimulator != null || currentTntGroup != null ? 50 : 49, swItem);
|
List<SimulatorElement> elements = simulatorElements.get();
|
||||||
|
inv.setItem(elements.isEmpty() ? 49 : 50, swItem);
|
||||||
if (currentTntGroup != null) {
|
if (currentTntGroup != null) {
|
||||||
Runnable editObserver = () -> {
|
Runnable editObserver = () -> {
|
||||||
List<String> otherLore = new ArrayList<>();
|
List<String> otherLore = new ArrayList<>();
|
||||||
@ -117,6 +120,12 @@ public class TNTSimulatorGui {
|
|||||||
SimulatorPreviewStorage.recalculate(currentTntSimulator);
|
SimulatorPreviewStorage.recalculate(currentTntSimulator);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
if (!elements.isEmpty()) {
|
||||||
|
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
|
||||||
|
inv.setItem(48, new SWItem(Material.ANVIL, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_GROUP", player), new ArrayList<>(), false, clickType -> {
|
||||||
|
TNTGroupEditGUI.open(player, tntSimulator, elements, () -> open(player, currentTntSimulator, currentTntGroup, simulatorElements, back));
|
||||||
|
}));
|
||||||
|
}
|
||||||
inv.addCloseCallback(clickType -> {
|
inv.addCloseCallback(clickType -> {
|
||||||
SimulatorPreviewStorage.recalculate(currentTntSimulator);
|
SimulatorPreviewStorage.recalculate(currentTntSimulator);
|
||||||
});
|
});
|
||||||
@ -158,54 +167,54 @@ public class TNTSimulatorGui {
|
|||||||
List<String> lore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_LORE", player));
|
List<String> lore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_LORE", player));
|
||||||
|
|
||||||
// X Position
|
// X Position
|
||||||
inv.setItem(12, new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(12, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
tntSimulator.hide();
|
tntSimulator.hide();
|
||||||
moveAll(tntSimulator, clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
|
moveAll(tntSimulator, clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
|
||||||
tntSimulator.show();
|
tntSimulator.show();
|
||||||
tntSimulator.change();
|
tntSimulator.change();
|
||||||
}));
|
})));
|
||||||
inv.setItem(21, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_POSITION_X", player), lore, false, clickType -> {}));
|
inv.setItem(21, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_POSITION_X", player), lore, false, clickType -> {}));
|
||||||
inv.setItem(30, new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(30, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
tntSimulator.hide();
|
tntSimulator.hide();
|
||||||
moveAll(tntSimulator, (clickType.isShiftClick() ? X_VECTOR : FX_VECTOR).clone().multiply(-1));
|
moveAll(tntSimulator, (clickType.isShiftClick() ? X_VECTOR : FX_VECTOR).clone().multiply(-1));
|
||||||
tntSimulator.show();
|
tntSimulator.show();
|
||||||
tntSimulator.change();
|
tntSimulator.change();
|
||||||
}));
|
})));
|
||||||
|
|
||||||
// Y Position
|
// Y Position
|
||||||
inv.setItem(13, new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(13, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
tntSimulator.hide();
|
tntSimulator.hide();
|
||||||
moveAll(tntSimulator, clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
|
moveAll(tntSimulator, clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
|
||||||
tntSimulator.show();
|
tntSimulator.show();
|
||||||
tntSimulator.change();
|
tntSimulator.change();
|
||||||
}));
|
})));
|
||||||
inv.setItem(22, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_POSITION_Y", player), lore, false, clickType -> {}));
|
inv.setItem(22, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_POSITION_Y", player), lore, false, clickType -> {}));
|
||||||
inv.setItem(31, new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(31, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
tntSimulator.hide();
|
tntSimulator.hide();
|
||||||
moveAll(tntSimulator, (clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR).clone().multiply(-1));
|
moveAll(tntSimulator, (clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR).clone().multiply(-1));
|
||||||
tntSimulator.show();
|
tntSimulator.show();
|
||||||
tntSimulator.change();
|
tntSimulator.change();
|
||||||
}));
|
})));
|
||||||
|
|
||||||
// Z Position
|
// Z Position
|
||||||
inv.setItem(14, new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(14, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
tntSimulator.hide();
|
tntSimulator.hide();
|
||||||
moveAll(tntSimulator, clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
|
moveAll(tntSimulator, clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
|
||||||
tntSimulator.show();
|
tntSimulator.show();
|
||||||
tntSimulator.change();
|
tntSimulator.change();
|
||||||
}));
|
})));
|
||||||
inv.setItem(23, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_POSITION_Z", player), lore, false, clickType -> {}));
|
inv.setItem(23, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_POSITION_Z", player), lore, false, clickType -> {}));
|
||||||
inv.setItem(32, new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(32, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
tntSimulator.hide();
|
tntSimulator.hide();
|
||||||
moveAll(tntSimulator, (clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR).clone().multiply(-1));
|
moveAll(tntSimulator, (clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR).clone().multiply(-1));
|
||||||
tntSimulator.show();
|
tntSimulator.show();
|
||||||
}));
|
})));
|
||||||
|
|
||||||
inv.open();
|
inv.open();
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren