SteamWar/BauSystem2.0
Archiviert
12
0

Update TNTSimulator once again
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-12-10 22:45:06 +01:00
Ursprung da0e2f20cc
Commit eabfead5da

Datei anzeigen

@ -54,6 +54,10 @@ public class TNTSimulator {
private static final Vector Y_VECTOR = new Vector(0, 0.0625, 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 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);
private static final World WORLD = Bukkit.getWorlds().get(0); private static final World WORLD = Bukkit.getWorlds().get(0);
private static final List<String> LORE = Collections.singletonList("§eZum Ändern klicken"); private static final List<String> LORE = Collections.singletonList("§eZum Ändern klicken");
private static final List<TNTSpawn> EMPTY = new ArrayList<>(); private static final List<TNTSpawn> EMPTY = new ArrayList<>();
@ -215,7 +219,10 @@ public class TNTSimulator {
return new SWListInv.SWListEntry<>(swItem, spawn); return new SWListInv.SWListEntry<>(swItem, spawn);
}).sorted(Comparator.comparing(SWListInv.SWListEntry::getObject)).collect(Collectors.toList()); }).sorted(Comparator.comparing(SWListInv.SWListEntry::getObject)).collect(Collectors.toList());
SWListInv<TNTSpawn> swListInv = new SWListInv<>(player, "Kanonensimulator", false, swListEntryList, (clickType, spawn) -> spawn.editTNT()); SWListInv<TNTSpawn> swListInv = new SWListInv<>(player, "Kanonensimulator", false, swListEntryList, (clickType, spawn) -> {
spawn.editTNT();
});
swListInv.setItem(51, new SWItem(Material.BARRIER, "§cTNT löschen", clickType -> { swListInv.setItem(51, new SWItem(Material.BARRIER, "§cTNT löschen", clickType -> {
delete(); delete();
player.closeInventory(); player.closeInventory();
@ -307,6 +314,7 @@ public class TNTSimulator {
private boolean printed = false; private boolean printed = false;
private final Vector position; private final Vector position;
private int fuseTicks = 80;
private int count = 1; private int count = 1;
private int tickOffset = 0; private int tickOffset = 0;
private boolean xVelocity = false; private boolean xVelocity = false;
@ -324,6 +332,7 @@ public class TNTSimulator {
private TNTSpawn(YAPIONObject yapionObject) { private TNTSpawn(YAPIONObject yapionObject) {
this.position = new Vector(yapionObject.getPlainValueOrDefault("positionX", 0.0), yapionObject.getPlainValueOrDefault("positionY", 0.0), yapionObject.getPlainValueOrDefault("positionZ", 0.0)); this.position = new Vector(yapionObject.getPlainValueOrDefault("positionX", 0.0), yapionObject.getPlainValueOrDefault("positionY", 0.0), yapionObject.getPlainValueOrDefault("positionZ", 0.0));
this.entity = SimulatorEntityShowMode.createEntity(player, position, false); this.entity = SimulatorEntityShowMode.createEntity(player, position, false);
this.fuseTicks = yapionObject.getPlainValue("fuseTicks");
this.count = yapionObject.getPlainValue("count"); this.count = yapionObject.getPlainValue("count");
this.tickOffset = yapionObject.getPlainValue("tickOffset"); this.tickOffset = yapionObject.getPlainValue("tickOffset");
this.xVelocity = yapionObject.getPlainValue("xVelocity"); this.xVelocity = yapionObject.getPlainValue("xVelocity");
@ -337,6 +346,7 @@ public class TNTSimulator {
yapionObject.add("positionX", position.getX()); yapionObject.add("positionX", position.getX());
yapionObject.add("positionY", position.getY()); yapionObject.add("positionY", position.getY());
yapionObject.add("positionZ", position.getZ()); yapionObject.add("positionZ", position.getZ());
yapionObject.add("fuseTicks", fuseTicks);
yapionObject.add("count", count); yapionObject.add("count", count);
yapionObject.add("tickOffset", tickOffset); yapionObject.add("tickOffset", tickOffset);
yapionObject.add("xVelocity", xVelocity); yapionObject.add("xVelocity", xVelocity);
@ -362,12 +372,19 @@ public class TNTSimulator {
private void spawn() { private void spawn() {
WORLD.spawn(position.toLocation(WORLD), TNTPrimed.class, tntPrimed -> { WORLD.spawn(position.toLocation(WORLD), TNTPrimed.class, tntPrimed -> {
tntPrimed.setFuseTicks(fuseTicks);
if (!xVelocity) tntPrimed.setVelocity(tntPrimed.getVelocity().setX(0)); if (!xVelocity) tntPrimed.setVelocity(tntPrimed.getVelocity().setX(0));
if (!yVelocity) tntPrimed.setVelocity(tntPrimed.getVelocity().setY(0)); if (!yVelocity) tntPrimed.setVelocity(tntPrimed.getVelocity().setY(0));
if (!zVelocity) tntPrimed.setVelocity(tntPrimed.getVelocity().setZ(0)); if (!zVelocity) tntPrimed.setVelocity(tntPrimed.getVelocity().setZ(0));
}); });
} }
private void setFuseTicks(int fuseTicks) {
if (fuseTicks < 0) fuseTicks = 0;
if (fuseTicks > 160) fuseTicks = 160;
this.fuseTicks = fuseTicks;
}
private void setCount(int count) { private void setCount(int count) {
if (count < 1) count = 1; if (count < 1) count = 1;
if (count > 400) count = 400; if (count > 400) count = 400;
@ -396,8 +413,8 @@ public class TNTSimulator {
SWInventory swInventory = new SWInventory(player, 54, "TNT konfigurieren"); SWInventory swInventory = new SWInventory(player, 54, "TNT konfigurieren");
// Change Count of spawned TNT // Change Count of spawned TNT
swInventory.setItem(1, new SWItem(SWItem.getDye(10), "§7+1", clickType -> { swInventory.setItem(1, new SWItem(SWItem.getDye(10), "§7+1", Arrays.asList("§eShift §7Click für §e-10"), false, clickType -> {
setCount(count + 1); setCount(count + (clickType.isShiftClick() ? 10 : 1));
editTNT(); editTNT();
})); }));
SWItem countItem = new SWItem(Material.TNT, "§7TNT-Anzahl §8- §e" + count, LORE, false, clickType -> changeCount(player, "Anzahl TNT", count, c -> { SWItem countItem = new SWItem(Material.TNT, "§7TNT-Anzahl §8- §e" + count, LORE, false, clickType -> changeCount(player, "Anzahl TNT", count, c -> {
@ -406,14 +423,14 @@ public class TNTSimulator {
}, this::editTNT)); }, this::editTNT));
countItem.getItemStack().setAmount(count); countItem.getItemStack().setAmount(count);
swInventory.setItem(10, countItem); swInventory.setItem(10, countItem);
swInventory.setItem(19, new SWItem(SWItem.getDye(1), "§7-1", clickType -> { swInventory.setItem(19, new SWItem(SWItem.getDye(1), "§7-1", Arrays.asList("§eShift §7Click für §e-10"), false, clickType -> {
setCount(count - 1); setCount(count - (clickType.isShiftClick() ? 10 : 1));
editTNT(); editTNT();
})); }));
// Change TickOffset // Change TickOffset
swInventory.setItem(2, new SWItem(SWItem.getDye(10), "§7+1", clickType -> { swInventory.setItem(2, new SWItem(SWItem.getDye(10), "§7+1", Arrays.asList("§eShift §7Click für §e+5"), false, clickType -> {
setTickOffset(tickOffset + 1); setTickOffset(count + (clickType.isShiftClick() ? 5 : 1));
editTNT(); editTNT();
})); }));
SWItem tickItem = new SWItem(SWItem.getMaterial("DIODE"), "§7Tick §8- §e" + tickOffset, LORE, false, clickType -> changeCount(player, "Tick Offset", tickOffset, tick -> { SWItem tickItem = new SWItem(SWItem.getMaterial("DIODE"), "§7Tick §8- §e" + tickOffset, LORE, false, clickType -> changeCount(player, "Tick Offset", tickOffset, tick -> {
@ -422,8 +439,24 @@ public class TNTSimulator {
}, this::editTNT)); }, this::editTNT));
tickItem.getItemStack().setAmount(Math.max(tickOffset, 1)); tickItem.getItemStack().setAmount(Math.max(tickOffset, 1));
swInventory.setItem(11, tickItem); swInventory.setItem(11, tickItem);
swInventory.setItem(20, new SWItem(SWItem.getDye(1), "§7-1", clickType -> { swInventory.setItem(20, new SWItem(SWItem.getDye(1), "§7-1", Arrays.asList("§eShift §7Click für §e-5"), false, clickType -> {
setTickOffset(tickOffset - 1); setTickOffset(count - (clickType.isShiftClick() ? 5 : 1));
editTNT();
}));
// Change FuseTicks
swInventory.setItem(3, new SWItem(SWItem.getDye(10), "§7+1", clickType -> {
setFuseTicks(fuseTicks + 1);
editTNT();
}));
SWItem fuseTickItem = new SWItem(Material.CLOCK, "§7Lebensdauer §8- §e" + fuseTicks, LORE, false, clickType -> changeCount(player, "Fuse-Ticks", fuseTicks, tick -> {
setFuseTicks(tick);
editTNT();
}, this::editTNT));
fuseTickItem.getItemStack().setAmount(Math.max(fuseTicks, 1));
swInventory.setItem(12, fuseTickItem);
swInventory.setItem(21, new SWItem(SWItem.getDye(1), "§7-1", clickType -> {
setFuseTicks(fuseTicks - 1);
editTNT(); editTNT();
})); }));
@ -445,8 +478,8 @@ public class TNTSimulator {
// Position Settings // Position Settings
// X Position // X Position
swInventory.setItem(5, new SWItem(SWItem.getDye(10), "§7+0,0625", clickType -> { swInventory.setItem(5, new SWItem(SWItem.getDye(10), "§7+0,0625", Arrays.asList("§eShift §7Click für §e+1"), false, clickType -> {
position.add(X_VECTOR); position.add(clickType.isShiftClick() ? FX_VECTOR : X_VECTOR);
editTNT(); editTNT();
})); }));
swInventory.setItem(14, new SWItem(Material.PAPER, "§7x-Position §8- §e" + position.getX(), LORE, false, clickType -> { swInventory.setItem(14, new SWItem(Material.PAPER, "§7x-Position §8- §e" + position.getX(), LORE, false, clickType -> {
@ -455,14 +488,14 @@ public class TNTSimulator {
editTNT(); editTNT();
}, this::editTNT); }, this::editTNT);
})); }));
swInventory.setItem(23, new SWItem(SWItem.getDye(1), "§7-0,0625", clickType -> { swInventory.setItem(23, new SWItem(SWItem.getDye(1), "§7-0,0625", Arrays.asList("§eShift §7Click für §e-1"), false, clickType -> {
position.subtract(X_VECTOR); position.subtract(clickType.isShiftClick() ? FX_VECTOR : X_VECTOR);
editTNT(); editTNT();
})); }));
// Y Position // Y Position
swInventory.setItem(6, new SWItem(SWItem.getDye(10), "§7+0,0625", clickType -> { swInventory.setItem(6, new SWItem(SWItem.getDye(10), "§7+0,0625", Arrays.asList("§eShift §7Click für §e+1"), false, clickType -> {
position.add(Y_VECTOR); position.add(clickType.isShiftClick() ? FY_VECTOR : Y_VECTOR);
editTNT(); editTNT();
})); }));
swInventory.setItem(15, new SWItem(Material.PAPER, "§7y-Position §8- §e" + position.getY(), LORE, false, clickType -> { swInventory.setItem(15, new SWItem(Material.PAPER, "§7y-Position §8- §e" + position.getY(), LORE, false, clickType -> {
@ -471,14 +504,14 @@ public class TNTSimulator {
editTNT(); editTNT();
}, this::editTNT); }, this::editTNT);
})); }));
swInventory.setItem(24, new SWItem(SWItem.getDye(1), "§7-0,0625", clickType -> { swInventory.setItem(24, new SWItem(SWItem.getDye(1), "§7-0,0625", Arrays.asList("§eShift §7Click für §e-1"), false, clickType -> {
position.subtract(Y_VECTOR); position.subtract(clickType.isShiftClick() ? FY_VECTOR : Y_VECTOR);
editTNT(); editTNT();
})); }));
// Z Position // Z Position
swInventory.setItem(7, new SWItem(SWItem.getDye(10), "§7+0,0625", clickType -> { swInventory.setItem(7, new SWItem(SWItem.getDye(10), "§7+0,0625", Arrays.asList("§eShift §7Click für §e+1"), false, clickType -> {
position.add(Z_VECTOR); position.add(clickType.isShiftClick() ? FZ_VECTOR : Z_VECTOR);
editTNT(); editTNT();
})); }));
swInventory.setItem(16, new SWItem(Material.PAPER, "§7z-Position §8- §e" + position.getZ(), LORE, false, clickType -> { swInventory.setItem(16, new SWItem(Material.PAPER, "§7z-Position §8- §e" + position.getZ(), LORE, false, clickType -> {
@ -487,8 +520,8 @@ public class TNTSimulator {
editTNT(); editTNT();
}, this::editTNT); }, this::editTNT);
})); }));
swInventory.setItem(25, new SWItem(SWItem.getDye(1), "§7-0,0625", clickType -> { swInventory.setItem(25, new SWItem(SWItem.getDye(1), "§7-0,0625", Arrays.asList("§eShift §7Click für §e-1"), false, clickType -> {
position.subtract(Z_VECTOR); position.subtract(clickType.isShiftClick() ? FZ_VECTOR : Z_VECTOR);
editTNT(); editTNT();
})); }));