SteamWar/BauSystem
Archiviert
13
0

Add CommandSimulator

Add TNTSimulator
Dieser Commit ist enthalten in:
yoyosource 2021-03-06 21:23:35 +01:00
Ursprung 549efa9801
Commit 9a1c900a71
2 geänderte Dateien mit 4 neuen und 25 gelöschten Zeilen

Datei anzeigen

@ -36,7 +36,7 @@ public class CommandSimulator implements CommandExecutor {
player.sendMessage("§8/§esimulator §8- §7Öffnet die 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 start §8- §7Startet die Simulation");
player.sendMessage("§8/§esimulator wand §8- §7Legt dir 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"); player.sendMessage("§8/§esimulator delete §8- §7Löscht alle TNT");
} }
private boolean permissionCheck(Player player) { private boolean permissionCheck(Player player) {

Datei anzeigen

@ -47,12 +47,11 @@ public class TNTSimulator {
private static final Vector NY_VECTOR = new Vector(0, -0.0625, 0); private static final Vector NY_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 NZ_VECTOR = new Vector(0, 0, -0.0625); private static final Vector NZ_VECTOR = new Vector(0, 0, -0.0625);
private static final List<String> LORE = Collections.singletonList("§7Zum ä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<>();
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();
@ -75,7 +74,7 @@ public class TNTSimulator {
lore.add("§7X§8: §e" + tntSpawn.getPosition().getX()); lore.add("§7X§8: §e" + tntSpawn.getPosition().getX());
lore.add("§7Y§8: §e" + tntSpawn.getPosition().getY()); lore.add("§7Y§8: §e" + tntSpawn.getPosition().getY());
lore.add("§7Z§8: §e" + tntSpawn.getPosition().getZ()); lore.add("§7Z§8: §e" + tntSpawn.getPosition().getZ());
swListEntryList.add(new SWListInv.SWListEntry<>(new SWItem(Material.TNT, "§eTNT" + (!tntSpawn.getName().isEmpty() ? " §8- §e" + tntSpawn.getName() : ""), lore, false, null), tntSpawn)); swListEntryList.add(new SWListInv.SWListEntry<>(new SWItem(Material.TNT, "§eTNT", lore, false, null), tntSpawn));
}); });
swListEntryList.sort(Comparator.comparing(SWListInv.SWListEntry::getObject)); swListEntryList.sort(Comparator.comparing(SWListInv.SWListEntry::getObject));
@ -96,7 +95,7 @@ public class TNTSimulator {
static void editTNT(Player player, TNTSpawn tntSpawn) { static void editTNT(Player player, TNTSpawn tntSpawn) {
TNTSimulator tntSimulator = get(player); TNTSimulator tntSimulator = get(player);
SWInventory swInventory = new SWInventory(player, 54, "TNT" + (!tntSpawn.getName().isEmpty() ? " - " + tntSpawn.getName() : "")); SWInventory swInventory = new SWInventory(player, 54, "TNT");
swInventory.setItem(49, new SWItem(Material.REDSTONE_BLOCK, "§cZurück", clickType -> { swInventory.setItem(49, new SWItem(Material.REDSTONE_BLOCK, "§cZurück", clickType -> {
openSimulator(player); openSimulator(player);
})); }));
@ -107,16 +106,6 @@ public class TNTSimulator {
openSimulator(player); openSimulator(player);
})); }));
// tnt Name
swInventory.setItem(45, new SWItem(Material.NAME_TAG, "§eName", clickType -> {
SWAnvilInv tntSimulatorAnvil = new SWAnvilInv(player, "Name", tntSpawn.getName());
tntSimulatorAnvil.setCallback(s -> {
tntSpawn.setName(s);
editTNT(player, tntSpawn);
});
tntSimulatorAnvil.open();
}));
// Change Count of spawned TNT // Change Count of spawned TNT
swInventory.setItem(10, new SWItem(SWItem.getDye(10), "§7+1", clickType -> { swInventory.setItem(10, new SWItem(SWItem.getDye(10), "§7+1", clickType -> {
tntSpawn.setCount(tntSpawn.getCount() + 1); tntSpawn.setCount(tntSpawn.getCount() + 1);
@ -265,7 +254,6 @@ public class TNTSimulator {
static void addTNT(Player player, TNTSpawn tntSpawn) { static void addTNT(Player player, TNTSpawn tntSpawn) {
TNTSimulator tntSimulator = TNT_SIMULATOR_MAP.computeIfAbsent(player, player1 -> new TNTSimulator()); TNTSimulator tntSimulator = TNT_SIMULATOR_MAP.computeIfAbsent(player, player1 -> new TNTSimulator());
if (tntSpawn.name.isEmpty()) tntSpawn.name = (++tntSimulator.number) + "";
tntSimulator.TNT_SPAWNS.add(tntSpawn); tntSimulator.TNT_SPAWNS.add(tntSpawn);
} }
@ -361,7 +349,6 @@ public class TNTSimulator {
private static final World WORLD = Bukkit.getWorlds().get(0); private static final World WORLD = Bukkit.getWorlds().get(0);
private String name = "";
private final Vector position; private final Vector position;
private int fuseTicks = 80; private int fuseTicks = 80;
private int count = 1; private int count = 1;
@ -384,14 +371,6 @@ public class TNTSimulator {
}); });
} }
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Vector getPosition() { public Vector getPosition() {
return position; return position;
} }