diff --git a/src/main/java/com/Acrobot/ChestShop/Commands/Transactions.java b/src/main/java/com/Acrobot/ChestShop/Commands/Transactions.java index 2ec81b4..1897704 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; @@ -11,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; @@ -29,10 +31,26 @@ public class Transactions implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { + if (!Config.getBoolean(Property.LOG_TO_DATABASE)) { + sender.sendMessage(Config.getLocal(Language.QUERY_DB_LOG_DISABLED)); + return true; + } + ArrayDeque argsQueue = new ArrayDeque<>(Arrays.asList(args)); - if (argsQueue.isEmpty()) return false; + if (argsQueue.isEmpty()) { + if (sender instanceof Player) { + String playerUsername = ((Player) sender).getName(); + + sender.sendMessage(Config.getLocal(Language.QUERY_SEE_MORE_OPTIONS).replace("%user", playerUsername)); - if (argsQueue.peek().equalsIgnoreCase("page")) { + 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 5d2a2e6..1c22c19 100644 --- a/src/main/java/com/Acrobot/ChestShop/Config/Language.java +++ b/src/main/java/com/Acrobot/ChestShop/Config/Language.java @@ -40,6 +40,8 @@ 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_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/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?"), 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