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
|
* @param player The new player to be stored
|
||||||
* @return A copy of the class with the new player
|
* @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);
|
DiscoParty newParty = new DiscoParty(this.ds, player);
|
||||||
newParty.setDoFireworks(this.doFireworks);
|
newParty.setDoFireworks(this.doFireworks);
|
||||||
newParty.setDuration(this.duration);
|
newParty.setDuration(this.duration);
|
||||||
@ -90,7 +90,7 @@ public class DiscoParty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DiscoParty setDuration(int duration) throws IllegalArgumentException {
|
public DiscoParty setDuration(int duration) throws IllegalArgumentException {
|
||||||
if (duration <= DiscoParty.maxDuration) {
|
if (duration <= DiscoParty.maxDuration || duration > 0) {
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
return this;
|
return this;
|
||||||
} else {
|
} else {
|
||||||
@ -108,7 +108,7 @@ public class DiscoParty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DiscoParty setRadius(int radius) throws IllegalArgumentException {
|
public DiscoParty setRadius(int radius) throws IllegalArgumentException {
|
||||||
if (radius <= DiscoParty.maxRadius) {
|
if (radius <= DiscoParty.maxRadius || radius > 0) {
|
||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
return this;
|
return this;
|
||||||
} else {
|
} else {
|
||||||
@ -117,7 +117,7 @@ public class DiscoParty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DiscoParty setSheep(int sheep) throws IllegalArgumentException {
|
public DiscoParty setSheep(int sheep) throws IllegalArgumentException {
|
||||||
if (sheep <= DiscoParty.maxSheep) {
|
if (sheep <= DiscoParty.maxSheep || sheep > 0) {
|
||||||
this.sheep = sheep;
|
this.sheep = sheep;
|
||||||
return this;
|
return this;
|
||||||
} else {
|
} else {
|
||||||
|
@ -161,6 +161,22 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
|
|||||||
player = (Player) sender;
|
player = (Player) sender;
|
||||||
isPlayer = true;
|
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++) {
|
for (int i = 1; i < args.length; i++) {
|
||||||
if (args[i].equalsIgnoreCase("-fw")) {
|
if (args[i].equalsIgnoreCase("-fw")) {
|
||||||
@ -210,18 +226,10 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
|
|||||||
|
|
||||||
if (args[0].equalsIgnoreCase("all")) {
|
if (args[0].equalsIgnoreCase("all")) {
|
||||||
return partyAllCommand(sender, duration, sheepNumber, radius, period, fireworks);
|
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) {
|
} else if (args[0].equalsIgnoreCase("me") && isPlayer) {
|
||||||
return partyCommand(player, duration, sheepNumber, radius, period, fireworks);
|
return partyCommand(player, duration, sheepNumber, radius, period, fireworks);
|
||||||
} else if (args[0].equalsIgnoreCase("other")) {
|
} else if (args[0].equalsIgnoreCase("other")) {
|
||||||
return partySelectCommand(parsePlayerList(args, 1), sender, duration, sheepNumber, radius, period, fireworks);
|
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 {
|
} else {
|
||||||
sender.sendMessage(ChatColor.RED + "Invalid argument (certain commands do not work from console).");
|
sender.sendMessage(ChatColor.RED + "Invalid argument (certain commands do not work from console).");
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user