SteamWar/BauSystem
Archiviert
13
0

Fix TNTSet error

Add TNTSpawn.fuseTicks
Dieser Commit ist enthalten in:
jojo 2021-01-20 16:10:07 +01:00
Ursprung a23608b171
Commit 7a8c3f20f1
2 geänderte Dateien mit 52 neuen und 25 gelöschten Zeilen

Datei anzeigen

@ -56,12 +56,15 @@ public class TNTSimulator {
List<String> lore = new ArrayList<>();
lore.add("§eTNT-Anzahl§8: §7" + tntSpawn.getCount());
lore.add("§eTick§8: §7" + tntSpawn.getTickOffset());
lore.add("§eFuse-Tick§8: §7" + tntSpawn.getFuseTicks());
lore.add("");
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, "§eTNT", lore, false, null), tntSpawn));
});
swListEntryList.sort(Comparator.comparing(SWListInv.SWListEntry::getObject));
SWListInv<TNTSpawn> swListInv = new SWListInv<>(player, "Kanonen Simulator", false, swListEntryList, (clickType, tntSpawn) -> {
editTNT(player, tntSpawn);
});
@ -91,19 +94,29 @@ public class TNTSimulator {
}
private static void editTNT(Player player, TNTSpawn tntSpawn) {
SWInventory swInventory = new SWInventory(player, 45, "TNT");
swInventory.setItem(44, new SWItem(Material.REDSTONE_BLOCK, "§cZurück", clickType -> {
SWInventory swInventory = new SWInventory(player, 54, "TNT");
swInventory.setItem(48, new SWItem(Material.REDSTONE_BLOCK, "§cZurück", clickType -> {
openSimulator(player);
}));
// Delete icon
swInventory.setItem(50, new SWItem(Material.BARRIER, "§cDelete", clickType -> {
tntSimulatorMap.get(player).tntSpawns.remove(tntSpawn);
openSimulator(player);
}));
// 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);
}
editTNT(player, tntSpawn);
}));
swInventory.setItem(19, new SWItem(Material.TNT, "§eAnzahl §8- §7" + tntSpawn.getCount(), clickType -> {
changeCount(player, count -> {
if (count < 1) count = 1;
if (count > 1000) count = 1000;
tntSpawn.setCount(count);
editTNT(player, tntSpawn);
}, () -> editTNT(player, tntSpawn));
@ -119,11 +132,15 @@ public class TNTSimulator {
// Change TickOffset
swInventory.setItem(11, new SWItem(SWItem.getDye(10), "§a+1", clickType -> {
tntSpawn.setTickOffset(tntSpawn.getTickOffset() + 1);
if (tntSpawn.getTickOffset() > 8000) {
tntSpawn.setTickOffset(8000);
}
editTNT(player, tntSpawn);
}));
swInventory.setItem(20, new SWItem(Material.CLOCK, "§eTick §8- §7" + tntSpawn.getTickOffset(), clickType -> {
changeCount(player, tick -> {
if (tick < 0) tick = 0;
if (tick > 8000) tick = 8000;
tntSpawn.setTickOffset(tick);
editTNT(player, tntSpawn);
}, () -> editTNT(player, tntSpawn));
@ -136,10 +153,28 @@ public class TNTSimulator {
editTNT(player, tntSpawn);
}));
// Delete icon
swInventory.setItem(21, new SWItem(Material.BARRIER, "§cDelete", clickType -> {
tntSimulatorMap.get(player).tntSpawns.remove(tntSpawn);
openSimulator(player);
// Change FuseTicks
swInventory.setItem(12, new SWItem(SWItem.getDye(10), "§a+1", clickType -> {
tntSpawn.setFuseTicks(tntSpawn.getFuseTicks() + 1);
if (tntSpawn.getFuseTicks() > 80) {
tntSpawn.setFuseTicks(80);
}
editTNT(player, tntSpawn);
}));
swInventory.setItem(21, new SWItem(Material.CLOCK, "§eFuseTicks §8- §7" + tntSpawn.getFuseTicks(), clickType -> {
changeCount(player, tick -> {
if (tick < 0) tick = 0;
if (tick > 80) tick = 80;
tntSpawn.setFuseTicks(tick);
editTNT(player, tntSpawn);
}, () -> editTNT(player, tntSpawn));
}));
swInventory.setItem(30, new SWItem(SWItem.getDye(1), "§c-1", clickType -> {
tntSpawn.setFuseTicks(tntSpawn.getFuseTicks() - 1);
if (tntSpawn.getFuseTicks() < 1) {
tntSpawn.setFuseTicks(1);
}
editTNT(player, tntSpawn);
}));
// Velocity Settings
@ -240,7 +275,7 @@ public class TNTSimulator {
return (int)(d * 100) * 0.01;
}
private Set<TNTSpawn> tntSpawns = new TreeSet<>();
private Set<TNTSpawn> tntSpawns = new HashSet<>();
public void start() {
tntSpawns.forEach(tntSpawn -> {

Datei anzeigen

@ -33,6 +33,7 @@ public class TNTSpawn implements Comparable<TNTSpawn> {
private static final World WORLD = Bukkit.getWorlds().get(0);
private Vector position;
private int fuseTicks = 80;
private int count = 1;
private int tickOffset = 0;
private boolean xVelocity = true;
@ -46,6 +47,7 @@ public class TNTSpawn implements Comparable<TNTSpawn> {
public void spawn() {
for (int i = 0; i < count; i++) {
WORLD.spawn(position.toLocation(WORLD), TNTPrimed.class, tntPrimed -> {
tntPrimed.setFuseTicks(fuseTicks);
if (!xVelocity) tntPrimed.setVelocity(tntPrimed.getVelocity().setX(0));
if (!yVelocity) tntPrimed.setVelocity(tntPrimed.getVelocity().setY(0));
if (!zVelocity) tntPrimed.setVelocity(tntPrimed.getVelocity().setZ(0));
@ -61,6 +63,14 @@ public class TNTSpawn implements Comparable<TNTSpawn> {
this.position = position;
}
public int getFuseTicks() {
return fuseTicks;
}
public void setFuseTicks(int fuseTicks) {
this.fuseTicks = fuseTicks;
}
public int getCount() {
return count;
}
@ -101,24 +111,6 @@ public class TNTSpawn implements Comparable<TNTSpawn> {
this.zVelocity = zVelocity;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof TNTSpawn)) return false;
TNTSpawn tntSpawn = (TNTSpawn) o;
return count == tntSpawn.count &&
tickOffset == tntSpawn.tickOffset &&
xVelocity == tntSpawn.xVelocity &&
yVelocity == tntSpawn.yVelocity &&
zVelocity == tntSpawn.zVelocity &&
position.equals(tntSpawn.position);
}
@Override
public int hashCode() {
return Objects.hash(position, count, tickOffset, xVelocity, yVelocity, zVelocity);
}
@Override
public int compareTo(TNTSpawn tntSpawn) {
return -Integer.compare(tickOffset, tntSpawn.tickOffset);