Made speed non-player by adding a name argument

This commit is contained in:
stijnb1234 2020-03-16 10:34:45 +01:00
parent 69beb8efe2
commit 608ea1906a

View file

@ -162,9 +162,9 @@ public class V10LiftCommand implements CommandExecutor {
} else { } else {
ConfigUtil.sendMessage(sender, "General.NoPermission"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else if (args[0].equalsIgnoreCase("speed") && args.length == 2) { } else if (args[0].equalsIgnoreCase("speed") && (args.length == 2 || args.length == 3)) {
//v10lift speed <Speed> //v10lift speed <Speed> [Name]
if (!(sender instanceof Player)) { if (args.length == 2 && !(sender instanceof Player)) {
ConfigUtil.sendMessage(sender, "General.PlayerOnly"); ConfigUtil.sendMessage(sender, "General.PlayerOnly");
return true; return true;
} }
@ -512,14 +512,24 @@ public class V10LiftCommand implements CommandExecutor {
return true; return true;
} }
private boolean speedCommand(CommandSender sender, String[] args) { private boolean speedCommand(CommandSender sender, @Nonnull String[] args) {
Player p = (Player) sender; Lift lift;
if (!DataManager.containsEditPlayer(p.getUniqueId())) { if (args.length == 3) {
ConfigUtil.sendMessage(sender, "General.SwitchOnEdit"); if (!DataManager.containsLift(args[2])) {
return true; ConfigUtil.sendMessage(sender, "General.DoesntExists");
return true;
}
lift = DataManager.getLift(args[2]);
} else {
Player p = (Player) sender;
if (!DataManager.containsEditPlayer(p.getUniqueId())) {
ConfigUtil.sendMessage(sender, "General.SwitchOnEdit");
return true;
}
lift = DataManager.getLift(DataManager.getEditPlayer(p.getUniqueId()));
} }
Lift lift = DataManager.getLift(DataManager.getEditPlayer(p.getUniqueId()));
try { try {
int speed = Integer.parseInt(args[1]); int speed = Integer.parseInt(args[1]);
lift.setSpeed(speed); lift.setSpeed(speed);