|
|
|
@ -19,7 +19,7 @@
|
|
|
|
|
* /
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package de.steamwar.bausystem.canonsimulator;
|
|
|
|
|
package de.steamwar.bausystem.cannonsimulator;
|
|
|
|
|
|
|
|
|
|
import de.steamwar.bausystem.BauSystem;
|
|
|
|
|
import de.steamwar.inventory.SWInventory;
|
|
|
|
@ -42,17 +42,18 @@ public class TNTSimulator {
|
|
|
|
|
private static final Vector NY_VECTOR = new Vector(0, -0.0625, 0);
|
|
|
|
|
private static final Vector Z_VECTOR = new Vector(0, 0, 0.0625);
|
|
|
|
|
private static final Vector NZ_VECTOR = new Vector(0, 0, -0.0625);
|
|
|
|
|
private static final List<String> LORE = Collections.singletonList("§7Klicken zum ändern");
|
|
|
|
|
private static final List<String> LORE = Collections.singletonList("§7Zum ändern klicken");
|
|
|
|
|
|
|
|
|
|
static Map<Player, TNTSimulator> tntSimulatorMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
public static final ItemStack WAND = new SWItem(Material.TRIPWIRE_HOOK, "§6Kanonen Simulator", Arrays.asList("§eRechts Klick Block §8- §7Füge einen TNT hinzu", "§eRechts Klick Luft §8- §7Öffne den Simulator", "§eLinks Klick §8- §7Starte die Simulation"), false, null).getItemStack();
|
|
|
|
|
public static final ItemStack WAND = new SWItem(Material.TRIPWIRE_HOOK, "§eKanonen Simulator", Arrays.asList("§eRechtsklick Block §8- §7Füge einen TNT hinzu", "§eRechtsklick Luft §8- §7Öffne den Simulator", "§eLinksklick §8- §7Starte die Simulation"), false, null).getItemStack();
|
|
|
|
|
|
|
|
|
|
public static TNTSimulator get(Player player) {
|
|
|
|
|
return tntSimulatorMap.computeIfAbsent(player, p -> new TNTSimulator());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void openSimulator(Player player) {
|
|
|
|
|
if (!tntSimulatorMap.containsKey(player)) {
|
|
|
|
|
tntSimulatorMap.put(player, new TNTSimulator());
|
|
|
|
|
}
|
|
|
|
|
TNTSimulator tntSimulator = tntSimulatorMap.get(player);
|
|
|
|
|
TNTSimulator tntSimulator = get(player);
|
|
|
|
|
|
|
|
|
|
List<SWListInv.SWListEntry<TNTSpawn>> swListEntryList = new ArrayList<>();
|
|
|
|
|
tntSimulator.tntSpawns.forEach(tntSpawn -> {
|
|
|
|
@ -66,11 +67,11 @@ public class TNTSimulator {
|
|
|
|
|
lore.add("§eX§8: §7" + tntSpawn.getPosition().getX());
|
|
|
|
|
lore.add("§eY§8: §7" + tntSpawn.getPosition().getY());
|
|
|
|
|
lore.add("§eZ§8: §7" + tntSpawn.getPosition().getZ());
|
|
|
|
|
swListEntryList.add(new SWListInv.SWListEntry<>(new SWItem(Material.TNT, "§6TNT", lore, false, null), tntSpawn));
|
|
|
|
|
swListEntryList.add(new SWListInv.SWListEntry<>(new SWItem(Material.TNT, "§eTNT", lore, false, null), tntSpawn));
|
|
|
|
|
});
|
|
|
|
|
swListEntryList.sort(Comparator.comparing(SWListInv.SWListEntry::getObject));
|
|
|
|
|
|
|
|
|
|
SWListInv<TNTSpawn> swListInv = new SWListInv<>(player, "Kanonen Simulator", false, swListEntryList, (clickType, tntSpawn) -> {
|
|
|
|
|
SWListInv<TNTSpawn> swListInv = new SWListInv<>(player, "Kanonensimulator", false, swListEntryList, (clickType, tntSpawn) -> {
|
|
|
|
|
editTNT(player, tntSpawn);
|
|
|
|
|
});
|
|
|
|
|
swListInv.setItem(51, new SWItem(Material.BARRIER, "§cLösche alle TNT", clickType -> {
|
|
|
|
@ -91,7 +92,7 @@ public class TNTSimulator {
|
|
|
|
|
tntSimulator.tntSpawns.add(tntSpawn);
|
|
|
|
|
editTNT(player, tntSpawn);
|
|
|
|
|
}));
|
|
|
|
|
swListInv.setItem(47, new SWItem(Material.FLINT_AND_STEEL, "§eSimulation Starten", clickType -> {
|
|
|
|
|
swListInv.setItem(47, new SWItem(Material.FLINT_AND_STEEL, "§eSimulation starten", clickType -> {
|
|
|
|
|
startSimulation(player);
|
|
|
|
|
player.closeInventory();
|
|
|
|
|
}));
|
|
|
|
@ -99,18 +100,15 @@ public class TNTSimulator {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void editTNT(Player player, TNTSpawn tntSpawn) {
|
|
|
|
|
if (!tntSimulatorMap.containsKey(player)) {
|
|
|
|
|
tntSimulatorMap.put(player, new TNTSimulator());
|
|
|
|
|
}
|
|
|
|
|
TNTSimulator tntSimulator = tntSimulatorMap.get(player);
|
|
|
|
|
TNTSimulator tntSimulator = get(player);
|
|
|
|
|
|
|
|
|
|
SWInventory swInventory = new SWInventory(player, 54, "TNT");
|
|
|
|
|
swInventory.setItem(49, new SWItem(Material.REDSTONE_BLOCK, "§cZurück", clickType -> {
|
|
|
|
|
openSimulator(player);
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
// Delete icon
|
|
|
|
|
swInventory.setItem(53, new SWItem(Material.BARRIER, "§cDelete", clickType -> {
|
|
|
|
|
// Delete tnt
|
|
|
|
|
swInventory.setItem(53, new SWItem(Material.BARRIER, "§cEntfernen", clickType -> {
|
|
|
|
|
tntSimulator.tntSpawns.remove(tntSpawn);
|
|
|
|
|
openSimulator(player);
|
|
|
|
|
}));
|
|
|
|
@ -118,15 +116,15 @@ public class TNTSimulator {
|
|
|
|
|
// Change Count of spawned TNT
|
|
|
|
|
swInventory.setItem(10, new SWItem(SWItem.getDye(10), "§a+1", clickType -> {
|
|
|
|
|
tntSpawn.setCount(tntSpawn.getCount() + 1);
|
|
|
|
|
if (tntSpawn.getCount() > 1000) {
|
|
|
|
|
tntSpawn.setCount(1000);
|
|
|
|
|
if (tntSpawn.getCount() > 400) {
|
|
|
|
|
tntSpawn.setCount(400);
|
|
|
|
|
}
|
|
|
|
|
editTNT(player, tntSpawn);
|
|
|
|
|
}));
|
|
|
|
|
swInventory.setItem(19, new SWItem(Material.TNT, "§eAnzahl §8- §7" + tntSpawn.getCount(), LORE, false, clickType -> {
|
|
|
|
|
changeCount(player, tntSpawn.getCount(), count -> {
|
|
|
|
|
if (count < 1) count = 1;
|
|
|
|
|
if (count > 1000) count = 1000;
|
|
|
|
|
if (count > 400) count = 400;
|
|
|
|
|
tntSpawn.setCount(count);
|
|
|
|
|
editTNT(player, tntSpawn);
|
|
|
|
|
}, () -> editTNT(player, tntSpawn));
|
|
|
|
@ -188,15 +186,15 @@ public class TNTSimulator {
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
// Velocity Settings
|
|
|
|
|
swInventory.setItem(13, new SWItem(tntSpawn.isxVelocity() ? Material.LIME_WOOL : Material.RED_WOOL, "§7Start §eVelocity X §8- §7" + active(tntSpawn.isxVelocity()), clickType -> {
|
|
|
|
|
swInventory.setItem(13, new SWItem(tntSpawn.isxVelocity() ? Material.LIME_CONCRETE : Material.RED_CONCRETE, "§7Start §eVelocity X §8- §7" + active(tntSpawn.isxVelocity()), clickType -> {
|
|
|
|
|
tntSpawn.setxVelocity(!tntSpawn.isxVelocity());
|
|
|
|
|
editTNT(player, tntSpawn);
|
|
|
|
|
}));
|
|
|
|
|
swInventory.setItem(22, new SWItem(tntSpawn.isyVelocity() ? Material.LIME_WOOL : Material.RED_WOOL, "§7Start §eVelocity Y §8- §7" + active(tntSpawn.isyVelocity()), clickType -> {
|
|
|
|
|
swInventory.setItem(22, new SWItem(tntSpawn.isyVelocity() ? Material.LIME_CONCRETE : Material.RED_CONCRETE, "§7Start §eVelocity Y §8- §7" + active(tntSpawn.isyVelocity()), clickType -> {
|
|
|
|
|
tntSpawn.setyVelocity(!tntSpawn.isyVelocity());
|
|
|
|
|
editTNT(player, tntSpawn);
|
|
|
|
|
}));
|
|
|
|
|
swInventory.setItem(31, new SWItem(tntSpawn.iszVelocity() ? Material.LIME_WOOL : Material.RED_WOOL, "§7Start §eVelocity Z §8- §7" + active(tntSpawn.iszVelocity()), clickType -> {
|
|
|
|
|
swInventory.setItem(31, new SWItem(tntSpawn.iszVelocity() ? Material.LIME_CONCRETE : Material.RED_CONCRETE, "§7Start §eVelocity Z §8- §7" + active(tntSpawn.iszVelocity()), clickType -> {
|
|
|
|
|
tntSpawn.setzVelocity(!tntSpawn.iszVelocity());
|
|
|
|
|
editTNT(player, tntSpawn);
|
|
|
|
|
}));
|
|
|
|
@ -206,7 +204,7 @@ public class TNTSimulator {
|
|
|
|
|
tntSpawn.getPosition().add(X_VECTOR);
|
|
|
|
|
editTNT(player, tntSpawn);
|
|
|
|
|
}));
|
|
|
|
|
swInventory.setItem(23, new SWItem(Material.PAPER, "§ePosition-X §8- §7" + tntSpawn.getPosition().getX(), LORE, false, clickType -> {
|
|
|
|
|
swInventory.setItem(23, new SWItem(Material.PAPER, "§ex-Position §8- §7" + tntSpawn.getPosition().getX(), LORE, false, clickType -> {
|
|
|
|
|
changePosition(player, tntSpawn.getPosition().getX(), x -> {
|
|
|
|
|
tntSpawn.getPosition().setX(clamp(x));
|
|
|
|
|
editTNT(player, tntSpawn);
|
|
|
|
@ -222,7 +220,7 @@ public class TNTSimulator {
|
|
|
|
|
tntSpawn.getPosition().add(Y_VECTOR);
|
|
|
|
|
editTNT(player, tntSpawn);
|
|
|
|
|
}));
|
|
|
|
|
swInventory.setItem(24, new SWItem(Material.PAPER, "§ePosition-Y §8- §7" + tntSpawn.getPosition().getY(), LORE, false, clickType -> {
|
|
|
|
|
swInventory.setItem(24, new SWItem(Material.PAPER, "§ey-Position §8- §7" + tntSpawn.getPosition().getY(), LORE, false, clickType -> {
|
|
|
|
|
changePosition(player, tntSpawn.getPosition().getY(), y -> {
|
|
|
|
|
tntSpawn.getPosition().setY(clamp(y));
|
|
|
|
|
editTNT(player, tntSpawn);
|
|
|
|
@ -238,7 +236,7 @@ public class TNTSimulator {
|
|
|
|
|
tntSpawn.getPosition().add(Z_VECTOR);
|
|
|
|
|
editTNT(player, tntSpawn);
|
|
|
|
|
}));
|
|
|
|
|
swInventory.setItem(25, new SWItem(Material.PAPER, "§ePosition-Z §8- §7" + tntSpawn.getPosition().getZ(), LORE, false, clickType -> {
|
|
|
|
|
swInventory.setItem(25, new SWItem(Material.PAPER, "§ez-Position §8- §7" + tntSpawn.getPosition().getZ(), LORE, false, clickType -> {
|
|
|
|
|
changePosition(player, tntSpawn.getPosition().getZ(), z -> {
|
|
|
|
|
tntSpawn.getPosition().setZ(clamp(z));
|
|
|
|
|
editTNT(player, tntSpawn);
|