From 92b89775cfd8f0d105d92dc37255f4bd36d3806b Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 4 Apr 2021 17:44:16 +0200 Subject: [PATCH] Remove Permission.build --- .../src/de/steamwar/bausystem/Permission.java | 1 - .../bausystem/commands/CommandBau.java | 19 --------- .../bausystem/commands/CommandDebugStick.java | 8 +--- .../bausystem/commands/CommandGUI.java | 35 +++++----------- .../bausystem/commands/CommandGamemode.java | 15 ------- .../bausystem/commands/CommandInfo.java | 1 - .../bausystem/commands/CommandLoader.java | 14 ------- .../commands/CommandRedstoneTester.java | 9 ----- .../bausystem/commands/CommandTeleport.java | 10 ----- .../bausystem/world/RedstoneListener.java | 12 ------ .../bausystem/world/RegionListener.java | 40 ------------------- .../src/de/steamwar/bausystem/world/Welt.java | 7 ---- 12 files changed, 11 insertions(+), 160 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java index c776150..dc92701 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java @@ -22,6 +22,5 @@ package de.steamwar.bausystem; public enum Permission { world, worldedit, - build, member } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java index a02e6bb..1d2dbd9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java @@ -38,7 +38,6 @@ public class CommandBau extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§ebau togglebuild §8[§7Player§8] §8- §7Editiere die Bau Rechte eines Spielers"); p.sendMessage("§8/§ebau togglewe §8[§7Player§8] §8- §7Editiere die WorldEdit Rechte eines Spielers"); p.sendMessage("§8/§ebau toggleworld §8[§7Player§8] §8- §7Editiere die Werlt Rechte eines Spielers"); } @@ -48,14 +47,6 @@ public class CommandBau extends SWCommand { CommandInfo.sendBauInfo(p); } - @Register("togglebuild") - public void toggleBuildCommand(Player p, SteamwarUser user) { - if (!permissionCheck(p)) { - return; - } - onToggleBD(p, user); - } - @Register("togglewe") public void toggleWECommand(Player p, SteamwarUser user) { if (!permissionCheck(p)) { @@ -72,16 +63,6 @@ public class CommandBau extends SWCommand { onToggleWorld(p, user); } - - private void onToggleBD(Player p, SteamwarUser id) { - if (negativeToggleCheck(p, id)) { - return; - } - - BauweltMember target = BauweltMember.getBauMember(BauSystem.getOwnerID(), id.getId()); - Welt.toggleBuild(p, target); - } - private void onToggleWE(Player p, SteamwarUser id) { if (negativeToggleCheck(p, id)) { return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java index 604122f..8e4cfc7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java @@ -39,11 +39,7 @@ public class CommandDebugStick extends SWCommand { @Register public void genericCommand(Player p) { - 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), - new VersionedRunnable(() -> CommandDebugStick_15.giveStick(p), 15)); - } + VersionedRunnable.call(new VersionedRunnable(() -> p.sendMessage(BauSystem.PREFIX + "§cDen Debugstick gibt es nicht in der 1.12."), 8), + new VersionedRunnable(() -> CommandDebugStick_15.giveStick(p), 15)); } } \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java index b2fa3db..7cdccfa 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java @@ -111,10 +111,8 @@ public class CommandGUI extends SWCommand implements Listener { 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", null, ""); inv.setItem(37, redstoneWand, clickType -> { - if (Welt.noPermission(player, Permission.build)) - return; player.closeInventory(); player.performCommand("redstonetester"); }); @@ -311,9 +309,7 @@ public class CommandGUI extends SWCommand implements Listener { }); } - 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; + inv.setItem(2, Material.ENDER_PEARL, "§7Teleporter", getNoPermsLore(Arrays.asList("§8/§7tp §8[§eSpieler§8]"), player, "", null), false, clickType -> { List> playerSWListEntry = new ArrayList<>(); Bukkit.getOnlinePlayers().forEach(player1 -> { if (player1.equals(player)) @@ -479,7 +475,6 @@ public class CommandGUI extends SWCommand implements Listener { item.setName("§7" + user.getUserName()); List lore = new ArrayList<>(); lore.add("§7Online: §e" + (Bukkit.getPlayer(user.getUUID()) == null ? "Offline" : "Online")); - lore.add("§7Bauen: §e" + (member.isBuild() ? "Ja" : "Nein")); lore.add("§7Worldedit: §e" + (member.isWorldEdit() ? "Ja" : "Nein")); lore.add("§7World: §e" + (member.isWorld() ? "Ja" : "Nein")); item.setLore(lore); @@ -514,47 +509,35 @@ public class CommandGUI extends SWCommand implements Listener { private static void bauweltMemberGUI(Player player, BauweltMember member) { SteamwarUser user = SteamwarUser.get(member.getMemberID()); SWInventory inv = new SWInventory(player, 9, "Member: " + user.getUserName()); - if (member.isBuild()) { - inv.setItem(0, getMaterial("GREEN_WOOL", "WOOL"), (byte) 13, "§7Bauen", Arrays.asList("§7Aktuell: §eJa", "§8/§7bau togglebuild §8[§eSpieler§8]"), false, clickType -> { - member.setBuild(false); - bauweltMemberGUI(player, member); - }); - } else { - inv.setItem(0, getMaterial("RED_WOOL", "WOOL"), (byte) 14, "§7Bauen", Arrays.asList("§7Aktuell: §eNein", "§8/§7bau togglebuild §8[§eSpieler§8]"), false, clickType -> { - member.setBuild(true); - bauweltMemberGUI(player, member); - }); - } - if (member.isWorldEdit()) { - inv.setItem(2, getMaterial("GREEN_WOOL", "WOOL"), (byte) 13, "§7Worldedit", Arrays.asList("§7Aktuell: §eJa", "§8/§7bau togglewe §8[§eSpieler§8]"), false, clickType -> { + inv.setItem(1, getMaterial("GREEN_WOOL", "WOOL"), (byte) 13, "§7Worldedit", Arrays.asList("§7Aktuell: §eJa", "§8/§7bau togglewe §8[§eSpieler§8]"), false, clickType -> { member.setWorldEdit(false); bauweltMemberGUI(player, member); }); } else { - inv.setItem(2, getMaterial("RED_WOOL", "WOOL"), (byte) 14, "§7Worldedit", Arrays.asList("§7Aktuell: §eNein", "§8/§7bau togglewe §8[§eSpieler§8]"), false, clickType -> { + inv.setItem(1, getMaterial("RED_WOOL", "WOOL"), (byte) 14, "§7Worldedit", Arrays.asList("§7Aktuell: §eNein", "§8/§7bau togglewe §8[§eSpieler§8]"), false, clickType -> { member.setWorldEdit(true); bauweltMemberGUI(player, member); }); } if (member.isWorld()) { - inv.setItem(4, getMaterial("GREEN_WOOL", "WOOL"), (byte) 13, "§7World", Arrays.asList("§7Aktuell: §eJa", "§8/§7bau toggleworld §8[§eSpieler§8]"), false, clickType -> { + inv.setItem(3, getMaterial("GREEN_WOOL", "WOOL"), (byte) 13, "§7World", Arrays.asList("§7Aktuell: §eJa", "§8/§7bau toggleworld §8[§eSpieler§8]"), false, clickType -> { member.setWorld(false); bauweltMemberGUI(player, member); }); } else { - inv.setItem(4, getMaterial("RED_WOOL", "WOOL"), (byte) 14, "§7World", Arrays.asList("§7Aktuell: §eNein", "§8/§7bau toggleworld §8[§eSpieler§8]"), false, clickType -> { + inv.setItem(3, getMaterial("RED_WOOL", "WOOL"), (byte) 14, "§7World", Arrays.asList("§7Aktuell: §eNein", "§8/§7bau toggleworld §8[§eSpieler§8]"), false, clickType -> { member.setWorld(true); bauweltMemberGUI(player, member); }); } - inv.setItem(6, Material.BARRIER, "§7Member entfernen", clickType -> { + inv.setItem(5, Material.BARRIER, "§7Member entfernen", clickType -> { player.closeInventory(); confirmChatMessage(player, "/bau delmember " + user.getUserName()); }); - inv.setItem(8, Material.ARROW, "§7Zurück", clickType -> bauManagementGUI(player)); + inv.setItem(7, Material.ARROW, "§7Zurück", clickType -> bauManagementGUI(player)); inv.open(); } @@ -569,7 +552,7 @@ public class CommandGUI extends SWCommand implements Listener { } private static List getNoPermsLore(List lore, Player player, String noPerms, Permission perm) { - if (Welt.noPermission(player, perm)) { + if (perm != null && Welt.noPermission(player, perm)) { lore = new ArrayList<>(lore); lore.add(noPerms); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java index 8747a1c..5ddbfa0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java @@ -19,9 +19,7 @@ package de.steamwar.bausystem.commands; -import de.steamwar.bausystem.BauSystem; import de.steamwar.command.SWCommand; -import de.steamwar.sql.BauweltMember; import org.bukkit.GameMode; import org.bukkit.entity.Player; @@ -38,7 +36,6 @@ public class CommandGamemode extends SWCommand { @Register public void genericCommand(Player p) { - if (!permissionCheck(p)) return; if (p.getGameMode() == GameMode.CREATIVE) { p.setGameMode(GameMode.SPECTATOR); } else { @@ -48,18 +45,6 @@ public class CommandGamemode extends SWCommand { @Register public void gamemodeCommand(Player p, GameMode gameMode) { - if (!permissionCheck(p)) return; p.setGameMode(gameMode); } - - private boolean permissionCheck(Player p) { - if (!p.getUniqueId().equals(BauSystem.getOwner())) { - BauweltMember member = BauweltMember.getBauMember(BauSystem.getOwner(), p.getUniqueId()); - if (member == null || !member.isBuild()) { - p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier deinen Spielmodus nicht ändern"); - return false; - } - } - return true; - } } \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java index 93873dc..20e0f5d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java @@ -58,7 +58,6 @@ public class CommandInfo extends SWCommand { for (BauweltMember member : members) { membermessage.append("§e").append(SteamwarUser.get(member.getMemberID()).getUserName()).append("§8["); - membermessage.append(member.isBuild() ? "§a" : "§c").append("B").append("§8,"); membermessage.append(member.isWorldEdit() ? "§a" : "§c").append("WE").append("§8,"); membermessage.append(member.isWorld() ? "§a" : "§c").append("W").append("§8]").append(" "); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLoader.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLoader.java index fb3f5d6..628db20 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLoader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLoader.java @@ -45,48 +45,34 @@ public class CommandLoader extends SWCommand { @Register({"setup"}) public void setupCommand(Player p) { - if (!permissionCheck(p)) return; setup(p); } @Register({"undo"}) public void undoCommand(Player p) { - if (!permissionCheck(p)) return; undo(p); } @Register({"start"}) public void startCommand(Player p) { - if (!permissionCheck(p)) return; start(p); } @Register({"stop"}) public void stopCommand(Player p) { - if (!permissionCheck(p)) return; stop(p); } @Register({"wait"}) public void waitCommand(Player p, int time) { - if (!permissionCheck(p)) return; wait(p, time); } @Register({"speed"}) public void speedCommand(Player p, int time) { - if (!permissionCheck(p)) return; speed(p, time); } - private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.build)) { - player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den AutoLader verwenden"); - return false; - } - return true; - } - private void setup(Player player) { AutoLoader.getLoader(player).setup(); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java index 3038690..8247efa 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java @@ -44,19 +44,10 @@ public class CommandRedstoneTester extends SWCommand { VersionedRunnable.call(new VersionedRunnable(() -> { p.sendMessage(BauSystem.PREFIX + "Der RedstoneTester ist nicht in der 1.12 verfügbar"); }, 8), new VersionedRunnable(() -> { - if (!permissionCheck(p)) return; p.sendMessage(BauSystem.PREFIX + "Messe die Zeit zwischen der Aktivierung zweier Redstone Komponenten"); SWUtils.giveItemToPlayer(p, RedstoneListener.WAND); }, 15)); } - private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.build)) { - player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Redstonetester nutzen"); - return false; - } - return true; - } - } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java index 769da8f..04fa8c7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java @@ -21,7 +21,6 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.command.SWCommand; -import de.steamwar.sql.BauweltMember; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerTeleportEvent; @@ -42,15 +41,6 @@ public class CommandTeleport extends SWCommand { p.sendMessage(BauSystem.PREFIX + "§cSei eins mit dir selbst!"); return; } - - if (!BauSystem.getOwner().equals(p.getUniqueId())) { - BauweltMember member = BauweltMember.getBauMember(BauSystem.getOwner(), p.getUniqueId()); - if (member == null || !member.isBuild()) { - p.sendMessage(BauSystem.PREFIX + "§cDu darfst dich auf dieser Welt nicht teleportieren!"); - return; - } - } - p.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND); } } \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java index 1fd82b3..c52f4f7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java @@ -48,14 +48,6 @@ public class RedstoneListener implements Listener { public static final ItemStack WAND = new SWItem(Material.BLAZE_ROD, "§eRedstonetester", Arrays.asList("§eLinksklick Block §8- §7Setzt die 1. Position", "§eRechtsklick Block §8- §7Setzt die 2. Position", "§eShift-Rechtsklick Luft §8- §7Zurücksetzten"), false, null).getItemStack(); private static Map playerMap = new HashMap<>(); - private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.build)) { - player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Redstonetester nutzen"); - return false; - } - return true; - } - @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { if (!WAND.isSimilar(event.getItem())) return; @@ -63,10 +55,6 @@ public class RedstoneListener implements Listener { Block block = event.getClickedBlock(); event.setCancelled(true); - if (!permissionCheck(event.getPlayer())) { - return; - } - switch (event.getAction()) { case RIGHT_CLICK_AIR: if (player.isSneaking()) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java index b562a9f..ead9a3c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java @@ -59,46 +59,6 @@ public class RegionListener implements Listener { } } - @EventHandler(priority = EventPriority.LOWEST) - public void onBlockBreak(BlockBreakEvent e) { - Player p = e.getPlayer(); - - if (Welt.noPermission(p, Permission.build)) { - p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke abbauen"); - e.setCancelled(true); - } - } - - @EventHandler(priority = EventPriority.LOWEST) - public void onBlockCanBuild(BlockCanBuildEvent e) { - if (Core.getVersion() == 12) return; - - Player p = e.getPlayer(); - try { - if (Welt.noPermission(p, Permission.build)) { - p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke platzieren"); - e.setBuildable(false); - } - } catch (NullPointerException ex) { - //ignored, caused by worldedit brushes - } - } - - @EventHandler(priority = EventPriority.LOWEST) - public void onBlockPlace(BlockPlaceEvent e) { - if (Core.getVersion() == 15) return; - - Player p = e.getPlayer(); - try { - if (Welt.noPermission(p, Permission.build)) { - p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke platzieren"); - e.setCancelled(true); - } - } catch (NullPointerException ex) { - //ignored, caused by worldedit brushes - } - } - private static final String[] shortcutCommands = {"//1", "//2", "//90", "//-90", "//180", "//p", "//c", "//flopy", "//floppy", "//flopyp", "//floppyp", "//u", "//r"}; private boolean isWorldEditCommand(String command) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java index 7b733ba..c5c411c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java @@ -40,8 +40,6 @@ public class Welt { return true; switch (perm) { - case build: - return !member1.isBuild(); case worldedit: return !member1.isWorldEdit(); case world: @@ -69,11 +67,6 @@ public class Welt { } } - public static void toggleBuild(Player p, BauweltMember target) { - target.setBuild(!target.isBuild()); - sendMessages(p, target.isBuild(), target, "bauen"); - } - public static void toggleWE(Player p, BauweltMember target) { target.setWorldEdit(!target.isWorldEdit()); sendMessages(p, target.isWorldEdit(), target, "WorldEdit verwenden");