diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java index 1d91de9..92dbe31 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java @@ -76,8 +76,10 @@ public class CommandGUI implements CommandExecutor, Listener { player.performCommand("sim wand"); }); - ItemStack redstoneWand = wand(player, RedstoneListener.WAND, "§8/§7redstonetester wand", null, ""); + ItemStack redstoneWand = wand(player, RedstoneListener.WAND, "§8/§7redstonetester wand", Permission.build, "Du hast keine Buildrechte"); inv.setItem(37, redstoneWand, clickType -> { + if (Welt.noPermission(player, Permission.build)) + return; player.closeInventory(); player.performCommand("redstonetester wand"); }); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java index 22b1837..1f46938 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java @@ -19,8 +19,11 @@ package de.steamwar.bausystem.commands; +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.world.RedstoneListener; +import de.steamwar.bausystem.world.Welt; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,6 +36,14 @@ public class CommandRedstoneTester implements CommandExecutor { player.sendMessage("§8/§eredstonetester wand §8- §7Legt dir den Testerstab ins Inventar"); } + 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; + } + @Override public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) { if (!(commandSender instanceof Player)) @@ -42,6 +53,11 @@ public class CommandRedstoneTester implements CommandExecutor { help(player); return false; } + + if (!permissionCheck(player)) { + return false; + } + switch (args[0].toLowerCase()) { case "wand": SWUtils.giveItemToPlayer(player, RedstoneListener.WAND); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java index db8dca1..a988510 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.world; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.inventory.SWItem; import org.bukkit.Location; import org.bukkit.Material; @@ -82,6 +83,14 @@ public class RedstoneListener implements Listener { private Map playerMap = new HashMap<>(); 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 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; @@ -89,6 +98,10 @@ 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()) {