From 7fe167a47ee2678ec119827c149055f38b2e8fae Mon Sep 17 00:00:00 2001 From: svgaming234 Date: Wed, 21 Jan 2026 06:48:58 +0100 Subject: [PATCH 1/2] block /ta command if LOG_TO_DATABASE is disabled --- .../java/com/Acrobot/ChestShop/Commands/Transactions.java | 6 ++++++ src/main/java/com/Acrobot/ChestShop/Config/Language.java | 1 + src/main/java/com/Acrobot/ChestShop/Config/Property.java | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/Acrobot/ChestShop/Commands/Transactions.java b/src/main/java/com/Acrobot/ChestShop/Commands/Transactions.java index 2ec81b4..8dbb14b 100644 --- a/src/main/java/com/Acrobot/ChestShop/Commands/Transactions.java +++ b/src/main/java/com/Acrobot/ChestShop/Commands/Transactions.java @@ -3,6 +3,7 @@ import com.Acrobot.ChestShop.ChestShop; import com.Acrobot.ChestShop.Config.Config; import com.Acrobot.ChestShop.Config.Language; +import com.Acrobot.ChestShop.Config.Property; import com.Acrobot.ChestShop.DB.Transaction; import com.Acrobot.ChestShop.Economy; import com.avaje.ebean.PagingList; @@ -32,6 +33,11 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String ArrayDeque argsQueue = new ArrayDeque<>(Arrays.asList(args)); if (argsQueue.isEmpty()) return false; + if (!Config.getBoolean(Property.LOG_TO_DATABASE)) { + sender.sendMessage(Config.getLocal(Language.QUERY_DB_LOG_DISABLED)); + return true; + } + if (argsQueue.peek().equalsIgnoreCase("page")) { int index; try { diff --git a/src/main/java/com/Acrobot/ChestShop/Config/Language.java b/src/main/java/com/Acrobot/ChestShop/Config/Language.java index 5d2a2e6..6a6d7ef 100644 --- a/src/main/java/com/Acrobot/ChestShop/Config/Language.java +++ b/src/main/java/com/Acrobot/ChestShop/Config/Language.java @@ -40,6 +40,7 @@ public enum Language { PROTECTED_SHOP("Successfully protected the shop with LWC!"), SHOP_CREATED("Shop successfully created!"), + QUERY_DB_LOG_DISABLED("To use this command, please enable the LOG_TO_DATABASE option inside the ChestShop configuration file."), QUERY_RESULTS("Results (Page %page of %total)"), QUERY_ROW("&6%datetime &b%user &7-> &b%owner &f%mode %amountx %item &a%price"), QUERY_SWITCH("Use '/transactions page ' to select a page"), diff --git a/src/main/java/com/Acrobot/ChestShop/Config/Property.java b/src/main/java/com/Acrobot/ChestShop/Config/Property.java index 6c3910b..4f00c1f 100644 --- a/src/main/java/com/Acrobot/ChestShop/Config/Property.java +++ b/src/main/java/com/Acrobot/ChestShop/Config/Property.java @@ -13,7 +13,7 @@ public enum Property { SHOP_CREATION_PRICE(0, "Amount of money player must pay to create a shop"), LOG_TO_FILE(false, "If true, plugin will log transactions in its own file"), LOG_TO_CONSOLE(true, "Do you want ChestShop's messages to show up in console?"), - LOG_TO_DATABASE(false, "If true, plugin will log transactions in EBean database"), + LOG_TO_DATABASE(false, "If true, plugin will log transactions in EBean database (required for /ta)"), GENERATE_STATISTICS_PAGE(false, "If true, plugin will generate shop statistics webpage."), STATISTICS_PAGE_PATH("plugins/ChestShop/website.html", "Where should your generated website be saved?"), RECORD_TIME_TO_LIVE(600, "How long should transaction information be stored?"), From 631a52a65fc908f44db07625ff142d7ae7225cfd Mon Sep 17 00:00:00 2001 From: svgaming234 Date: Thu, 22 Jan 2026 13:40:26 +0100 Subject: [PATCH 2/2] add /shophistory alias and autorun /ta to (username) on just /ta --- .../ChestShop/Commands/Transactions.java | 20 +++++++++++++++---- .../Acrobot/ChestShop/Config/Language.java | 1 + src/main/resources/plugin.yml | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/Acrobot/ChestShop/Commands/Transactions.java b/src/main/java/com/Acrobot/ChestShop/Commands/Transactions.java index 8dbb14b..1897704 100644 --- a/src/main/java/com/Acrobot/ChestShop/Commands/Transactions.java +++ b/src/main/java/com/Acrobot/ChestShop/Commands/Transactions.java @@ -12,6 +12,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; import java.time.LocalDateTime; import java.time.ZoneOffset; @@ -30,15 +31,26 @@ public class Transactions implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { - ArrayDeque argsQueue = new ArrayDeque<>(Arrays.asList(args)); - if (argsQueue.isEmpty()) return false; - if (!Config.getBoolean(Property.LOG_TO_DATABASE)) { sender.sendMessage(Config.getLocal(Language.QUERY_DB_LOG_DISABLED)); return true; } - if (argsQueue.peek().equalsIgnoreCase("page")) { + ArrayDeque argsQueue = new ArrayDeque<>(Arrays.asList(args)); + if (argsQueue.isEmpty()) { + if (sender instanceof Player) { + String playerUsername = ((Player) sender).getName(); + + sender.sendMessage(Config.getLocal(Language.QUERY_SEE_MORE_OPTIONS).replace("%user", playerUsername)); + + argsQueue.add("to"); + argsQueue.add(playerUsername); + } + else { + return false; + } + } + else if (argsQueue.peek().equalsIgnoreCase("page")) { int index; try { index = getIndex(argsQueue); diff --git a/src/main/java/com/Acrobot/ChestShop/Config/Language.java b/src/main/java/com/Acrobot/ChestShop/Config/Language.java index 6a6d7ef..1c22c19 100644 --- a/src/main/java/com/Acrobot/ChestShop/Config/Language.java +++ b/src/main/java/com/Acrobot/ChestShop/Config/Language.java @@ -41,6 +41,7 @@ public enum Language { SHOP_CREATED("Shop successfully created!"), QUERY_DB_LOG_DISABLED("To use this command, please enable the LOG_TO_DATABASE option inside the ChestShop configuration file."), + QUERY_SEE_MORE_OPTIONS("To see available parameters, run '/ta help'. Running equivalent of '/ta to %user'."), QUERY_RESULTS("Results (Page %page of %total)"), QUERY_ROW("&6%datetime &b%user &7-> &b%owner &f%mode %amountx %item &a%price"), QUERY_SWITCH("Use '/transactions page ' to select a page"), diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 7941972..25ac1a0 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -25,7 +25,7 @@ commands: usage: | / [from ] [to ] [before ] [after ] / page - aliases: [ta] + aliases: [ta, shophistory] csVersion: description: Shows the ChestShop's version