SteamWar/BauSystem
Archiviert
13
0
Dieser Commit ist enthalten in:
yoyosource 2021-03-05 20:13:15 +01:00
Ursprung ab8f0db420
Commit 549efa9801
4 geänderte Dateien mit 20 neuen und 26 gelöschten Zeilen

Datei anzeigen

@ -31,12 +31,4 @@ public class TNTSimulator_12 {
return Material.CONCRETE;
}
public static Material repeater() {
return Material.DIODE;
}
public static Material comparator() {
return Material.REDSTONE_COMPARATOR;
}
}

Datei anzeigen

@ -32,12 +32,4 @@ public class TNTSimulator_15 {
return Material.RED_CONCRETE;
}
public static Material repeater() {
return Material.REPEATER;
}
public static Material comparator() {
return Material.COMPARATOR;
}
}

Datei anzeigen

@ -33,9 +33,10 @@ import org.bukkit.entity.Player;
public class CommandSimulator implements CommandExecutor {
private void help(Player player) {
player.sendMessage("§8/§esimulator §8- §7Öffnet das Simulations GUI");
player.sendMessage("§8/§esimulator §8- §7Öffnet die Simulations GUI");
player.sendMessage("§8/§esimulator start §8- §7Startet die Simulation");
player.sendMessage("§8/§esimulator wand §8- §7Legt den Simulatorstab ins Inventar");
player.sendMessage("§8/§esimulator wand §8- §7Legt dir den Simulatorstab ins Inventar");
player.sendMessage("§8/§esimulator delete §8- §7Lösche alle TNT");
}
private boolean permissionCheck(Player player) {
@ -68,6 +69,8 @@ public class CommandSimulator implements CommandExecutor {
case "start":
TNTSimulator.get(player).start();
break;
case "delete":
TNTSimulator.get(player).delete();
default:
help(player);
break;

Datei anzeigen

@ -271,9 +271,9 @@ public class TNTSimulator {
private static Material comparatorOrNot(boolean b) {
if (b) {
return VersionedCallable.call(new VersionedCallable<>(TNTSimulator_12::comparator, 8), new VersionedCallable<>(TNTSimulator_15::comparator, 14));
return SWItem.getMaterial("REDSTONE_COMPARATOR");
} else {
return VersionedCallable.call(new VersionedCallable<>(TNTSimulator_12::repeater, 8), new VersionedCallable<>(TNTSimulator_15::repeater, 14));
return SWItem.getMaterial("DIODE");
}
}
@ -319,25 +319,32 @@ public class TNTSimulator {
return (int)(d * 10000) * 0.0001;
}
public void delete() {
TNT_SPAWNS.clear();
}
public void start() {
Map<Integer, List<TNTSpawn>> first = new HashMap<>();
Map<Integer, List<TNTSpawn>> second = new HashMap<>();
AtomicInteger lastTick = new AtomicInteger(0);
TNT_SPAWNS.forEach(tntSpawn -> {
int lastTick = 0;
for (TNTSpawn tntSpawn : TNT_SPAWNS) {
Map<Integer, List<TNTSpawn>> list = tntSpawn.isComparator() ? second : first;
for (int i = 0; i < tntSpawn.getCount(); i++) {
list.computeIfAbsent(tntSpawn.getTickOffset(), integer -> new ArrayList<>()).add(tntSpawn);
}
if (lastTick.get() < tntSpawn.getTickOffset()) {
lastTick.set(tntSpawn.getTickOffset());
if (lastTick < tntSpawn.getTickOffset()) {
lastTick = tntSpawn.getTickOffset();
}
});
}
int finalLastTick = lastTick;
AtomicInteger currentTick = new AtomicInteger(0);
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), bukkitTask -> {
int tick = currentTick.get();
spawnRandomList(first.getOrDefault(tick, EMPTY));
spawnRandomList(second.getOrDefault(tick, EMPTY));
if (tick > lastTick.get()) bukkitTask.cancel();
if (tick > finalLastTick) bukkitTask.cancel();
currentTick.incrementAndGet();
}, 1, 1);
}