Add buildPermission to CommandRedstoneTester
Dieser Commit ist enthalten in:
Ursprung
7b7e10d6cc
Commit
e1cdd4f1b7
@ -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");
|
||||
});
|
||||
|
@ -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);
|
||||
|
@ -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<Player, RedstoneTester> 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()) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren