Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/main/java/com/Acrobot/ChestShop/Commands/Transactions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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<String> 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);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/Acrobot/ChestShop/Config/Language.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 <page>' to select a page"),
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/Acrobot/ChestShop/Config/Property.java
Original file line number Diff line number Diff line change
Expand Up @@ -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?"),
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ commands:
usage: |
/<command> [from <player>] [to <player>] [before <yyyy-MM-dd>] [after <yyyy-MM-dd>]
/<command> page <page>
aliases: [ta]
aliases: [ta, shophistory]

csVersion:
description: Shows the ChestShop's version
Expand Down