changed order of command parsing, fixed limit checking for arguments
This commit is contained in:
parent
1f13192aec
commit
cca4cb11e3
@ -66,7 +66,7 @@ public class DiscoParty {
|
||||
* @param player The new player to be stored
|
||||
* @return A copy of the class with the new player
|
||||
*/
|
||||
public static DiscoParty DiscoParty(Player player) {
|
||||
public DiscoParty DiscoParty(Player player) {
|
||||
DiscoParty newParty = new DiscoParty(this.ds, player);
|
||||
newParty.setDoFireworks(this.doFireworks);
|
||||
newParty.setDuration(this.duration);
|
||||
@ -90,7 +90,7 @@ public class DiscoParty {
|
||||
}
|
||||
|
||||
public DiscoParty setDuration(int duration) throws IllegalArgumentException {
|
||||
if (duration <= DiscoParty.maxDuration) {
|
||||
if (duration <= DiscoParty.maxDuration || duration > 0) {
|
||||
this.duration = duration;
|
||||
return this;
|
||||
} else {
|
||||
@ -108,7 +108,7 @@ public class DiscoParty {
|
||||
}
|
||||
|
||||
public DiscoParty setRadius(int radius) throws IllegalArgumentException {
|
||||
if (radius <= DiscoParty.maxRadius) {
|
||||
if (radius <= DiscoParty.maxRadius || radius > 0) {
|
||||
this.radius = radius;
|
||||
return this;
|
||||
} else {
|
||||
@ -117,7 +117,7 @@ public class DiscoParty {
|
||||
}
|
||||
|
||||
public DiscoParty setSheep(int sheep) throws IllegalArgumentException {
|
||||
if (sheep <= DiscoParty.maxSheep) {
|
||||
if (sheep <= DiscoParty.maxSheep || sheep > 0) {
|
||||
this.sheep = sheep;
|
||||
return this;
|
||||
} else {
|
||||
|
@ -162,6 +162,22 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
|
||||
isPlayer = true;
|
||||
}
|
||||
|
||||
// check for commands that don't need a party
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("stopall")) {
|
||||
return stopAllCommand(sender);
|
||||
} else if (args[0].equalsIgnoreCase("stop") && isPlayer) {
|
||||
return stopMeCommand(sender);
|
||||
} else if (args[0].equalsIgnoreCase("help")) {
|
||||
return helpCommand(sender);
|
||||
} else if (args[0].equalsIgnoreCase("reload")) {
|
||||
return reloadCommand(sender);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid argument (certain commands do not work from console).");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
if (args[i].equalsIgnoreCase("-fw")) {
|
||||
if (senderHasPerm(sender, PERMISSION_FIREWORKS)) {
|
||||
@ -210,18 +226,10 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
|
||||
|
||||
if (args[0].equalsIgnoreCase("all")) {
|
||||
return partyAllCommand(sender, duration, sheepNumber, radius, period, fireworks);
|
||||
} else if (args[0].equalsIgnoreCase("stopall")) {
|
||||
return stopAllCommand(sender);
|
||||
} else if (args[0].equalsIgnoreCase("stop") && isPlayer) {
|
||||
return stopMeCommand(sender);
|
||||
} else if (args[0].equalsIgnoreCase("me") && isPlayer) {
|
||||
return partyCommand(player, duration, sheepNumber, radius, period, fireworks);
|
||||
} else if (args[0].equalsIgnoreCase("other")) {
|
||||
return partySelectCommand(parsePlayerList(args, 1), sender, duration, sheepNumber, radius, period, fireworks);
|
||||
} else if (args[0].equalsIgnoreCase("help")) {
|
||||
return helpCommand(sender);
|
||||
} else if (args[0].equalsIgnoreCase("reload")) {
|
||||
return reloadCommand(sender);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid argument (certain commands do not work from console).");
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user