diff --git a/src/main/lombok/nl/SBDeveloper/V10Lift/Commands/V10LiftCommand.java b/src/main/lombok/nl/SBDeveloper/V10Lift/Commands/V10LiftCommand.java index b5e7c3f..05d8722 100644 --- a/src/main/lombok/nl/SBDeveloper/V10Lift/Commands/V10LiftCommand.java +++ b/src/main/lombok/nl/SBDeveloper/V10Lift/Commands/V10LiftCommand.java @@ -212,44 +212,50 @@ public class V10LiftCommand implements CommandExecutor { } } else if (args[0].equalsIgnoreCase("reload") && args.length == 1) { //v10lift reload - if (!(sender instanceof Player)) { - sender.sendMessage(ChatColor.RED + "You have to be a player to do this."); - return true; - } - if (sender.hasPermission("v10lift.admin")) { + if (sender.hasPermission("v10lift.reload") || sender.hasPermission("v10lift.admin")) { return reloadCommand(sender); } else { sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); } } else if (args[0].equalsIgnoreCase("repair") && args.length == 2) { //v10lift repair + //@TODO Make non-player if (!(sender instanceof Player)) { sender.sendMessage(ChatColor.RED + "You have to be a player to do this."); return true; } - if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) { + if (sender.hasPermission("v10lift.repair") || sender.hasPermission("v10lift.admin")) { return repairCommand(sender, args); } else { sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); } + } else if (args[0].equalsIgnoreCase("disable") && args.length == 2) { + //v10lift disable + if (sender.hasPermission("v10lift.disable") || sender.hasPermission("v10lift.admin")) { + return disableCommand(sender, args); + } else { + sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); + } } else if (args[0].equalsIgnoreCase("start")) { + //@TODO Make non-player //v10lift start if (!(sender instanceof Player)) { sender.sendMessage(ChatColor.RED + "You have to be a player to do this."); return true; } - if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) { + if (sender.hasPermission("v10lift.start") || sender.hasPermission("v10lift.admin")) { return startCommand(sender, args); } else { sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); } } else if (args[0].equalsIgnoreCase("stop")) { + //@TODO Make non-player //v10lift stop if (!(sender instanceof Player)) { sender.sendMessage(ChatColor.RED + "You have to be a player to do this."); return true; } - if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) { + if (sender.hasPermission("v10lift.stop") || sender.hasPermission("v10lift.admin")) { return stopCommand(sender, args); } else { sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); @@ -260,6 +266,25 @@ public class V10LiftCommand implements CommandExecutor { return true; } + private boolean disableCommand(CommandSender sender, @Nonnull String[] args) { + String liftName = args[1]; + if (!DataManager.containsLift(liftName)) { + sender.sendMessage(ChatColor.RED + "Lift " + args[1] + " doesn't exists!"); + return true; + } + + Lift lift = DataManager.getLift(liftName); + + if (lift.isDefective()) { + sender.sendMessage(ChatColor.RED + "This lift is already defective!"); + return true; + } + + V10LiftPlugin.getAPI().setDefective(liftName, true); + sender.sendMessage(ChatColor.GREEN + "Lift disabled!"); + return true; + } + private boolean stopCommand(CommandSender sender, @Nonnull String[] args) { String liftName; if (args.length == 1 && sender instanceof Player) { @@ -1068,7 +1093,7 @@ public class V10LiftCommand implements CommandExecutor { sender.sendMessage("§6/v10lift create [Name]§f: Create a lift."); sender.sendMessage("§6/v10lift delete §f: Delete a lift."); - sender.sendMessage("§6/v10lift rename §f: Rename a lift."); + sender.sendMessage("§6/v10lift rename §f: Rename a lift."); sender.sendMessage("§6/v10lift abort§f: Abort your action."); sender.sendMessage("§6/v10lift whois [Name]§f: See information about a lift."); sender.sendMessage("§6/v10lift edit [Name]§f: Edit a lift."); @@ -1084,7 +1109,8 @@ public class V10LiftCommand implements CommandExecutor { sender.sendMessage("§6/v10lift whitelist [Floorname]§f: Add/remove someone of the whitelist. Use g: for a group."); sender.sendMessage("§6/v10lift start [Name] [Floor]§f: Start a lift to a floor."); sender.sendMessage("§6/v10lift stop [Name]§f: Stop a lift."); - sender.sendMessage("§6/v10lift repair§f: Repair a lift."); + sender.sendMessage("§6/v10lift disable §f: Repair a lift."); + sender.sendMessage("§6/v10lift repair §f: Repair a lift."); return true; } diff --git a/src/main/lombok/nl/SBDeveloper/V10Lift/Commands/V10LiftTabCompleter.java b/src/main/lombok/nl/SBDeveloper/V10Lift/Commands/V10LiftTabCompleter.java index ddf2604..5fedae4 100644 --- a/src/main/lombok/nl/SBDeveloper/V10Lift/Commands/V10LiftTabCompleter.java +++ b/src/main/lombok/nl/SBDeveloper/V10Lift/Commands/V10LiftTabCompleter.java @@ -12,7 +12,7 @@ import java.util.List; public class V10LiftTabCompleter implements TabCompleter { - private static final List COMMANDS = Arrays.asList("create", "delete", "rename", "abort", "whois", "edit", "floor", "input", "build", "rope", "door", "speed", "realistic", "repair", "whitelist", "reload", "help", "start", "stop", "offline"); + private static final List COMMANDS = Arrays.asList("create", "delete", "rename", "abort", "whois", "edit", "floor", "input", "build", "rope", "door", "speed", "realistic", "repair", "disable", "whitelist", "reload", "help", "start", "stop", "offline"); @Override diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index a1c06d2..2c8647c 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -6,4 +6,20 @@ author: SBDeveloper softdepend: ["Vault"] commands: v10lift: - description: The V10Lift Command \ No newline at end of file + description: The V10Lift Command +permissions: + v10lift.admin: + description: The full power admin permission + default: op + v10lift.build: + description: The permission to build a lift + v10lift.reload: + description: Reload the plugin + v10lift.repair: + description: Repair a lift + v10lift.disable: + description: Disable a lift + v10lift.start: + description: Start a lift + v10lift.stop: + description: Stop a lift