From 7802a03f48faaf2ffdfab19de58ded3988a4f110 Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Sat, 16 Dec 2023 14:47:33 +0100 Subject: [PATCH] Addjusted permissions --- .../bausystem/features/warp/WarpCommand.java | 7 ------- .../de/steamwar/bausystem/features/warp/WarpGui.java | 2 +- .../features/world/AxiomPermissionCheck.java | 2 +- .../bausystem/features/world/ClipboardListener.java | 5 +++++ .../bausystem/features/world/ItemFrameListener.java | 4 ++++ .../bausystem/features/world/KickallCommand.java | 12 ++++-------- .../bausystem/features/world/StopCommand.java | 2 +- .../bausystem/features/world/WorldEditListener.java | 2 +- .../features/worldedit/ColorReplaceCommand.java | 2 +- .../features/worldedit/TypeReplaceCommand.java | 2 +- .../bausystem/features/xray/XrayCommand.java | 2 +- 11 files changed, 20 insertions(+), 22 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java index 8fa832a7..aad07fcb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java @@ -122,13 +122,6 @@ public class WarpCommand extends SWCommand implements Disable, Enable { BauSystem.MESSAGE.sendPrefixless("WARP_GUI_DISTANCE", player, warp.getLocation().distance(player.getLocation())); } - @ClassValidator(value = Player.class, local = true) - public TypeValidator validator() { - return (commandSender, player, messageSender) -> { - return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "WARP_DISALLOWED"); - }; - } - @Linked public static class WarpsLink extends SWCommand { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpGui.java b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpGui.java index 7c5c87a6..30fd21e3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpGui.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpGui.java @@ -55,7 +55,7 @@ public class WarpGui { ), warp))); SWListInv inv = new SWListInv<>(player, BauSystem.MESSAGE.parse("WARP_GUI_NAME", player), false, entries, (clickType, warp) -> { - if (clickType.isRightClick() && Permission.hasPermission(player, Permission.WORLD)) { + if (clickType.isRightClick() && Permission.BUILD.hasPermission(player)) { openWarpGui(player, warp); } else { warp.teleport(player); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java index 5ee07dae..e006e184 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java @@ -32,7 +32,7 @@ public class AxiomPermissionCheck implements Listener { @EventHandler public void onAxiomHandshake(AxiomHandshakeEvent event) { - if (Permission.WORLDEDIT.hasPermission(event.getPlayer())) return; + if (Permission.BUILD.hasPermission(event.getPlayer())) return; event.setCancelled(true); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ClipboardListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ClipboardListener.java index 3d3ca140..04c95e5c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ClipboardListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ClipboardListener.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.world; +import de.steamwar.bausystem.Permission; import de.steamwar.linkage.Linked; import de.steamwar.sql.SchematicData; import de.steamwar.sql.SchematicNode; @@ -35,6 +36,8 @@ public class ClipboardListener implements Listener { @EventHandler public void onLogin(PlayerJoinEvent e) { + if(!Permission.BUILD.hasPermission(e.getPlayer())) return; + try { SchematicNode schematic = SchematicNode.getSchematicNode(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, (Integer) null); if (schematic != null) { @@ -47,6 +50,8 @@ public class ClipboardListener implements Listener { @EventHandler public void onLogout(PlayerQuitEvent e) { + if(!Permission.SUPERVISOR.hasPermission(e.getPlayer())) return; + SchematicNode schematic = SchematicNode.getSchematicNode(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, (Integer) null); boolean newSchem = false; if (schematic == null) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ItemFrameListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ItemFrameListener.java index 9a294708..535551ab 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ItemFrameListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ItemFrameListener.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.world; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; import de.steamwar.linkage.Linked; import org.bukkit.Material; @@ -40,6 +41,9 @@ public class ItemFrameListener implements Listener { if (!(event.getEntity() instanceof ItemFrame)) { return; } + + if(!Permission.BUILD.hasPermission((Player) event.getDamager())) return; + event.setCancelled(true); ItemFrame itemFrame = (ItemFrame) event.getEntity(); ItemStack itemStack = itemFrame.getItem(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/KickallCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/KickallCommand.java index ee9ace1b..d4e5d3f7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/KickallCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/KickallCommand.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.world; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.config.BauServer; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; @@ -38,16 +39,11 @@ public class KickallCommand extends SWCommand { } @Register(description = "KICKALL_HELP") - public void genericCommand(@Validator Player player) { + public void genericCommand(Player player) { + if(!Permission.OWNER.hasPermission(player)) return; + Bukkit.getOnlinePlayers().forEach(p -> { if (!bauServer.getOwner().equals(p.getUniqueId())) p.kickPlayer(""); }); } - - @ClassValidator(value = Player.class, local = true) - public TypeValidator validator() { - return (commandSender, player, messageSender) -> { - return !messageSender.send(!bauServer.getOwner().equals(player.getUniqueId()), "KICKALL_NO_PERM"); - }; - } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/StopCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/StopCommand.java index 4017e548..479cd9ad 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/StopCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/StopCommand.java @@ -51,7 +51,7 @@ public class StopCommand extends SWCommand { return true; } Player player = (Player) sender; - if (Permission.hasPermission(player, Permission.WORLD)) { + if (Permission.SUPERVISOR.hasPermission(player)) { return true; } SteamwarUser user = SteamwarUser.get(player.getUniqueId()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java index ba9d6d9e..6cda80be 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java @@ -40,7 +40,7 @@ public class WorldEditListener implements Listener { if (!isWorldEditCommand(e.getMessage().split(" ")[0])) return; Player p = e.getPlayer(); - if (!Permission.hasPermission(p, Permission.WORLDEDIT)) { + if (!Permission.BUILD.hasPermission(e.getPlayer())) { BauSystem.MESSAGE.send("WORLD_EDIT_NO_PERMS", p); e.setCancelled(true); e.setMessage("/"); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java index 010498a8..6b6659ba 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java @@ -63,7 +63,7 @@ public class ColorReplaceCommand extends SWCommand { @Register(description = "COLORREPLACE_HELP") @SneakyThrows - public void genericCommand(Player player, Pair from, Color to) { + public void genericCommand(@Validator Player player, Pair from, Color to) { if (from.getValue() == to) { BukkitAdapter.adapt(player).printInfo(TranslatableComponent.of("worldedit.replace.replaced", new Component[]{TextComponent.of(0)})); return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/TypeReplaceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/TypeReplaceCommand.java index 0cc939d6..8013c92b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/TypeReplaceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/TypeReplaceCommand.java @@ -67,7 +67,7 @@ public class TypeReplaceCommand extends SWCommand { @Register(description = "TYPEREPLACE_HELP") @SneakyThrows - public void genericCommand(Player player, Pair from, Type to) { + public void genericCommand(@Validator Player player, Pair from, Type to) { if (from.getValue() == to) { BukkitAdapter.adapt(player).printInfo(TranslatableComponent.of("worldedit.replace.replaced", new Component[]{TextComponent.of(0)})); return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java index ef30fbcd..2e5d90a0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java @@ -62,7 +62,7 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen public TechHiderCommand techHiderCommand; @Register(description = "XRAY_HELP") - public void toggleHider(Player player) { + public void toggleHider(@Validator Player player) { Region region = Region.getRegion(player.getLocation()); if (region.isGlobal()) { BauSystem.MESSAGE.send("XRAY_GLOBAL", player);