From db3e3a7cbc8288bdd4a1c7b13c6f8bc27869d722 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Sat, 3 Apr 2021 22:16:19 +0200 Subject: [PATCH] converted enums to upper case added CommandSelect --- .../src/de/steamwar/bausystem/Permission.java | 8 +- .../bausystem/commands/CommandClear.java | 2 +- .../bausystem/commands/CommandDebugStick.java | 2 +- .../bausystem/commands/CommandDetonator.java | 2 +- .../bausystem/commands/CommandFire.java | 2 +- .../bausystem/commands/CommandFreeze.java | 2 +- .../bausystem/commands/CommandGUI.java | 70 +++++------ .../bausystem/commands/CommandLoader.java | 2 +- .../commands/CommandRedstoneTester.java | 2 +- .../bausystem/commands/CommandReset.java | 2 +- .../bausystem/commands/CommandSelect.java | 110 ++++++++++++++++++ .../bausystem/commands/CommandSimulator.java | 2 +- .../bausystem/commands/CommandTNT.java | 2 +- .../bausystem/commands/CommandTPSLimiter.java | 2 +- .../bausystem/commands/CommandTime.java | 4 +- .../bausystem/commands/CommandTrace.java | 2 +- .../bausystem/world/DetonatorListener.java | 2 +- .../bausystem/world/RedstoneListener.java | 2 +- .../bausystem/world/RegionListener.java | 6 +- .../bausystem/world/TNTSimulatorListener.java | 2 +- .../src/de/steamwar/bausystem/world/Welt.java | 6 +- 21 files changed, 172 insertions(+), 62 deletions(-) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java index c776150..3bacfea 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java @@ -20,8 +20,8 @@ package de.steamwar.bausystem; public enum Permission { - world, - worldedit, - build, - member + WORLD, + WORLDEDIT, + BUILD, + MEMBER } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java index 81225a8..d1c60e4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java @@ -54,7 +54,7 @@ public class CommandClear extends SWCommand { } private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.world)) { + if (Welt.noPermission(player, Permission.WORLD)) { player.sendMessage(BauSystem.PREFIX + "$cDu darfst hier keine fremden Inventare leeren."); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java index 604122f..c6da6b5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java @@ -39,7 +39,7 @@ public class CommandDebugStick extends SWCommand { @Register public void genericCommand(Player p) { - if (Welt.noPermission(p, Permission.build)) { + if (Welt.noPermission(p, Permission.BUILD)) { p.sendMessage(BauSystem.PREFIX + "§cKein Debugstick für dich hier."); } else { VersionedRunnable.call(new VersionedRunnable(() -> p.sendMessage(BauSystem.PREFIX + "§cDen Debugstick gibt es nicht in der 1.12."), 8), diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java index 226e498..28b91c0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java @@ -105,7 +105,7 @@ public class CommandDetonator extends SWCommand { } private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.world)) { + if (Welt.noPermission(player, Permission.WORLD)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Detonator nutzen"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFire.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFire.java index 8295088..56b4862 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFire.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFire.java @@ -72,7 +72,7 @@ public class CommandFire extends SWCommand implements Listener { } private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.world)) { + if (Welt.noPermission(player, Permission.WORLD)) { player.sendMessage(BauSystem.PREFIX + getNoPermMessage()); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java index 2531ccd..a3460ed 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java @@ -77,7 +77,7 @@ public class CommandFreeze extends SWCommand implements Listener { } private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.world)) { + if (Welt.noPermission(player, Permission.WORLD)) { player.sendMessage(BauSystem.PREFIX + getNoPermMessage()); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java index 69a51fc..f73270a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java @@ -97,45 +97,45 @@ public class CommandGUI extends SWCommand implements Listener { player.performCommand("gui item"); }); - ItemStack dtWand = wand(player, Detonator.WAND, "§8/§7dt wand", Permission.world, "§cDu hast keine Worldrechte"); + ItemStack dtWand = wand(player, Detonator.WAND, "§8/§7dt wand", Permission.WORLD, "§cDu hast keine Worldrechte"); inv.setItem(39, dtWand, clickType -> { - if (Welt.noPermission(player, Permission.world)) + if (Welt.noPermission(player, Permission.WORLD)) return; player.closeInventory(); player.performCommand("dt wand"); }); - ItemStack simWand = wand(player, TNTSimulator.WAND, "§8/§7sim wand", Permission.world, "§cDu hast keine Worldrechte"); + ItemStack simWand = wand(player, TNTSimulator.WAND, "§8/§7sim wand", Permission.WORLD, "§cDu hast keine Worldrechte"); inv.setItem(38, simWand, clickType -> { - if (Welt.noPermission(player, Permission.world)) + if (Welt.noPermission(player, Permission.WORLD)) return; player.closeInventory(); player.performCommand("sim wand"); }); - ItemStack redstoneWand = wand(player, RedstoneListener.WAND, "§8/§7redstonetester", Permission.build, "Du hast keine Buildrechte"); + ItemStack redstoneWand = wand(player, RedstoneListener.WAND, "§8/§7redstonetester", Permission.BUILD, "Du hast keine Buildrechte"); inv.setItem(37, redstoneWand, clickType -> { - if (Welt.noPermission(player, Permission.build)) + if (Welt.noPermission(player, Permission.BUILD)) return; player.closeInventory(); player.performCommand("redstonetester"); }); inv.setItem(40, getMaterial("WOODEN_AXE", "WOOD_AXE"), "§eWorldedit Axt", getNoPermsLore(Arrays.asList("§8//§7wand"), player, "§cDu hast keine Worldeditrechte", Permission.worldedit), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + if (Welt.noPermission(player, Permission.WORLD)) return; player.closeInventory(); player.performCommand("/wand"); }); - inv.setItem(41, getMaterial("DEBUG_STICK", "STICK"), "§eDebugstick", getNoPermsLore(Arrays.asList("§8/§7debugstick"), player, "§cDu hast keine Worldrechte", Permission.world), Core.getVersion() < 13, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(41, getMaterial("DEBUG_STICK", "STICK"), "§eDebugstick", getNoPermsLore(Arrays.asList("§8/§7debugstick"), player, "§cDu hast keine Worldrechte", Permission.WORLD), Core.getVersion() < 13, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.closeInventory(); player.performCommand("debugstick"); }); - inv.setItem(20, Material.COMPASS, "§7TPS Limitieren", getNoPermsLore(Arrays.asList("§7Aktuell: §e" + CommandTPSLimiter.getCurrentTPSLimit(), "§8/§7tpslimit §8[§e0,5 - " + (TPSUtils.isWarpAllowed() ? 40 : 20) + "§8]"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(20, Material.COMPASS, "§7TPS Limitieren", getNoPermsLore(Arrays.asList("§7Aktuell: §e" + CommandTPSLimiter.getCurrentTPSLimit(), "§8/§7tpslimit §8[§e0,5 - " + (TPSUtils.isWarpAllowed() ? 40 : 20) + "§8]"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; SWAnvilInv anvilInv = new SWAnvilInv(player, "TPS Limitieren"); anvilInv.setItem(Material.COMPASS); @@ -170,16 +170,16 @@ public class CommandGUI extends SWCommand implements Listener { scriptBooksGUI(player); }); - inv.setItem(21, Material.OBSERVER, "§7Tracer", getNoPermsLore(Arrays.asList("§7Status: §e" + RecordStateMachine.getRecordStatus().getName()), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(21, Material.OBSERVER, "§7Tracer", getNoPermsLore(Arrays.asList("§7Status: §e" + RecordStateMachine.getRecordStatus().getName()), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.closeInventory(); OPEN_TRACER_INVS.add(player); traceGUI(player); }); - inv.setItem(22, Material.DISPENSER, "§7Auto-Loader", getNoPermsLore(Arrays.asList("§7Status: " + (AutoLoader.hasLoader(player) ? "§aan" : "§caus")), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(22, Material.DISPENSER, "§7Auto-Loader", getNoPermsLore(Arrays.asList("§7Status: " + (AutoLoader.hasLoader(player) ? "§aan" : "§caus")), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.closeInventory(); autoLoaderGUI(player); @@ -200,15 +200,15 @@ public class CommandGUI extends SWCommand implements Listener { inv.setItem(27, Material.BARRIER, "§eKeine Region", clickType -> { }); } else { - inv.setItem(27, getMaterial("HEAVY_WEIGHTED_PRESSURE_PLATE", "IRON_PLATE"), "§eRegion Reseten", getNoPermsLore(Arrays.asList("§8/§7reset"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(27, getMaterial("HEAVY_WEIGHTED_PRESSURE_PLATE", "IRON_PLATE"), "§eRegion Reseten", getNoPermsLore(Arrays.asList("§8/§7reset"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; confirmationInventory(player, "Region Reseten?", () -> player.performCommand("reset"), () -> openBauGui(player)); }); if (region.hasProtection()) { - inv.setItem(18, Material.OBSIDIAN, "§eRegion Protecten", getNoPermsLore(Arrays.asList("§8/§7protect"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(18, Material.OBSIDIAN, "§eRegion Protecten", getNoPermsLore(Arrays.asList("§8/§7protect"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; confirmationInventory(player, "Region Protecten", () -> player.performCommand("protect"), () -> openBauGui(player)); }); @@ -218,8 +218,8 @@ public class CommandGUI extends SWCommand implements Listener { } if (region.hasTestblock()) { - inv.setItem(9, getMaterial("END_STONE", "ENDER_STONE"), "§eTestblock erneuern", getNoPermsLore(Arrays.asList("§8/§7testblock"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(9, getMaterial("END_STONE", "ENDER_STONE"), "§eTestblock erneuern", getNoPermsLore(Arrays.asList("§8/§7testblock"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; confirmationInventory(player, "Testblock erneuern", () -> player.performCommand("testblock"), () -> openBauGui(player)); }); @@ -254,11 +254,11 @@ public class CommandGUI extends SWCommand implements Listener { } boolean isBuildArea = region.hasBuildRegion(); - List tntLore = getNoPermsLore(Arrays.asList("§8/§7tnt §8[" + (isBuildArea ? "§eTB§7, " : "") + "§eOff §7oder §eOn§7]"), player, "§cDu hast keine Worldrechte", Permission.world); + List tntLore = getNoPermsLore(Arrays.asList("§8/§7tnt §8[" + (isBuildArea ? "§eTB§7, " : "") + "§eOff §7oder §eOn§7]"), player, "§cDu hast keine Worldrechte", Permission.WORLD); switch (region.getTntMode()) { case OFF: inv.setItem(23, Material.MINECART, "§7TNT: §eAusgeschaltet", tntLore, false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + if (Welt.noPermission(player, Permission.WORLD)) return; player.performCommand("tnt " + (isBuildArea ? "tb" : "on")); updateInventories(); @@ -266,7 +266,7 @@ public class CommandGUI extends SWCommand implements Listener { break; case ONLY_TB: inv.setItem(23, getMaterial("TNT_MINECART", "EXPLOSIVE_MINECART"), "§7TNT: §enur Testblock", tntLore, false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + if (Welt.noPermission(player, Permission.WORLD)) return; player.performCommand("tnt on"); updateInventories(); @@ -274,7 +274,7 @@ public class CommandGUI extends SWCommand implements Listener { break; default: inv.setItem(23, Material.TNT, "§7TNT: §eEingeschaltet", tntLore, false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + if (Welt.noPermission(player, Permission.WORLD)) return; player.performCommand("tnt off"); updateInventories(); @@ -282,15 +282,15 @@ public class CommandGUI extends SWCommand implements Listener { } if (region.isFreeze()) { - inv.setItem(24, getMaterial("GUNPOWDER", "SULPHUR"), "§7Freeze: §eEingeschaltet", getNoPermsLore(Arrays.asList("§8/§7freeze"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(24, getMaterial("GUNPOWDER", "SULPHUR"), "§7Freeze: §eEingeschaltet", getNoPermsLore(Arrays.asList("§8/§7freeze"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.performCommand("freeze"); updateInventories(); }); } else { - inv.setItem(24, Material.REDSTONE, "§7Freeze: §eAusgeschaltet", getNoPermsLore(Arrays.asList("§8/§7freeze"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(24, Material.REDSTONE, "§7Freeze: §eAusgeschaltet", getNoPermsLore(Arrays.asList("§8/§7freeze"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.performCommand("freeze"); updateInventories(); @@ -298,23 +298,23 @@ public class CommandGUI extends SWCommand implements Listener { } if (region.isFire()) { - inv.setItem(3, getMaterial("FIREWORK_STAR", "FIREWORK_CHARGE"), "§7Fire: §eAusgeschaltet", getNoPermsLore(Arrays.asList("§8/§7fire"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(3, getMaterial("FIREWORK_STAR", "FIREWORK_CHARGE"), "§7Fire: §eAusgeschaltet", getNoPermsLore(Arrays.asList("§8/§7fire"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.performCommand("fire"); updateInventories(); }); } else { - inv.setItem(3, getMaterial("FIRE_CHARGE", "FIREBALL"), "§7Fire: §eEingeschaltet", getNoPermsLore(Arrays.asList("§8/§7fire"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(3, getMaterial("FIRE_CHARGE", "FIREBALL"), "§7Fire: §eEingeschaltet", getNoPermsLore(Arrays.asList("§8/§7fire"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.performCommand("fire"); updateInventories(); }); } - inv.setItem(2, Material.ENDER_PEARL, "§7Teleporter", getNoPermsLore(Arrays.asList("§8/§7tp §8[§eSpieler§8]"), player, "§cDu hast keine Buildrechte", Permission.build), false, clickType -> { - if (Welt.noPermission(player, Permission.build)) + inv.setItem(2, Material.ENDER_PEARL, "§7Teleporter", getNoPermsLore(Arrays.asList("§8/§7tp §8[§eSpieler§8]"), player, "§cDu hast keine Buildrechte", Permission.BUILD), false, clickType -> { + if (Welt.noPermission(player, Permission.BUILD)) return; List> playerSWListEntry = new ArrayList<>(); Bukkit.getOnlinePlayers().forEach(player1 -> { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLoader.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLoader.java index fb3f5d6..da8dcdf 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLoader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLoader.java @@ -80,7 +80,7 @@ public class CommandLoader extends SWCommand { } private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.build)) { + if (Welt.noPermission(player, Permission.BUILD)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den AutoLader verwenden"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java index 3038690..c22df9b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java @@ -52,7 +52,7 @@ public class CommandRedstoneTester extends SWCommand { private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.build)) { + if (Welt.noPermission(player, Permission.BUILD)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Redstonetester nutzen"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java index 0847c11..cc61dd3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java @@ -78,7 +78,7 @@ public class CommandReset extends SWCommand { } private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.world)) { + if (Welt.noPermission(player, Permission.WORLD)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Region zurücksetzen"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java new file mode 100644 index 0000000..f10761f --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java @@ -0,0 +1,110 @@ +package de.steamwar.bausystem.commands; + +import com.sk89q.worldedit.bukkit.BukkitWorld; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; +import com.sk89q.worldedit.world.World; +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.world.Welt; +import de.steamwar.bausystem.world.regions.*; +import de.steamwar.command.SWCommand; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + + +public class CommandSelect extends SWCommand { + + + public static final WorldEditPlugin WORLDEDIT_PLUGIN = ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")); + public static final World BUKKITWORLD = new BukkitWorld(Bukkit.getWorlds().get(0)); + + public CommandSelect() { + super("select"); + } + + + @Register + public void baurahmenCommand(Player p, RegionType regionType) { + if (!permissionCheck(p)) { + return; + } + + Region region = Region.getRegion(p.getLocation()); + + if (GlobalRegion.isGlobalRegion(region)) { + //TODO + return; + } + + if (regionType == RegionType.TESTBLOCK) { + if (!region.hasTestblock()) { + //TODO motz den user an + return; + } + setSelection(regionType, RegionExtensionType.NORMAL, region, p); + return; + } + + if (regionType == RegionType.BUILD) { + if (!region.hasBuildRegion()) { + //TODO motz den user an + return; + } + setSelection(regionType, RegionExtensionType.NORMAL, region, p); + return; + } + + setSelection(regionType, RegionExtensionType.NORMAL, region, p); + } + + @Register + public void baurahmenCommand(Player p, RegionType regionType, RegionExtensionType regionExtensionType) { + if (!permissionCheck(p)) { + return; + } + + Region region = Region.getRegion(p.getLocation()); + + if (GlobalRegion.isGlobalRegion(region)) { + //TODO + return; + } + + if (regionType == RegionType.TESTBLOCK) { + if (!region.hasTestblock() || !region.hasTestblockExtensionAreaRegistered()) { + //TODO motz den user an + return; + } + setSelection(regionType, regionExtensionType, region, p); + return; + } + + if (regionType == RegionType.BUILD) { + if (!region.hasBuildRegion() || !region.hasBuildAreaExtensionAreaRegistered()) { + //TODO motz den user an + return; + } + setSelection(regionType, regionExtensionType, region, p); + return; + } + + setSelection(regionType, regionExtensionType, region, p); + } + + + private boolean permissionCheck(Player player) { + if (Welt.noPermission(player, Permission.WORLDEDIT)) { + player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den AutoLader verwenden"); + return false; + } + return true; + } + + private void setSelection(RegionType regionType, RegionExtensionType regionExtensionType, Region region, Player p) { + Point minPoint = region.getMinPoint(regionType, regionExtensionType); + Point maxPoint = region.getMaxPoint(regionType, regionExtensionType); + + WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, minPoint.toBlockVector3(), maxPoint.toBlockVector3())); + } +} \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulator.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulator.java index 10e603d..17947a5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulator.java @@ -67,7 +67,7 @@ public class CommandSimulator extends SWCommand { } private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.world)) { + if (Welt.noPermission(player, Permission.WORLD)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Simulator nutzen"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java index 10c7d7e..a96daf3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java @@ -96,7 +96,7 @@ public class CommandTNT extends SWCommand implements Listener { } private boolean permissionCheck(Player p) { - if (Welt.noPermission(p, Permission.world)) { + if (Welt.noPermission(p, Permission.WORLD)) { p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht TNT-Schaden (de-)aktivieren"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index 35101f5..9f4e904 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -105,7 +105,7 @@ public class CommandTPSLimiter extends SWCommand { } private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.world)) { + if (Welt.noPermission(player, Permission.WORLD)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TPS-Limiter nutzen"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java index ce07c8a..8a23105 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java @@ -45,7 +45,7 @@ public class CommandTime extends SWCommand { @Register public void genericCommand(Player p, int time) { - if (Welt.noPermission(p, Permission.world)) { + if (Welt.noPermission(p, Permission.WORLD)) { p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern"); return; } @@ -58,7 +58,7 @@ public class CommandTime extends SWCommand { @Register public void genericCommand(Player p, Time time) { - if (Welt.noPermission(p, Permission.world)) { + if (Welt.noPermission(p, Permission.WORLD)) { p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern"); return; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java index beb45b8..d1c9e2f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java @@ -123,7 +123,7 @@ public class CommandTrace extends SWCommand { private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.world)) { + if (Welt.noPermission(player, Permission.WORLD)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/DetonatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/DetonatorListener.java index dced125..c044144 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/DetonatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/DetonatorListener.java @@ -21,7 +21,7 @@ public class DetonatorListener implements Listener { if (VersionedCallable.call(new VersionedCallable<>(() -> event.getItem().isSimilar(Detonator.WAND), 12), new VersionedCallable<>(() -> event.getItem().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE), 15))) { Player player = event.getPlayer(); - if (Welt.noPermission(player, Permission.world)) { + if (Welt.noPermission(player, Permission.WORLD)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Detonator nutzen"); return; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java index 1fd82b3..5454ed2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java @@ -49,7 +49,7 @@ public class RedstoneListener implements Listener { private static Map playerMap = new HashMap<>(); private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.build)) { + if (Welt.noPermission(player, Permission.BUILD)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Redstonetester nutzen"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java index b562a9f..1b05bdc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java @@ -63,7 +63,7 @@ public class RegionListener implements Listener { public void onBlockBreak(BlockBreakEvent e) { Player p = e.getPlayer(); - if (Welt.noPermission(p, Permission.build)) { + if (Welt.noPermission(p, Permission.BUILD)) { p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke abbauen"); e.setCancelled(true); } @@ -75,7 +75,7 @@ public class RegionListener implements Listener { Player p = e.getPlayer(); try { - if (Welt.noPermission(p, Permission.build)) { + if (Welt.noPermission(p, Permission.BUILD)) { p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke platzieren"); e.setBuildable(false); } @@ -90,7 +90,7 @@ public class RegionListener implements Listener { Player p = e.getPlayer(); try { - if (Welt.noPermission(p, Permission.build)) { + if (Welt.noPermission(p, Permission.BUILD)) { p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke platzieren"); e.setCancelled(true); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulatorListener.java index e0af211..0a722ce 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulatorListener.java @@ -37,7 +37,7 @@ public class TNTSimulatorListener implements Listener { private static final Vector HALF = new Vector(0.5, 0, 0.5); private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.world)) { + if (Welt.noPermission(player, Permission.WORLD)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Simulator nutzen"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java index 7b733ba..e9e40ec 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java @@ -40,13 +40,13 @@ public class Welt { return true; switch (perm) { - case build: + case BUILD: return !member1.isBuild(); case worldedit: return !member1.isWorldEdit(); - case world: + case WORLD: return !member1.isWorld(); - case member: + case MEMBER: return false; default: return true;