From 82f4c6009678ed6ae839dbf79f0ba17f9e6e85c5 Mon Sep 17 00:00:00 2001 From: test Date: Tue, 23 Jul 2024 22:36:03 +1000 Subject: [PATCH] Allow deleted for bank transfers sheet --- build.gradle | 2 +- .../manager/v2/impl/pw/binding/PWBindings.java | 3 ++- .../manager/v2/impl/pw/commands/BankCommands.java | 12 ++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 46ca06f9..4c64258e 100644 --- a/build.gradle +++ b/build.gradle @@ -209,7 +209,7 @@ dependencies { runtimeOnly "ai.djl.pytorch:pytorch-engine:0.28.0" runtimeOnly "ai.djl.pytorch:pytorch-model-zoo:0.28.0" implementation "ai.djl.huggingface:tokenizers:0.28.0" -// runtimeOnly 'ai.djl.pytorch:pytorch-native-cu121:2.2.2:win-x86_64' + runtimeOnly 'ai.djl.pytorch:pytorch-native-cu121:2.2.2:win-x86_64' runtimeOnly 'ai.djl.pytorch:pytorch-jni:2.2.2-0.28.0' // implementation 'net.sourceforge.tess4j:tess4j:4.5.1' implementation 'org.bytedeco:javacv:1.5.6' diff --git a/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/binding/PWBindings.java b/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/binding/PWBindings.java index 3c0b8064..154fcae0 100644 --- a/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/binding/PWBindings.java +++ b/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/binding/PWBindings.java @@ -683,8 +683,9 @@ public static NationOrAllianceOrGuildOrTaxid nationOrAllianceOrGuildOrTaxId(Stri return selfDb; } } + boolean allowDeleted = data != null && data.getAnnotation(AllowDeleted.class) != null; try { - return nationOrAlliance(input, data); + return nationOrAlliance(data, input, allowDeleted); } catch (IllegalArgumentException ignore) { if (includeTaxId && !input.startsWith("#") && input.contains("tax_id")) { int taxId = PW.parseTaxId(input); diff --git a/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/commands/BankCommands.java b/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/commands/BankCommands.java index c0c9484a..f002a0e4 100644 --- a/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/commands/BankCommands.java +++ b/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/commands/BankCommands.java @@ -2655,7 +2655,7 @@ public void largest(Map total, Map l @Command(desc = "Get a sheet of in-game transfers for nations") @RolePermission(value = Roles.ECON) - public String getIngameNationTransfers(@Me IMessageIO channel, @Me GuildDB db, Set senders, Set receivers, @Arg("Only transfers after timeframe") @Default("%epoch%") @Timestamp long timeframe, @Switch("s") SpreadSheet sheet) throws IOException, GeneralSecurityException { + public String getIngameNationTransfers(@Me IMessageIO channel, @Me GuildDB db, @AllowDeleted Set senders, @AllowDeleted Set receivers, @Arg("Only transfers after timeframe") @Default("%epoch%") @Timestamp long timeframe, @Switch("s") SpreadSheet sheet) throws IOException, GeneralSecurityException { if (sheet == null) sheet = SpreadSheet.create(db, SheetKey.BANK_TRANSACTION_SHEET); Set senderIds = senders.stream().map(NationOrAllianceOrGuild::getIdLong).collect(Collectors.toSet()); Set receiverIds = receivers.stream().map(NationOrAllianceOrGuild::getIdLong).collect(Collectors.toSet()); @@ -2800,7 +2800,7 @@ public String convertNegativeDeposits(@Me IMessageIO channel, @Me GuildDB db, @M }) @RolePermission(value = Roles.ECON) public String getNationsInternalTransfers(@Me IMessageIO channel, @Me GuildDB db, - Set nations, + @AllowDeleted Set nations, @Arg(value = "Only list transfers after this time", group = 0) @Timestamp @Default Long startTime, @Arg(value = "Only list transfers before this time", group = 0) @@ -2826,7 +2826,11 @@ public String getNationsInternalTransfers(@Me IMessageIO channel, @Me GuildDB db @Command(desc = "Get a sheet of transfers") @RolePermission(value = Roles.ECON, root = true) - public String getIngameTransactions(@Me IMessageIO channel, @Me GuildDB db, @Default NationOrAlliance sender, @Default NationOrAlliance receiver, @Default NationOrAlliance banker, @Default("%epoch%") @Timestamp long timeframe, @Switch("s") SpreadSheet sheet) throws GeneralSecurityException, IOException { + public String getIngameTransactions(@Me IMessageIO channel, @Me GuildDB db, + @AllowDeleted @Default NationOrAlliance sender, + @AllowDeleted @Default NationOrAlliance receiver, + @AllowDeleted @Default NationOrAlliance banker, + @Default("%epoch%") @Timestamp long timeframe, @Switch("s") SpreadSheet sheet) throws GeneralSecurityException, IOException { if (sheet == null) sheet = SpreadSheet.create(db, SheetKey.BANK_TRANSACTION_SHEET); List transactions = Locutus.imp().getBankDB().getAllTransactions(sender, receiver, banker, timeframe, null); if (transactions.size() > 10000) return "Timeframe is too large, please use a shorter period"; @@ -2841,7 +2845,7 @@ public String getIngameTransactions(@Me IMessageIO channel, @Me GuildDB db, @Def }) @RolePermission(value = Roles.ECON) public String transactions(@Me IMessageIO channel, @Me GuildDB db, @Me User user, - NationOrAllianceOrGuildOrTaxid nationOrAllianceOrGuild, + @AllowDeleted NationOrAllianceOrGuildOrTaxid nationOrAllianceOrGuild, @Arg(value = "Only show transactions after this time", group = 0) @Default("%epoch%") @Timestamp long timeframe, @Arg(value = "Do NOT include the tax record resources below the internal tax rate\n" +