I cannot into boolean logic (fixed limit checking and exceptions)
This commit is contained in:
parent
4855cf753c
commit
dbbe9d5dba
BIN
dist/DiscoSheep.jar
vendored
BIN
dist/DiscoSheep.jar
vendored
Binary file not shown.
@ -94,7 +94,7 @@ public class DiscoParty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DiscoParty setDuration(int duration) throws IllegalArgumentException {
|
public DiscoParty setDuration(int duration) throws IllegalArgumentException {
|
||||||
if (duration <= DiscoParty.maxDuration || duration > 0) {
|
if (duration <= DiscoParty.maxDuration && duration > 0) {
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
return this;
|
return this;
|
||||||
} else {
|
} else {
|
||||||
@ -103,7 +103,7 @@ public class DiscoParty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DiscoParty setPeriod(int period) throws IllegalArgumentException {
|
public DiscoParty setPeriod(int period) throws IllegalArgumentException {
|
||||||
if (period >= DiscoParty.minPeriod || period <= DiscoParty.maxPeriod) {
|
if (period >= DiscoParty.minPeriod && period <= DiscoParty.maxPeriod) {
|
||||||
this.period = period;
|
this.period = period;
|
||||||
return this;
|
return this;
|
||||||
} else {
|
} else {
|
||||||
@ -112,7 +112,7 @@ public class DiscoParty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DiscoParty setRadius(int radius) throws IllegalArgumentException {
|
public DiscoParty setRadius(int radius) throws IllegalArgumentException {
|
||||||
if (radius <= DiscoParty.maxRadius || radius > 0) {
|
if (radius <= DiscoParty.maxRadius && radius > 0) {
|
||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
return this;
|
return this;
|
||||||
} else {
|
} else {
|
||||||
@ -121,7 +121,7 @@ public class DiscoParty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DiscoParty setSheep(int sheep) throws IllegalArgumentException {
|
public DiscoParty setSheep(int sheep) throws IllegalArgumentException {
|
||||||
if (sheep <= DiscoParty.maxSheep || sheep > 0) {
|
if (sheep <= DiscoParty.maxSheep && sheep > 0) {
|
||||||
this.sheep = sheep;
|
this.sheep = sheep;
|
||||||
return this;
|
return this;
|
||||||
} else {
|
} else {
|
||||||
|
@ -187,6 +187,7 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
|
|||||||
} else if (args[i].equalsIgnoreCase("-r")) {
|
} else if (args[i].equalsIgnoreCase("-r")) {
|
||||||
try {
|
try {
|
||||||
mainParty.setRadius(parseNextIntArg(args, i));
|
mainParty.setRadius(parseNextIntArg(args, i));
|
||||||
|
sender.sendMessage("RADIUS OK");
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
sender.sendMessage("Radius must be an integer within the range [1, "
|
sender.sendMessage("Radius must be an integer within the range [1, "
|
||||||
+ DiscoParty.maxRadius + "]");
|
+ DiscoParty.maxRadius + "]");
|
||||||
@ -195,6 +196,7 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
|
|||||||
} else if (args[i].equalsIgnoreCase("-n")) {
|
} else if (args[i].equalsIgnoreCase("-n")) {
|
||||||
try {
|
try {
|
||||||
mainParty.setSheep(parseNextIntArg(args, i));
|
mainParty.setSheep(parseNextIntArg(args, i));
|
||||||
|
sender.sendMessage("SHEEP OK");
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
sender.sendMessage("The number of sheep must be an integer within the range [1, "
|
sender.sendMessage("The number of sheep must be an integer within the range [1, "
|
||||||
+ DiscoParty.maxSheep + "]");
|
+ DiscoParty.maxSheep + "]");
|
||||||
@ -203,6 +205,7 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
|
|||||||
} else if (args[i].equalsIgnoreCase("-t")) {
|
} else if (args[i].equalsIgnoreCase("-t")) {
|
||||||
try {
|
try {
|
||||||
mainParty.setDuration(parent.toTicks(parseNextIntArg(args, i)));
|
mainParty.setDuration(parent.toTicks(parseNextIntArg(args, i)));
|
||||||
|
sender.sendMessage("DURATION OK");
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
sender.sendMessage("The duration in seconds must be an integer within the range [1, "
|
sender.sendMessage("The duration in seconds must be an integer within the range [1, "
|
||||||
+ parent.toSeconds(DiscoParty.maxDuration) + "]");
|
+ parent.toSeconds(DiscoParty.maxDuration) + "]");
|
||||||
@ -211,6 +214,7 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
|
|||||||
} else if (args[i].equalsIgnoreCase("-p")) {
|
} else if (args[i].equalsIgnoreCase("-p")) {
|
||||||
try {
|
try {
|
||||||
mainParty.setPeriod(parseNextIntArg(args, i));
|
mainParty.setPeriod(parseNextIntArg(args, i));
|
||||||
|
sender.sendMessage("PERIOD OK");
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
sender.sendMessage(
|
sender.sendMessage(
|
||||||
"The period in ticks must be within the range ["
|
"The period in ticks must be within the range ["
|
||||||
|
Loading…
Reference in New Issue
Block a user