SteamWar/BauSystem
Archiviert
13
0
Dieser Commit ist enthalten in:
jojo 2021-02-12 16:20:22 +01:00
Ursprung e6417bd578
Commit 3f39066209

Datei anzeigen

@ -32,11 +32,13 @@ import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Consumer;
import org.bukkit.util.Vector;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
public class TNTSimulator {
@ -195,15 +197,15 @@ public class TNTSimulator {
}));
// Velocity Settings
swInventory.setItem(13, new SWItem(tntSpawn.isxVelocity() ? Material.LIME_CONCRETE : Material.RED_CONCRETE, "§7TNT §eSprung X §8- §7" + active(tntSpawn.isxVelocity()), clickType -> {
swInventory.setItem(13, new SWItem(tntSpawn.isxVelocity() ? Material.LIME_CONCRETE : Material.RED_CONCRETE, "§7TNT §eSprung X §8- " + active(tntSpawn.isxVelocity()), clickType -> {
tntSpawn.setxVelocity(!tntSpawn.isxVelocity());
editTNT(player, tntSpawn);
}));
swInventory.setItem(22, new SWItem(tntSpawn.isyVelocity() ? Material.LIME_CONCRETE : Material.RED_CONCRETE, "§7TNT §eSprung Y §8- §7" + active(tntSpawn.isyVelocity()), clickType -> {
swInventory.setItem(22, new SWItem(tntSpawn.isyVelocity() ? Material.LIME_CONCRETE : Material.RED_CONCRETE, "§7TNT §eSprung Y §8- " + active(tntSpawn.isyVelocity()), clickType -> {
tntSpawn.setyVelocity(!tntSpawn.isyVelocity());
editTNT(player, tntSpawn);
}));
swInventory.setItem(31, new SWItem(tntSpawn.iszVelocity() ? Material.LIME_CONCRETE : Material.RED_CONCRETE, "§7TNT §eSprung Z §8- §7" + active(tntSpawn.iszVelocity()), clickType -> {
swInventory.setItem(31, new SWItem(tntSpawn.iszVelocity() ? Material.LIME_CONCRETE : Material.RED_CONCRETE, "§7TNT §eSprung Z §8- " + active(tntSpawn.iszVelocity()), clickType -> {
tntSpawn.setzVelocity(!tntSpawn.iszVelocity());
editTNT(player, tntSpawn);
}));
@ -316,12 +318,15 @@ public class TNTSimulator {
}
});
AtomicInteger currentTick = new AtomicInteger(0);
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> {
AtomicReference<Runnable> taskCanceler = new AtomicReference<>(() -> {});
BukkitTask bukkitTask = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> {
int tick = currentTick.get();
spawnRandomList(first.getOrDefault(tick, EMPTY));
spawnRandomList(second.getOrDefault(tick, EMPTY));
if (tick > lastTick.get()) taskCanceler.get().run();
currentTick.incrementAndGet();
}, 1, 1);
taskCanceler.set(bukkitTask::cancel);
}
private void spawnRandomList(List<TNTSpawn> tntSpawns) {