SteamWar/BauSystem
Archiviert
13
0
Dieser Commit ist enthalten in:
jojo 2021-02-08 20:48:45 +01:00
Ursprung bcb964fdb4
Commit de28cc9c1d
2 geänderte Dateien mit 11 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -50,6 +50,7 @@ public class TNTSimulator {
static final Map<Player, TNTSimulator> TNT_SIMULATOR_MAP = new HashMap<>(); static final Map<Player, TNTSimulator> TNT_SIMULATOR_MAP = new HashMap<>();
private final Set<TNTSpawn> TNT_SPAWNS = new HashSet<>(); private final Set<TNTSpawn> TNT_SPAWNS = new HashSet<>();
private int number = 0;
public static final ItemStack WAND = new SWItem(Material.BLAZE_ROD, "§eKanonensimulator", 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 final ItemStack WAND = new SWItem(Material.BLAZE_ROD, "§eKanonensimulator", 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();
@ -84,8 +85,8 @@ public class TNTSimulator {
openSimulator(player); openSimulator(player);
})); }));
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(); player.closeInventory();
startSimulation(player);
})); }));
swListInv.open(); swListInv.open();
} }
@ -108,7 +109,6 @@ public class TNTSimulator {
swInventory.setItem(45, new SWItem(Material.NAME_TAG, "§eName", clickType -> { swInventory.setItem(45, new SWItem(Material.NAME_TAG, "§eName", clickType -> {
SWAnvilInv tntSimulatorAnvil = new SWAnvilInv(player, "Name", tntSpawn.getName()); SWAnvilInv tntSimulatorAnvil = new SWAnvilInv(player, "Name", tntSpawn.getName());
tntSimulatorAnvil.setCallback(s -> { tntSimulatorAnvil.setCallback(s -> {
if (s.startsWith("»")) s = s.substring(1);
tntSpawn.setName(s); tntSpawn.setName(s);
editTNT(player, tntSpawn); editTNT(player, tntSpawn);
}); });
@ -262,7 +262,9 @@ public class TNTSimulator {
} }
static void addTNT(Player player, TNTSpawn tntSpawn) { static void addTNT(Player player, TNTSpawn tntSpawn) {
TNT_SIMULATOR_MAP.computeIfAbsent(player, player1 -> new TNTSimulator()).TNT_SPAWNS.add(tntSpawn); TNTSimulator tntSimulator = TNT_SIMULATOR_MAP.computeIfAbsent(player, player1 -> new TNTSimulator());
if (tntSpawn.name.isEmpty()) tntSpawn.name = (++tntSimulator.number) + "";
tntSimulator.TNT_SPAWNS.add(tntSpawn);
} }
private static String active(boolean b) { private static String active(boolean b) {

Datei anzeigen

@ -47,8 +47,12 @@ public class TNTSimulatorListener implements Listener {
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getItem() == null) return; if (event.getItem() == null) {
if (!event.getItem().isSimilar(WAND)) return; return;
}
if (!event.getItem().isSimilar(WAND)) {
return;
}
event.setCancelled(true); event.setCancelled(true);
if (!permissionCheck(event.getPlayer())) { if (!permissionCheck(event.getPlayer())) {
return; return;