SteamWar/BauSystem
Archiviert
13
0

Add CommandSimulator.permissionCheck

Dieser Commit ist enthalten in:
jojo 2021-01-20 17:51:44 +01:00
Ursprung d5ed63f938
Commit e127144223

Datei anzeigen

@ -21,7 +21,10 @@
package de.steamwar.bausystem.commands; package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.canonsimulator.TNTSimulator; import de.steamwar.bausystem.canonsimulator.TNTSimulator;
import de.steamwar.bausystem.world.Welt;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -29,11 +32,23 @@ import org.bukkit.entity.Player;
public class CommandSimulator implements CommandExecutor { public class CommandSimulator implements CommandExecutor {
private boolean permissionCheck(Player player) {
if (Welt.noPermission(player, Permission.build)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Simulator nutzen");
return false;
}
return true;
}
@Override @Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) { public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
if(!(commandSender instanceof Player)) if (!(commandSender instanceof Player))
return false; return false;
Player player = (Player) commandSender; Player player = (Player) commandSender;
if (permissionCheck(player)) {
return false;
}
if (args.length == 1 && args[0].equalsIgnoreCase("wand")) { if (args.length == 1 && args[0].equalsIgnoreCase("wand")) {
player.getInventory().setItemInMainHand(TNTSimulator.WAND); player.getInventory().setItemInMainHand(TNTSimulator.WAND);
player.updateInventory(); player.updateInventory();