Added disable command and fixed permissions, closes #15

This commit is contained in:
stijnb1234 2020-02-25 21:19:15 +01:00
parent fb2f6da9cf
commit 74b4ce38fb
3 changed files with 54 additions and 12 deletions

View file

@ -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 <Name>
//@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 <Name>
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 <Name> <Floor>
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 <Name>
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 <Name>§f: Delete a lift.");
sender.sendMessage("§6/v10lift rename <Name> <New name>§f: Rename a lift.");
sender.sendMessage("§6/v10lift rename <New name>§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 <add/del> <Player/Group> [Floorname]§f: Add/remove someone of the whitelist. Use g:<Groupname> 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 <Name>§f: Repair a lift.");
sender.sendMessage("§6/v10lift repair <Name>§f: Repair a lift.");
return true;
}

View file

@ -12,7 +12,7 @@ import java.util.List;
public class V10LiftTabCompleter implements TabCompleter {
private static final List<String> 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<String> 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

View file

@ -7,3 +7,19 @@ softdepend: ["Vault"]
commands:
v10lift:
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