fix out of bounds error with hasTime

Took 10 minutes
This commit is contained in:
Kiran Hart 2022-07-27 22:55:16 -04:00
parent 7e9043f359
commit c88f185e8e
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3

View File

@ -143,17 +143,24 @@ public final class CommandSell extends AbstractCommand {
boolean isStackPrice = false;
boolean partialBuy = false;
List<String> timeSets = Arrays.asList(
"second",
"minute",
"hour",
"day",
"week",
"month"
);
for (int i = 0; i < args.length; i++) {
if (NumberUtils.isDouble(args[i]) && !Double.isNaN(Double.parseDouble(args[i]))) {
final boolean hasTimeValue = args.length >= i + 1 && Arrays.asList(
"second",
"minute",
"hour",
"day",
"week",
"month"
).contains(args[i + 1]);
boolean hasTimeValue = false;
if (i + 1 < args.length) {
if (timeSets.contains(args[i + 1].toLowerCase()))
hasTimeValue = true;
}
if (!hasTimeValue) {
if (buyNowPrice == null)
@ -181,8 +188,6 @@ public final class CommandSell extends AbstractCommand {
if (i + 2 < args.length) {
int customTime = (int) AuctionAPI.toTicks(args[i + 1] + " " + args[i + 2]);
Bukkit.broadcastMessage(customTime + " time");
if (customTime <= Settings.MAX_CUSTOM_DEFINED_TIME.getInt())
allowedTime = customTime;
}