SteamWar/BauSystem
Archiviert
13
0
Dieser Commit ist enthalten in:
jojo 2021-01-20 18:55:13 +01:00
Ursprung b5f0dde9d1
Commit 870fc285e7
6 geänderte Dateien mit 44 neuen und 30 gelöschten Zeilen

Datei anzeigen

@ -19,7 +19,7 @@
package de.steamwar.bausystem; package de.steamwar.bausystem;
import de.steamwar.bausystem.canonsimulator.TNTSimulatorListener; import de.steamwar.bausystem.cannonsimulator.TNTSimulatorListener;
import de.steamwar.bausystem.commands.*; import de.steamwar.bausystem.commands.*;
import de.steamwar.bausystem.world.*; import de.steamwar.bausystem.world.*;
import de.steamwar.core.CommandRemover; import de.steamwar.core.CommandRemover;

Datei anzeigen

@ -19,7 +19,7 @@
* / * /
*/ */
package de.steamwar.bausystem.canonsimulator; package de.steamwar.bausystem.cannonsimulator;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWInventory;
@ -42,17 +42,18 @@ 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("§7Klicken zum ändern"); private static final List<String> LORE = Collections.singletonList("§7Zum ändern klicken");
static Map<Player, TNTSimulator> tntSimulatorMap = new HashMap<>(); static Map<Player, TNTSimulator> tntSimulatorMap = new HashMap<>();
public static final ItemStack WAND = new SWItem(Material.TRIPWIRE_HOOK, "§6Kanonen Simulator", Arrays.asList("§eRechts Klick Block §8- §7Füge einen TNT hinzu", "§eRechts Klick Luft §8- §7Öffne den Simulator", "§eLinks Klick §8- §7Starte die Simulation"), false, null).getItemStack(); public static final ItemStack WAND = new SWItem(Material.TRIPWIRE_HOOK, "§eKanonen Simulator", 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 TNTSimulator get(Player player) {
return tntSimulatorMap.computeIfAbsent(player, p -> new TNTSimulator());
}
public static void openSimulator(Player player) { public static void openSimulator(Player player) {
if (!tntSimulatorMap.containsKey(player)) { TNTSimulator tntSimulator = get(player);
tntSimulatorMap.put(player, new TNTSimulator());
}
TNTSimulator tntSimulator = tntSimulatorMap.get(player);
List<SWListInv.SWListEntry<TNTSpawn>> swListEntryList = new ArrayList<>(); List<SWListInv.SWListEntry<TNTSpawn>> swListEntryList = new ArrayList<>();
tntSimulator.tntSpawns.forEach(tntSpawn -> { tntSimulator.tntSpawns.forEach(tntSpawn -> {
@ -66,11 +67,11 @@ public class TNTSimulator {
lore.add("§eX§8: §7" + tntSpawn.getPosition().getX()); lore.add("§eX§8: §7" + tntSpawn.getPosition().getX());
lore.add("§eY§8: §7" + tntSpawn.getPosition().getY()); lore.add("§eY§8: §7" + tntSpawn.getPosition().getY());
lore.add("§eZ§8: §7" + tntSpawn.getPosition().getZ()); lore.add("§eZ§8: §7" + tntSpawn.getPosition().getZ());
swListEntryList.add(new SWListInv.SWListEntry<>(new SWItem(Material.TNT, "§6TNT", 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));
SWListInv<TNTSpawn> swListInv = new SWListInv<>(player, "Kanonen Simulator", false, swListEntryList, (clickType, tntSpawn) -> { SWListInv<TNTSpawn> swListInv = new SWListInv<>(player, "Kanonensimulator", false, swListEntryList, (clickType, tntSpawn) -> {
editTNT(player, tntSpawn); editTNT(player, tntSpawn);
}); });
swListInv.setItem(51, new SWItem(Material.BARRIER, "§cLösche alle TNT", clickType -> { swListInv.setItem(51, new SWItem(Material.BARRIER, "§cLösche alle TNT", clickType -> {
@ -91,7 +92,7 @@ public class TNTSimulator {
tntSimulator.tntSpawns.add(tntSpawn); tntSimulator.tntSpawns.add(tntSpawn);
editTNT(player, tntSpawn); editTNT(player, tntSpawn);
})); }));
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); startSimulation(player);
player.closeInventory(); player.closeInventory();
})); }));
@ -99,18 +100,15 @@ public class TNTSimulator {
} }
static void editTNT(Player player, TNTSpawn tntSpawn) { static void editTNT(Player player, TNTSpawn tntSpawn) {
if (!tntSimulatorMap.containsKey(player)) { TNTSimulator tntSimulator = get(player);
tntSimulatorMap.put(player, new TNTSimulator());
}
TNTSimulator tntSimulator = tntSimulatorMap.get(player);
SWInventory swInventory = new SWInventory(player, 54, "TNT"); 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);
})); }));
// Delete icon // Delete tnt
swInventory.setItem(53, new SWItem(Material.BARRIER, "§cDelete", clickType -> { swInventory.setItem(53, new SWItem(Material.BARRIER, "§cEntfernen", clickType -> {
tntSimulator.tntSpawns.remove(tntSpawn); tntSimulator.tntSpawns.remove(tntSpawn);
openSimulator(player); openSimulator(player);
})); }));
@ -118,15 +116,15 @@ public class TNTSimulator {
// Change Count of spawned TNT // Change Count of spawned TNT
swInventory.setItem(10, new SWItem(SWItem.getDye(10), "§a+1", clickType -> { swInventory.setItem(10, new SWItem(SWItem.getDye(10), "§a+1", clickType -> {
tntSpawn.setCount(tntSpawn.getCount() + 1); tntSpawn.setCount(tntSpawn.getCount() + 1);
if (tntSpawn.getCount() > 1000) { if (tntSpawn.getCount() > 400) {
tntSpawn.setCount(1000); tntSpawn.setCount(400);
} }
editTNT(player, tntSpawn); editTNT(player, tntSpawn);
})); }));
swInventory.setItem(19, new SWItem(Material.TNT, "§eAnzahl §8- §7" + tntSpawn.getCount(), LORE, false, clickType -> { swInventory.setItem(19, new SWItem(Material.TNT, "§eAnzahl §8- §7" + tntSpawn.getCount(), LORE, false, clickType -> {
changeCount(player, tntSpawn.getCount(), count -> { changeCount(player, tntSpawn.getCount(), count -> {
if (count < 1) count = 1; if (count < 1) count = 1;
if (count > 1000) count = 1000; if (count > 400) count = 400;
tntSpawn.setCount(count); tntSpawn.setCount(count);
editTNT(player, tntSpawn); editTNT(player, tntSpawn);
}, () -> editTNT(player, tntSpawn)); }, () -> editTNT(player, tntSpawn));
@ -188,15 +186,15 @@ public class TNTSimulator {
})); }));
// Velocity Settings // Velocity Settings
swInventory.setItem(13, new SWItem(tntSpawn.isxVelocity() ? Material.LIME_WOOL : Material.RED_WOOL, "§7Start §eVelocity X §8- §7" + active(tntSpawn.isxVelocity()), clickType -> { swInventory.setItem(13, new SWItem(tntSpawn.isxVelocity() ? Material.LIME_CONCRETE : Material.RED_CONCRETE, "§7Start §eVelocity X §8- §7" + active(tntSpawn.isxVelocity()), clickType -> {
tntSpawn.setxVelocity(!tntSpawn.isxVelocity()); tntSpawn.setxVelocity(!tntSpawn.isxVelocity());
editTNT(player, tntSpawn); editTNT(player, tntSpawn);
})); }));
swInventory.setItem(22, new SWItem(tntSpawn.isyVelocity() ? Material.LIME_WOOL : Material.RED_WOOL, "§7Start §eVelocity Y §8- §7" + active(tntSpawn.isyVelocity()), clickType -> { swInventory.setItem(22, new SWItem(tntSpawn.isyVelocity() ? Material.LIME_CONCRETE : Material.RED_CONCRETE, "§7Start §eVelocity Y §8- §7" + active(tntSpawn.isyVelocity()), clickType -> {
tntSpawn.setyVelocity(!tntSpawn.isyVelocity()); tntSpawn.setyVelocity(!tntSpawn.isyVelocity());
editTNT(player, tntSpawn); editTNT(player, tntSpawn);
})); }));
swInventory.setItem(31, new SWItem(tntSpawn.iszVelocity() ? Material.LIME_WOOL : Material.RED_WOOL, "§7Start §eVelocity Z §8- §7" + active(tntSpawn.iszVelocity()), clickType -> { swInventory.setItem(31, new SWItem(tntSpawn.iszVelocity() ? Material.LIME_CONCRETE : Material.RED_CONCRETE, "§7Start §eVelocity Z §8- §7" + active(tntSpawn.iszVelocity()), clickType -> {
tntSpawn.setzVelocity(!tntSpawn.iszVelocity()); tntSpawn.setzVelocity(!tntSpawn.iszVelocity());
editTNT(player, tntSpawn); editTNT(player, tntSpawn);
})); }));
@ -206,7 +204,7 @@ public class TNTSimulator {
tntSpawn.getPosition().add(X_VECTOR); tntSpawn.getPosition().add(X_VECTOR);
editTNT(player, tntSpawn); editTNT(player, tntSpawn);
})); }));
swInventory.setItem(23, new SWItem(Material.PAPER, "§ePosition-X §8- §7" + tntSpawn.getPosition().getX(), LORE, false, clickType -> { swInventory.setItem(23, new SWItem(Material.PAPER, "§ex-Position §8- §7" + tntSpawn.getPosition().getX(), LORE, false, clickType -> {
changePosition(player, tntSpawn.getPosition().getX(), x -> { changePosition(player, tntSpawn.getPosition().getX(), x -> {
tntSpawn.getPosition().setX(clamp(x)); tntSpawn.getPosition().setX(clamp(x));
editTNT(player, tntSpawn); editTNT(player, tntSpawn);
@ -222,7 +220,7 @@ public class TNTSimulator {
tntSpawn.getPosition().add(Y_VECTOR); tntSpawn.getPosition().add(Y_VECTOR);
editTNT(player, tntSpawn); editTNT(player, tntSpawn);
})); }));
swInventory.setItem(24, new SWItem(Material.PAPER, "§ePosition-Y §8- §7" + tntSpawn.getPosition().getY(), LORE, false, clickType -> { swInventory.setItem(24, new SWItem(Material.PAPER, "§ey-Position §8- §7" + tntSpawn.getPosition().getY(), LORE, false, clickType -> {
changePosition(player, tntSpawn.getPosition().getY(), y -> { changePosition(player, tntSpawn.getPosition().getY(), y -> {
tntSpawn.getPosition().setY(clamp(y)); tntSpawn.getPosition().setY(clamp(y));
editTNT(player, tntSpawn); editTNT(player, tntSpawn);
@ -238,7 +236,7 @@ public class TNTSimulator {
tntSpawn.getPosition().add(Z_VECTOR); tntSpawn.getPosition().add(Z_VECTOR);
editTNT(player, tntSpawn); editTNT(player, tntSpawn);
})); }));
swInventory.setItem(25, new SWItem(Material.PAPER, "§ePosition-Z §8- §7" + tntSpawn.getPosition().getZ(), LORE, false, clickType -> { swInventory.setItem(25, new SWItem(Material.PAPER, "§ez-Position §8- §7" + tntSpawn.getPosition().getZ(), LORE, false, clickType -> {
changePosition(player, tntSpawn.getPosition().getZ(), z -> { changePosition(player, tntSpawn.getPosition().getZ(), z -> {
tntSpawn.getPosition().setZ(clamp(z)); tntSpawn.getPosition().setZ(clamp(z));
editTNT(player, tntSpawn); editTNT(player, tntSpawn);

Datei anzeigen

@ -19,7 +19,7 @@
* / * /
*/ */
package de.steamwar.bausystem.canonsimulator; package de.steamwar.bausystem.cannonsimulator;
import de.steamwar.core.Core; import de.steamwar.core.Core;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;

Datei anzeigen

@ -19,8 +19,12 @@
* / * /
*/ */
package de.steamwar.bausystem.canonsimulator; package de.steamwar.bausystem.cannonsimulator;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.Welt;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
@ -32,11 +36,23 @@ public class TNTSimulatorListener implements Listener {
private static final Vector HALF = new Vector(0.5, 0, 0.5); private static final Vector HALF = new Vector(0.5, 0, 0.5);
private boolean permissionCheck(Player player) {
if (Welt.noPermission(player, Permission.build)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Simulator nutzen");
return false;
}
return true;
}
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getItem() == null) return; if (event.getItem() == null) return;
if (!event.getItem().isSimilar(TNTSimulator.WAND)) return; if (!event.getItem().isSimilar(TNTSimulator.WAND)) return;
event.setCancelled(true); event.setCancelled(true);
if (permissionCheck(event.getPlayer())) {
return;
}
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR) { if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR) {
TNTSimulator.startSimulation(event.getPlayer()); TNTSimulator.startSimulation(event.getPlayer());
return; return;

Datei anzeigen

@ -19,7 +19,7 @@
* / * /
*/ */
package de.steamwar.bausystem.canonsimulator; package de.steamwar.bausystem.cannonsimulator;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;

Datei anzeigen

@ -23,7 +23,7 @@ package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.canonsimulator.TNTSimulator; import de.steamwar.bausystem.cannonsimulator.TNTSimulator;
import de.steamwar.bausystem.world.Welt; import de.steamwar.bausystem.world.Welt;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;