From 4b8745a318bc5757fe26d551307647fe6e7f13d8 Mon Sep 17 00:00:00 2001 From: test Date: Mon, 22 Jul 2024 03:55:25 +1000 Subject: [PATCH] Update GrantCommands.java --- .../manager/v2/impl/pw/commands/GrantCommands.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/commands/GrantCommands.java b/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/commands/GrantCommands.java index eb0aa42d..f6e0550a 100644 --- a/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/commands/GrantCommands.java +++ b/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/commands/GrantCommands.java @@ -1435,12 +1435,12 @@ public String templateCreateWarchest(@Me GuildDB db, @Me DBNation me, @Me IMessa "Defaults to the guild setting: `WARCHEST_PER_CITY`") @Switch("a") Map allowancePerCity, @Arg("Allow granting warchest if they have not received it in the past number of days") - @Switch("t") long trackDays, + @Switch("t") Long trackDays, @Arg("Allow granting warchest that has been consumed in war") @Switch("c") boolean subtractExpenditure, @Arg("Allow granting a certain percent above the allowance to account for unintended losses (e.g. looting)\n" + "Defaults to 0 (percent)") - @Switch("o") long overdrawPercent, + @Switch("o") Long overdrawPercent, @Arg("The role that can grant this template to others\n" + "Defaults to the ECON role (see `{prefix}role setalias`)") @Switch("e") Role econRole, @@ -1483,7 +1483,7 @@ public String templateCreateWarchest(@Me GuildDB db, @Me DBNation me, @Me IMessa @Switch("repeat") boolean nonRepeatable, @Switch("f") boolean force) { boolean repeatable = !nonRepeatable; - long overdrawPercentCents = overdrawPercent * 100; + long overdrawPercentCents = overdrawPercent == null ? 0 : overdrawPercent * 100; name = name.toUpperCase(Locale.ROOT).trim(); // Ensure name is alphanumericalund if (!name.matches("[A-Z0-9_-]+")) { @@ -1506,7 +1506,7 @@ public String templateCreateWarchest(@Me GuildDB db, @Me DBNation me, @Me IMessa } double[] allowancePerCityArr = allowancePerCity == null ? null : ResourceType.resourcesToArray(allowancePerCity); - WarchestTemplate template = new WarchestTemplate(db, false, name, allowedRecipients, econRole.getIdLong(), selfRole.getIdLong(), bracket == null ? 0 : bracket.getId(), useReceiverBracket, maxTotal == null ? 0 : maxTotal, maxDay == null ? 0 : maxDay, maxGranterDay == null ? 0 : maxGranterDay, maxGranterTotal == null ? 0 : maxGranterTotal, System.currentTimeMillis(), allowancePerCityArr, trackDays, subtractExpenditure, overdrawPercentCents, expireTime == null ? 0 : expireTime, decayTime == null ? 0 : decayTime, allowIgnore, repeatable); + WarchestTemplate template = new WarchestTemplate(db, false, name, allowedRecipients, econRole.getIdLong(), selfRole.getIdLong(), bracket == null ? 0 : bracket.getId(), useReceiverBracket, maxTotal == null ? 0 : maxTotal, maxDay == null ? 0 : maxDay, maxGranterDay == null ? 0 : maxGranterDay, maxGranterTotal == null ? 0 : maxGranterTotal, System.currentTimeMillis(), allowancePerCityArr, trackDays == null ? 0 : trackDays, subtractExpenditure, overdrawPercentCents, expireTime == null ? 0 : expireTime, decayTime == null ? 0 : decayTime, allowIgnore, repeatable); AGrantTemplate existing = manager.getTemplateMatching(f -> f.getName().equalsIgnoreCase(finalName)).stream().findFirst().orElse(null); if (existing != null && existing.getType() != template.getType()) {