From b4bc4783542ce096c4f1a196038b939a6553bcb2 Mon Sep 17 00:00:00 2001 From: Kiran Hart Date: Wed, 14 Aug 2024 13:26:24 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Added=20ability=20to=20customize=20?= =?UTF-8?q?command=20aliases?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Took 22 minutes --- .../auctionhouse/commands/CommandActive.java | 12 ++-- .../auctionhouse/commands/CommandAdmin.java | 69 +++++++++---------- .../commands/CommandAuctionHouse.java | 3 +- .../auctionhouse/commands/CommandBan.java | 20 +++--- .../auctionhouse/commands/CommandBids.java | 12 ++-- .../auctionhouse/commands/CommandConfirm.java | 20 +++--- .../auctionhouse/commands/CommandExpired.java | 19 +++-- .../auctionhouse/commands/CommandFilter.java | 16 ++--- .../commands/CommandMarkChest.java | 3 +- .../commands/CommandMiddleware.java | 2 - .../commands/CommandMinPrice.java | 21 +++--- .../commands/CommandPayments.java | 13 ++-- .../auctionhouse/commands/CommandRequest.java | 50 ++++---------- .../auctionhouse/commands/CommandSearch.java | 12 ++-- .../auctionhouse/commands/CommandSell.java | 64 ++++++++--------- .../commands/CommandSettings.java | 3 +- .../auctionhouse/commands/CommandStats.java | 19 +++-- .../commands/CommandToggleListInfo.java | 15 ++-- .../commands/CommandTransactions.java | 10 +-- .../auctionhouse/commands/CommandUnban.java | 14 ++-- .../auctionhouse/commands/CommandUpload.java | 11 ++- .../auctionhouse/database/DataManager.java | 7 +- .../auctionhouse/model/ListingBuilder.java | 8 +-- .../model/discord/DiscordMessageCreator.java | 1 - .../auctionhouse/settings/Settings.java | 22 +++++- 25 files changed, 217 insertions(+), 229 deletions(-) diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandActive.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandActive.java index 04af92c..9274b39 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandActive.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandActive.java @@ -21,6 +21,7 @@ package ca.tweetzy.auctionhouse.commands; import ca.tweetzy.auctionhouse.AuctionHouse; import ca.tweetzy.auctionhouse.auction.AuctionPlayer; import ca.tweetzy.auctionhouse.guis.core.GUIActiveAuctions; +import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.commands.AbstractCommand; import ca.tweetzy.core.utils.TextUtils; import org.bukkit.Bukkit; @@ -38,7 +39,7 @@ import java.util.List; public class CommandActive extends AbstractCommand { public CommandActive() { - super(CommandType.PLAYER_ONLY, "active"); + super(CommandType.PLAYER_ONLY, Settings.CMD_ALIAS_SUB_ACTIVE.getStringList().toArray(new String[0])); } @Override @@ -47,12 +48,11 @@ public class CommandActive extends AbstractCommand { if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE; - final AuctionHouse instance = AuctionHouse.getInstance(); - if (instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()) == null) { - instance.getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); - instance.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player)); + if (AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()) == null) { + AuctionHouse.getInstance().getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); + AuctionHouse.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player)); } - instance.getGuiManager().showGUI(player, new GUIActiveAuctions(instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()))); + AuctionHouse.getGuiManager().showGUI(player, new GUIActiveAuctions(AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()))); return ReturnType.SUCCESS; } diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandAdmin.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandAdmin.java index 78f27e1..da68c5f 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandAdmin.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandAdmin.java @@ -58,7 +58,7 @@ import java.util.stream.Collectors; public class CommandAdmin extends AbstractCommand { public CommandAdmin() { - super(CommandType.CONSOLE_OK, "admin"); + super(CommandType.CONSOLE_OK, Settings.CMD_ALIAS_SUB_ADMIN.getStringList().toArray(new String[0])); } @Override @@ -66,16 +66,15 @@ public class CommandAdmin extends AbstractCommand { if (args.length < 1) return ReturnType.FAILURE; if (AuctionAPI.tellMigrationStatus(sender)) return ReturnType.FAILURE; - final AuctionHouse instance = AuctionHouse.getInstance(); switch (args[0].toLowerCase()) { case "logs": if (!(sender instanceof Player)) break; Player player = (Player) sender; if (!player.hasPermission("auctionhouse.cmd.admin.logs")) return ReturnType.FAILURE; - instance.getDataManager().getAdminLogs((error, logs) -> { + AuctionHouse.getDataManager().getAdminLogs((error, logs) -> { if (error == null) - AuctionHouse.newChain().sync(() -> instance.getGuiManager().showGUI(player, new GUIAdminLogs(player, logs))).execute(); + AuctionHouse.newChain().sync(() -> AuctionHouse.getGuiManager().showGUI(player, new GUIAdminLogs(player, logs))).execute(); else error.printStackTrace(); }); @@ -98,42 +97,42 @@ public class CommandAdmin extends AbstractCommand { } if (target == null) { - instance.getLocale().getMessage("general.playernotfound").processPlaceholder("player", args[1]).sendPrefixedMessage(sender); + AuctionHouse.getInstance().getLocale().getMessage("general.playernotfound").processPlaceholder("player", args[1]).sendPrefixedMessage(sender); return ReturnType.FAILURE; } - instance.getGuiManager().showGUI(player, new GUIAdminExpired(player, target)); + AuctionHouse.getGuiManager().showGUI(player, new GUIAdminExpired(player, target)); break; case "endall": if (!sender.hasPermission("auctionhouse.cmd.admin.endall")) return ReturnType.FAILURE; - for (UUID id : instance.getAuctionItemManager().getItems().keySet()) { - instance.getAuctionItemManager().getItems().get(id).setExpired(true); + for (UUID id : AuctionHouse.getAuctionItemManager().getItems().keySet()) { + AuctionHouse.getAuctionItemManager().getItems().get(id).setExpired(true); } - instance.getLocale().getMessage("general.endedallauctions").sendPrefixedMessage(sender); + AuctionHouse.getInstance().getLocale().getMessage("general.endedallauctions").sendPrefixedMessage(sender); break; case "bans": if (!(sender instanceof Player)) break; player = (Player) sender; if (!player.hasPermission("auctionhouse.cmd.admin.bans")) return ReturnType.FAILURE; - instance.getGuiManager().showGUI(player, new GUIBans(player)); + AuctionHouse.getGuiManager().showGUI(player, new GUIBans(player)); break; case "relistall": if (!sender.hasPermission("auctionhouse.cmd.admin.relistall")) return ReturnType.FAILURE; - for (UUID id : instance.getAuctionItemManager().getItems().keySet()) { - if (instance.getAuctionItemManager().getItems().get(id).isExpired()) { - int relistTime = args.length == 1 ? instance.getAuctionItemManager().getItems().get(id).isBidItem() ? Settings.DEFAULT_AUCTION_LISTING_TIME.getInt() : Settings.DEFAULT_BIN_LISTING_TIME.getInt() : Integer.parseInt(args[1]); + for (UUID id : AuctionHouse.getAuctionItemManager().getItems().keySet()) { + if (AuctionHouse.getAuctionItemManager().getItems().get(id).isExpired()) { + int relistTime = args.length == 1 ? AuctionHouse.getAuctionItemManager().getItems().get(id).isBidItem() ? Settings.DEFAULT_AUCTION_LISTING_TIME.getInt() : Settings.DEFAULT_BIN_LISTING_TIME.getInt() : Integer.parseInt(args[1]); - instance.getAuctionItemManager().getItems().get(id).setExpiresAt(System.currentTimeMillis() + 1000L * relistTime); - instance.getAuctionItemManager().getItems().get(id).setExpired(false); + AuctionHouse.getAuctionItemManager().getItems().get(id).setExpiresAt(System.currentTimeMillis() + 1000L * relistTime); + AuctionHouse.getAuctionItemManager().getItems().get(id).setExpired(false); } } - instance.getLocale().getMessage("general.relisteditems").sendPrefixedMessage(sender); + AuctionHouse.getInstance().getLocale().getMessage("general.relisteditems").sendPrefixedMessage(sender); break; case "clearall": if (!sender.hasPermission("auctionhouse.cmd.admin.clearall")) return ReturnType.FAILURE; // Don't tell ppl that this exists - instance.getAuctionItemManager().getItems().clear(); + AuctionHouse.getAuctionItemManager().getItems().clear(); break; case "clear": if (args.length < 4) return ReturnType.FAILURE; @@ -171,29 +170,29 @@ public class CommandAdmin extends AbstractCommand { ItemStack itemToSell = PlayerHelper.getHeldItem(player).clone(); if (itemToSell.getType() == XMaterial.AIR.parseMaterial() && Settings.SELL_MENU_REQUIRES_USER_TO_HOLD_ITEM.getBoolean()) { - instance.getLocale().getMessage("general.air").sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("general.air").sendPrefixedMessage(player); return ReturnType.FAILURE; } else { - final AuctionPlayer auctionPlayer = instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()); + final AuctionPlayer auctionPlayer = AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()); if (Settings.SELL_MENU_SKIPS_TYPE_SELECTION.getBoolean()) { if (Settings.FORCE_AUCTION_USAGE.getBoolean()) { - AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, ListingType.AUCTION)); + AuctionHouse.getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, ListingType.AUCTION)); return ReturnType.SUCCESS; } if (!Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean()) { - AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, ListingType.BIN)); + AuctionHouse.getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, ListingType.BIN)); return ReturnType.SUCCESS; } - AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUISellListingType(auctionPlayer, selected -> { - AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, selected)); + AuctionHouse.getGuiManager().showGUI(player, new GUISellListingType(auctionPlayer, selected -> { + AuctionHouse.getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, selected)); })); } else { - instance.getGuiManager().showGUI(player, new GUISellListingType(auctionPlayer, selected -> { - instance.getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, selected)); + AuctionHouse.getGuiManager().showGUI(player, new GUISellListingType(auctionPlayer, selected -> { + AuctionHouse.getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, selected)); })); } } @@ -207,12 +206,12 @@ public class CommandAdmin extends AbstractCommand { if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE; - if (instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()) == null) { - instance.getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); - instance.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player)); + if (AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()) == null) { + AuctionHouse.getInstance().getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); + AuctionHouse.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player)); } - instance.getGuiManager().showGUI(player, new GUIAuctionHouse(instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()))); + AuctionHouse.getGuiManager().showGUI(player, new GUIAuctionHouse(AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()))); break; } @@ -244,7 +243,7 @@ public class CommandAdmin extends AbstractCommand { } private void handleUserBidClear(final Player player, final boolean returnMoney) { - final List items = AuctionHouse.getInstance().getAuctionItemManager().getHighestBidItems(player); + final List items = AuctionHouse.getAuctionItemManager().getHighestBidItems(player); for (AuctionedItem auctionedItem : items) { auctionedItem.setHighestBidder(auctionedItem.getOwner()); @@ -252,7 +251,7 @@ public class CommandAdmin extends AbstractCommand { if (returnMoney && Settings.BIDDING_TAKES_MONEY.getBoolean()) if (Settings.STORE_PAYMENTS_FOR_MANUAL_COLLECTION.getBoolean()) - AuctionHouse.getInstance().getDataManager().insertAuctionPayment(new AuctionPayment( + AuctionHouse.getDataManager().insertAuctionPayment(new AuctionPayment( player.getUniqueId(), auctionedItem.getCurrentPrice(), auctionedItem.getItem(), @@ -265,13 +264,13 @@ public class CommandAdmin extends AbstractCommand { } private void handleUserClear(final Player player, final boolean returnBids, final boolean giveItemsBack) { - final AuctionPlayer auctionPlayer = AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(player.getUniqueId()); + final AuctionPlayer auctionPlayer = AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()); final List items = auctionPlayer.getAllItems(); for (AuctionedItem auctionItem : items) { if (auctionItem.isExpired()) { if (!giveItemsBack) - AuctionHouse.getInstance().getAuctionItemManager().sendToGarbage(auctionItem); + AuctionHouse.getAuctionItemManager().sendToGarbage(auctionItem); continue; } @@ -280,7 +279,7 @@ public class CommandAdmin extends AbstractCommand { final OfflinePlayer oldBidder = Bukkit.getOfflinePlayer(auctionItem.getHighestBidder()); if (Settings.STORE_PAYMENTS_FOR_MANUAL_COLLECTION.getBoolean()) - AuctionHouse.getInstance().getDataManager().insertAuctionPayment(new AuctionPayment( + AuctionHouse.getDataManager().insertAuctionPayment(new AuctionPayment( oldBidder.getUniqueId(), auctionItem.getCurrentPrice(), auctionItem.getItem(), @@ -300,7 +299,7 @@ public class CommandAdmin extends AbstractCommand { auctionItem.setExpiresAt(System.currentTimeMillis()); auctionItem.setExpired(true); } else { - AuctionHouse.getInstance().getAuctionItemManager().sendToGarbage(auctionItem); + AuctionHouse.getAuctionItemManager().sendToGarbage(auctionItem); } } } diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandAuctionHouse.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandAuctionHouse.java index 0bd285c..6b2047f 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandAuctionHouse.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandAuctionHouse.java @@ -21,6 +21,7 @@ package ca.tweetzy.auctionhouse.commands; import ca.tweetzy.auctionhouse.AuctionHouse; import ca.tweetzy.auctionhouse.auction.AuctionPlayer; import ca.tweetzy.auctionhouse.guis.core.GUIAuctionHouse; +import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.commands.AbstractCommand; import ca.tweetzy.core.utils.TextUtils; import org.apache.commons.lang.StringUtils; @@ -40,7 +41,7 @@ import java.util.stream.Collectors; public class CommandAuctionHouse extends AbstractCommand { public CommandAuctionHouse() { - super(CommandType.PLAYER_ONLY, "auctionhouse"); + super(CommandType.PLAYER_ONLY, Settings.CMD_ALIAS_MAIN.getStringList().toArray(new String[0])); } @Override diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandBan.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandBan.java index 37c14ec..38e9b56 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandBan.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandBan.java @@ -21,6 +21,7 @@ package ca.tweetzy.auctionhouse.commands; import ca.tweetzy.auctionhouse.AuctionHouse; import ca.tweetzy.auctionhouse.guis.admin.bans.GUIBanUser; import ca.tweetzy.auctionhouse.guis.selector.GUIPlayerSelector; +import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.commands.AbstractCommand; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; @@ -38,23 +39,22 @@ import java.util.stream.Collectors; public class CommandBan extends AbstractCommand { public CommandBan() { - super(CommandType.PLAYER_ONLY, "ban"); + super(CommandType.PLAYER_ONLY, Settings.CMD_ALIAS_SUB_BAN.getStringList().toArray(new String[0])); } @Override protected ReturnType runCommand(CommandSender sender, String... args) { final Player player = (Player) sender; - final AuctionHouse instance = AuctionHouse.getInstance(); if (args.length == 0) { // open the player picker then redirect to the ban user menu - instance.getGuiManager().showGUI(player, new GUIPlayerSelector(player, selected -> { - if (instance.getBanManager().isBannedAlready(selected)) { - instance.getLocale().getMessage("ban.user already banned").processPlaceholder("player_name", selected.getName()).sendPrefixedMessage(player); + AuctionHouse.getGuiManager().showGUI(player, new GUIPlayerSelector(player, selected -> { + if (AuctionHouse.getBanManager().isBannedAlready(selected)) { + AuctionHouse.getInstance().getLocale().getMessage("ban.user already banned").processPlaceholder("player_name", selected.getName()).sendPrefixedMessage(player); return; } - instance.getGuiManager().showGUI(player, new GUIBanUser(player, instance.getBanManager().generateEmptyBan(player, selected))); + AuctionHouse.getGuiManager().showGUI(player, new GUIBanUser(player, AuctionHouse.getBanManager().generateEmptyBan(player, selected))); })); return ReturnType.SUCCESS; } @@ -62,16 +62,16 @@ public class CommandBan extends AbstractCommand { final Player target = Bukkit.getPlayerExact(args[0]); if (target == null) { - instance.getLocale().getMessage("general.playernotfound").processPlaceholder("player", args[0]).sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("general.playernotfound").processPlaceholder("player", args[0]).sendPrefixedMessage(player); return ReturnType.FAILURE; } - if (instance.getBanManager().isBannedAlready(target)) { - instance.getLocale().getMessage("ban.user already banned").processPlaceholder("player_name", args[0]).sendPrefixedMessage(player); + if (AuctionHouse.getBanManager().isBannedAlready(target)) { + AuctionHouse.getInstance().getLocale().getMessage("ban.user already banned").processPlaceholder("player_name", args[0]).sendPrefixedMessage(player); return ReturnType.FAILURE; } - instance.getGuiManager().showGUI(player, new GUIBanUser(player, instance.getBanManager().generateEmptyBan(player, target))); + AuctionHouse.getGuiManager().showGUI(player, new GUIBanUser(player, AuctionHouse.getBanManager().generateEmptyBan(player, target))); return ReturnType.SUCCESS; } diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandBids.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandBids.java index 0d958a2..8316ca9 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandBids.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandBids.java @@ -21,6 +21,7 @@ package ca.tweetzy.auctionhouse.commands; import ca.tweetzy.auctionhouse.AuctionHouse; import ca.tweetzy.auctionhouse.auction.AuctionPlayer; import ca.tweetzy.auctionhouse.guis.core.bid.GUIActiveBids; +import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.commands.AbstractCommand; import ca.tweetzy.core.utils.TextUtils; import org.bukkit.Bukkit; @@ -38,7 +39,7 @@ import java.util.List; public class CommandBids extends AbstractCommand { public CommandBids() { - super(CommandType.PLAYER_ONLY, "bids"); + super(CommandType.PLAYER_ONLY, Settings.CMD_ALIAS_SUB_BIDS.getStringList().toArray(new String[0])); } @Override @@ -47,12 +48,11 @@ public class CommandBids extends AbstractCommand { if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE; - final AuctionHouse instance = AuctionHouse.getInstance(); - if (instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()) == null) { - instance.getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); - instance.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player)); + if (AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()) == null) { + AuctionHouse.getInstance().getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); + AuctionHouse.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player)); } - instance.getGuiManager().showGUI(player, new GUIActiveBids(instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()))); + AuctionHouse.getGuiManager().showGUI(player, new GUIActiveBids(AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()))); return ReturnType.SUCCESS; } diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandConfirm.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandConfirm.java index 1bed8d1..04ee2a4 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandConfirm.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandConfirm.java @@ -40,7 +40,7 @@ import java.util.List; public class CommandConfirm extends AbstractCommand { public CommandConfirm() { - super(CommandType.PLAYER_ONLY, "confirm"); + super(CommandType.PLAYER_ONLY, Settings.CMD_ALIAS_SUB_CONFIRM.getStringList().toArray(new String[0])); } @Override @@ -49,27 +49,25 @@ public class CommandConfirm extends AbstractCommand { if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE; - final AuctionHouse instance = AuctionHouse.getInstance(); - - if (instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()) == null) { - instance.getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); - instance.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player)); + if (AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()) == null) { + AuctionHouse.getInstance().getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); + AuctionHouse.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player)); } - final AuctionPlayer auctionPlayer = instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()); + final AuctionPlayer auctionPlayer = AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()); if (auctionPlayer.getEndAllRequestTime() == -1) { - instance.getLocale().getMessage("general.nothing to confirm").sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("general.nothing to confirm").sendPrefixedMessage(player); return ReturnType.SUCCESS; } if (System.currentTimeMillis() > auctionPlayer.getEndAllRequestTime()) { - instance.getLocale().getMessage("general.confirm time limit reached").sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("general.confirm time limit reached").sendPrefixedMessage(player); return ReturnType.SUCCESS; } if (System.currentTimeMillis() <= auctionPlayer.getEndAllRequestTime()) { - instance.getLocale().getMessage("general.confirmed cancellation").sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("general.confirmed cancellation").sendPrefixedMessage(player); auctionPlayer.setEndAllRequestTime(-1); Titles.clearTitle(player); @@ -78,7 +76,7 @@ public class CommandConfirm extends AbstractCommand { continue; if (item.isRequest()) { - AuctionHouse.getInstance().getAuctionItemManager().sendToGarbage(item); + AuctionHouse.getAuctionItemManager().sendToGarbage(item); } else { item.setExpired(true); } diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandExpired.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandExpired.java index 2dfcf7c..f1ebaeb 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandExpired.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandExpired.java @@ -21,6 +21,7 @@ package ca.tweetzy.auctionhouse.commands; import ca.tweetzy.auctionhouse.AuctionHouse; import ca.tweetzy.auctionhouse.auction.AuctionPlayer; import ca.tweetzy.auctionhouse.guis.core.GUIExpiredItems; +import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.commands.AbstractCommand; import ca.tweetzy.core.utils.TextUtils; import org.bukkit.Bukkit; @@ -37,12 +38,8 @@ import java.util.List; */ public class CommandExpired extends AbstractCommand { - final AuctionHouse instance; - - public CommandExpired() { - super(CommandType.PLAYER_ONLY, "expired"); - instance = AuctionHouse.getInstance(); + super(CommandType.PLAYER_ONLY, Settings.CMD_ALIAS_SUB_EXPIRED.getStringList().toArray(new String[0])); } @Override @@ -50,12 +47,12 @@ public class CommandExpired extends AbstractCommand { final Player player = (Player) sender; if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE; - if (instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()) == null) { - instance.getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); - instance.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player)); + if (AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()) == null) { + AuctionHouse.getInstance().getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); + AuctionHouse.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player)); } - instance.getGuiManager().showGUI(player, new GUIExpiredItems(null, instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()))); + AuctionHouse.getGuiManager().showGUI(player, new GUIExpiredItems(null, AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()))); return ReturnType.SUCCESS; } @@ -66,12 +63,12 @@ public class CommandExpired extends AbstractCommand { @Override public String getSyntax() { - return instance.getLocale().getMessage("commands.syntax.expired").getMessage(); + return AuctionHouse.getInstance().getLocale().getMessage("commands.syntax.expired").getMessage(); } @Override public String getDescription() { - return instance.getLocale().getMessage("commands.description.expired").getMessage(); + return AuctionHouse.getInstance().getLocale().getMessage("commands.description.expired").getMessage(); } @Override diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandFilter.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandFilter.java index de4e536..c31f140 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandFilter.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandFilter.java @@ -24,6 +24,7 @@ import ca.tweetzy.auctionhouse.auction.AuctionFilterItem; import ca.tweetzy.auctionhouse.auction.enums.AuctionItemCategory; import ca.tweetzy.auctionhouse.guis.filter.GUIFilterWhitelist; import ca.tweetzy.auctionhouse.helpers.PlayerHelper; +import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.commands.AbstractCommand; import ca.tweetzy.core.compatibility.XMaterial; import org.bukkit.command.CommandSender; @@ -44,7 +45,7 @@ import java.util.stream.Collectors; public class CommandFilter extends AbstractCommand { public CommandFilter() { - super(CommandType.PLAYER_ONLY, "filter"); + super(CommandType.PLAYER_ONLY, Settings.CMD_ALIAS_SUB_FILTER.getStringList().toArray(new String[0])); } @Override @@ -52,9 +53,8 @@ public class CommandFilter extends AbstractCommand { final Player player = (Player) sender; // if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE; - final AuctionHouse instance = AuctionHouse.getInstance(); if (args.length == 0) { - instance.getGuiManager().showGUI(player, new GUIFilterWhitelist(player)); + AuctionHouse.getGuiManager().showGUI(player, new GUIFilterWhitelist(player)); return ReturnType.SUCCESS; } @@ -71,19 +71,19 @@ public class CommandFilter extends AbstractCommand { ItemStack held = PlayerHelper.getHeldItem(player); if (held.getType() == XMaterial.AIR.parseMaterial()) { - instance.getLocale().getMessage("general.filter air").sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("general.filter air").sendPrefixedMessage(player); return ReturnType.FAILURE; } - if (instance.getFilterManager().getFilteredItem(held) != null && instance.getFilterManager().getFilteredItem(held).getCategory() == AuctionItemCategory.valueOf(args[1].toUpperCase())) { - instance.getLocale().getMessage("general.filteritemaddedalready").sendPrefixedMessage(player); + if (AuctionHouse.getFilterManager().getFilteredItem(held) != null && AuctionHouse.getFilterManager().getFilteredItem(held).getCategory() == AuctionItemCategory.valueOf(args[1].toUpperCase())) { + AuctionHouse.getInstance().getLocale().getMessage("general.filteritemaddedalready").sendPrefixedMessage(player); return ReturnType.FAILURE; } AuctionFilterItem filterItem = new AuctionFilterItem(held, AuctionItemCategory.valueOf(args[1].toUpperCase())); - instance.getFilterManager().addFilterItem(filterItem); - instance.getLocale().getMessage("general.addeditemtofilterwhitelist").processPlaceholder("item_name", AuctionAPI.getInstance().getItemName(held)).processPlaceholder("filter_category", args[1]).sendPrefixedMessage(player); + AuctionHouse.getFilterManager().addFilterItem(filterItem); + AuctionHouse.getInstance().getLocale().getMessage("general.addeditemtofilterwhitelist").processPlaceholder("item_name", AuctionAPI.getInstance().getItemName(held)).processPlaceholder("filter_category", args[1]).sendPrefixedMessage(player); } } diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandMarkChest.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandMarkChest.java index c065ba3..eaca8e4 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandMarkChest.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandMarkChest.java @@ -19,6 +19,7 @@ package ca.tweetzy.auctionhouse.commands; import ca.tweetzy.auctionhouse.AuctionHouse; +import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.commands.AbstractCommand; import ca.tweetzy.core.compatibility.XMaterial; import ca.tweetzy.flight.comp.enums.ServerVersion; @@ -40,7 +41,7 @@ import java.util.List; public final class CommandMarkChest extends AbstractCommand { public CommandMarkChest() { - super(CommandType.PLAYER_ONLY, "markchest"); + super(CommandType.PLAYER_ONLY, Settings.CMD_ALIAS_SUB_MARKCHEST.getStringList().toArray(new String[0])); } @Override diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandMiddleware.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandMiddleware.java index 296c3c4..892f8e3 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandMiddleware.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandMiddleware.java @@ -46,8 +46,6 @@ public final class CommandMiddleware { } if (Settings.USE_AUCTION_CHEST_MODE.getBoolean() && !player.hasPermission("auctionhouse.auctionchestbypass")) { - - instance.getLocale().getMessage("general.visit auction chest").sendPrefixedMessage(player); return AbstractCommand.ReturnType.FAILURE; } diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandMinPrice.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandMinPrice.java index 1888739..6640755 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandMinPrice.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandMinPrice.java @@ -23,6 +23,7 @@ import ca.tweetzy.auctionhouse.api.AuctionAPI; import ca.tweetzy.auctionhouse.auction.MinItemPrice; import ca.tweetzy.auctionhouse.guis.admin.GUIMinItemPrices; import ca.tweetzy.auctionhouse.helpers.PlayerHelper; +import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.commands.AbstractCommand; import ca.tweetzy.core.compatibility.XMaterial; import ca.tweetzy.core.utils.NumberUtils; @@ -42,17 +43,15 @@ import java.util.List; public class CommandMinPrice extends AbstractCommand { public CommandMinPrice() { - super(CommandType.PLAYER_ONLY, "minprices"); + super(CommandType.PLAYER_ONLY, Settings.CMD_ALIAS_SUB_MINPRICE.getStringList().toArray(new String[0])); } @Override protected ReturnType runCommand(CommandSender sender, String... args) { final Player player = (Player) sender; // if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE; - - final AuctionHouse instance = AuctionHouse.getInstance(); if (args.length == 0) { - instance.getGuiManager().showGUI(player, new GUIMinItemPrices(player)); + AuctionHouse.getGuiManager().showGUI(player, new GUIMinItemPrices(player)); return ReturnType.SUCCESS; } @@ -61,26 +60,26 @@ public class CommandMinPrice extends AbstractCommand { ItemStack held = PlayerHelper.getHeldItem(player); if (held.getType() == XMaterial.AIR.parseMaterial()) { - instance.getLocale().getMessage("general.min item price air").sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("general.min item price air").sendPrefixedMessage(player); return ReturnType.FAILURE; } - if (instance.getMinItemPriceManager().getMinPrice(held.clone()) != null) { - instance.getLocale().getMessage("general.min price already added").sendPrefixedMessage(player); + if (AuctionHouse.getMinItemPriceManager().getMinPrice(held.clone()) != null) { + AuctionHouse.getInstance().getLocale().getMessage("general.min price already added").sendPrefixedMessage(player); return ReturnType.FAILURE; } if (!NumberUtils.isNumeric(args[1])) { - instance.getLocale().getMessage("general.notanumber").processPlaceholder("value", args[1]).sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("general.notanumber").processPlaceholder("value", args[1]).sendPrefixedMessage(player); return ReturnType.FAILURE; } final double price = Double.parseDouble(args[1]); - instance.getDataManager().insertMinPrice(new MinItemPrice(held.clone(), price), (error, inserted) -> { + AuctionHouse.getDataManager().insertMinPrice(new MinItemPrice(held.clone(), price), (error, inserted) -> { if (error == null) { - instance.getMinItemPriceManager().addItem(inserted); - instance.getLocale().getMessage("general.added min price") + AuctionHouse.getMinItemPriceManager().addItem(inserted); + AuctionHouse.getInstance().getLocale().getMessage("general.added min price") .processPlaceholder("item", AuctionAPI.getInstance().getItemName(inserted.getItemStack())) .processPlaceholder("price", AuctionAPI.getInstance().formatNumber(inserted.getPrice())) .sendPrefixedMessage(player); diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandPayments.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandPayments.java index 2d50321..4bce0c9 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandPayments.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandPayments.java @@ -21,6 +21,7 @@ package ca.tweetzy.auctionhouse.commands; import ca.tweetzy.auctionhouse.AuctionHouse; import ca.tweetzy.auctionhouse.auction.AuctionPlayer; import ca.tweetzy.auctionhouse.guis.core.GUIPaymentCollection; +import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.commands.AbstractCommand; import ca.tweetzy.core.utils.TextUtils; import org.bukkit.Bukkit; @@ -38,7 +39,7 @@ import java.util.List; public class CommandPayments extends AbstractCommand { public CommandPayments() { - super(CommandType.PLAYER_ONLY, "payments"); + super(CommandType.PLAYER_ONLY, Settings.CMD_ALIAS_SUB_PAYMENTS.getStringList().toArray(new String[0])); } @Override @@ -47,12 +48,12 @@ public class CommandPayments extends AbstractCommand { if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE; - final AuctionHouse instance = AuctionHouse.getInstance(); - if (instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()) == null) { - instance.getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); - instance.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player)); + if (AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()) == null) { + AuctionHouse.getInstance().getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); + AuctionHouse.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player)); } - instance.getGuiManager().showGUI(player, new GUIPaymentCollection(null, instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()))); + + AuctionHouse.getGuiManager().showGUI(player, new GUIPaymentCollection(null, AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()))); return ReturnType.SUCCESS; } diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandRequest.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandRequest.java index 4a636d9..d6ef3d1 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandRequest.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandRequest.java @@ -49,40 +49,39 @@ import java.util.List; public class CommandRequest extends AbstractCommand { public CommandRequest() { - super(CommandType.PLAYER_ONLY, "request"); + super(CommandType.PLAYER_ONLY, Settings.CMD_ALIAS_SUB_REQUEST.getStringList().toArray(new String[0])); } @Override protected ReturnType runCommand(CommandSender sender, String... args) { final Player player = (Player) sender; - final AuctionHouse instance = AuctionHouse.getInstance(); if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE; - if (AuctionHouse.getInstance().getBanManager().isStillBanned(player, BanType.EVERYTHING, BanType.REQUESTS)) return ReturnType.FAILURE; + if (AuctionHouse.getBanManager().isStillBanned(player, BanType.EVERYTHING, BanType.REQUESTS)) return ReturnType.FAILURE; - if (instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()) == null) { - instance.getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); - instance.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player)); + if (AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()) == null) { + AuctionHouse.getInstance().getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); + AuctionHouse.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player)); } - final AuctionPlayer auctionPlayer = instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()); + final AuctionPlayer auctionPlayer = AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()); // grab held item & check valid final ItemStack originalItem = PlayerHelper.getHeldItem(player).clone(); if (originalItem.getType() == XMaterial.AIR.parseMaterial()) { - instance.getLocale().getMessage("general.air").sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("general.air").sendPrefixedMessage(player); return ReturnType.FAILURE; } if (args.length < 1) { - instance.getGuiManager().showGUI(player, new GUIRequestItem(auctionPlayer, originalItem, originalItem.getAmount(), 1)); + AuctionHouse.getGuiManager().showGUI(player, new GUIRequestItem(auctionPlayer, originalItem, originalItem.getAmount(), 1)); return ReturnType.SUCCESS; } // check if price is even a number if (!NumberUtils.isDouble(args[0])) { - instance.getLocale().getMessage("general.notanumber").processPlaceholder("value", args[0]).sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("general.notanumber").processPlaceholder("value", args[0]).sendPrefixedMessage(player); return ReturnType.FAILURE; } @@ -91,7 +90,7 @@ public class CommandRequest extends AbstractCommand { // check if at limit if (auctionPlayer.isAtItemLimit(player)) { - instance.getLocale().getMessage("general.requestlimit").sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("general.requestlimit").sendPrefixedMessage(player); return ReturnType.FAILURE; } @@ -107,47 +106,28 @@ public class CommandRequest extends AbstractCommand { final double price = Double.parseDouble(args[0]); if (price < Settings.MIN_AUCTION_PRICE.getDouble()) { - instance.getLocale().getMessage("pricing.minbaseprice").processPlaceholder("price", Settings.MIN_AUCTION_PRICE.getDouble()).sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("pricing.minbaseprice").processPlaceholder("price", Settings.MIN_AUCTION_PRICE.getDouble()).sendPrefixedMessage(player); return ReturnType.FAILURE; } if (price > Settings.MAX_AUCTION_PRICE.getDouble()) { - instance.getLocale().getMessage("pricing.maxbaseprice").processPlaceholder("price", Settings.MIN_AUCTION_PRICE.getDouble()).sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("pricing.maxbaseprice").processPlaceholder("price", Settings.MIN_AUCTION_PRICE.getDouble()).sendPrefixedMessage(player); return ReturnType.FAILURE; } AuctionedItem auctionedItem = AuctionedItem.createRequest(player, originalItem, originalItem.getAmount(), price, allowedTime); - // TODO REMOVE THIS -// auctionedItem.setId(UUID.randomUUID()); -// auctionedItem.setOwner(player.getUniqueId()); -// auctionedItem.setHighestBidder(player.getUniqueId()); -// auctionedItem.setOwnerName(player.getName()); -// auctionedItem.setHighestBidderName(player.getName()); -// auctionedItem.setBasePrice(price); -// auctionedItem.setItem(originalItem.clone()); -// auctionedItem.setCategory(MaterialCategorizer.getMaterialCategory(originalItem)); -// auctionedItem.setExpiresAt(System.currentTimeMillis() + 1000L * allowedTime); -// auctionedItem.setBidItem(false); -// auctionedItem.setServerItem(false); -// auctionedItem.setExpired(false); -// auctionedItem.setListedWorld(player.getWorld().getName()); -// auctionedItem.setInfinite(false); -// auctionedItem.setAllowPartialBuy(false); -// auctionedItem.setRequest(true); -// auctionedItem.setRequestAmount(originalItem.getAmount()); - - AuctionHouse.getInstance().getAuctionPlayerManager().addToSellProcess(player); + AuctionHouse.getAuctionPlayerManager().addToSellProcess(player); if (auctionPlayer.getPlayer() == null || !auctionPlayer.getPlayer().isOnline()) { return ReturnType.FAILURE; } AuctionCreator.create(auctionPlayer, auctionedItem, (auction, listingResult) -> { - AuctionHouse.getInstance().getAuctionPlayerManager().processSell(player); + AuctionHouse.getAuctionPlayerManager().processSell(player); if (Settings.OPEN_MAIN_AUCTION_HOUSE_AFTER_MENU_LIST.getBoolean()) { player.removeMetadata("AuctionHouseConfirmListing", AuctionHouse.getInstance()); - instance.getGuiManager().showGUI(player, new GUIAuctionHouse(auctionPlayer)); + AuctionHouse.getGuiManager().showGUI(player, new GUIAuctionHouse(auctionPlayer)); } else AuctionHouse.newChain().sync(player::closeInventory).execute(); }); diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSearch.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSearch.java index b425fe9..fabb8ef 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSearch.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSearch.java @@ -21,6 +21,7 @@ package ca.tweetzy.auctionhouse.commands; import ca.tweetzy.auctionhouse.AuctionHouse; import ca.tweetzy.auctionhouse.auction.AuctionPlayer; import ca.tweetzy.auctionhouse.guis.core.GUIAuctionHouse; +import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.commands.AbstractCommand; import ca.tweetzy.core.utils.TextUtils; import org.bukkit.Bukkit; @@ -38,7 +39,7 @@ import java.util.List; public class CommandSearch extends AbstractCommand { public CommandSearch() { - super(CommandType.PLAYER_ONLY, "search"); + super(CommandType.PLAYER_ONLY, Settings.CMD_ALIAS_SUB_SEARCH.getStringList().toArray(new String[0])); } @Override @@ -53,13 +54,12 @@ public class CommandSearch extends AbstractCommand { builder.append(arg).append(" "); } - final AuctionHouse instance = AuctionHouse.getInstance(); - if (instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()) == null) { - instance.getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); - instance.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player)); + if (AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()) == null) { + AuctionHouse.getInstance().getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); + AuctionHouse.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player)); } - instance.getGuiManager().showGUI(player, new GUIAuctionHouse(instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()), builder.toString().trim())); + AuctionHouse.getGuiManager().showGUI(player, new GUIAuctionHouse(AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()), builder.toString().trim())); return ReturnType.SUCCESS; } diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java index d5543e3..f2c7392 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java @@ -61,7 +61,7 @@ import java.util.UUID; public final class CommandSell extends AbstractCommand { public CommandSell() { - super(CommandType.PLAYER_ONLY, "sell"); + super(CommandType.PLAYER_ONLY, Settings.CMD_ALIAS_SUB_SELL.getStringList().toArray(new String[0])); } @Override @@ -69,15 +69,15 @@ public final class CommandSell extends AbstractCommand { Player player = (Player) sender; if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE; - if (AuctionHouse.getInstance().getBanManager().isStillBanned(player, BanType.EVERYTHING, BanType.SELL)) return ReturnType.FAILURE; + if (AuctionHouse.getBanManager().isStillBanned(player, BanType.EVERYTHING, BanType.SELL)) return ReturnType.FAILURE; - final AuctionHouse instance = AuctionHouse.getInstance(); - if (instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()) == null) { - instance.getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); - instance.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player)); + + if (AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()) == null) { + AuctionHouse.getInstance().getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); + AuctionHouse.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player)); } - AuctionPlayer auctionPlayer = instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()); + AuctionPlayer auctionPlayer = AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()); if (!Bukkit.getOfflinePlayer(player.getUniqueId()).isOnline()) return ReturnType.FAILURE; @@ -97,28 +97,28 @@ public final class CommandSell extends AbstractCommand { } if (itemToSell.getType() == XMaterial.AIR.parseMaterial() && Settings.SELL_MENU_REQUIRES_USER_TO_HOLD_ITEM.getBoolean()) { - instance.getLocale().getMessage("general.air").sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("general.air").sendPrefixedMessage(player); return ReturnType.FAILURE; } else { if (Settings.SELL_MENU_SKIPS_TYPE_SELECTION.getBoolean()) { if (Settings.FORCE_AUCTION_USAGE.getBoolean()) { - instance.getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, ListingType.AUCTION)); + AuctionHouse.getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, ListingType.AUCTION)); return ReturnType.SUCCESS; } if (!Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean()) { - instance.getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, ListingType.BIN)); + AuctionHouse.getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, ListingType.BIN)); return ReturnType.SUCCESS; } - instance.getGuiManager().showGUI(player, new GUISellListingType(auctionPlayer, selected -> { - instance.getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, selected)); + AuctionHouse.getGuiManager().showGUI(player, new GUISellListingType(auctionPlayer, selected -> { + AuctionHouse.getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, selected)); })); } else { - instance.getGuiManager().showGUI(player, new GUISellListingType(auctionPlayer, selected -> { - instance.getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, selected)); + AuctionHouse.getGuiManager().showGUI(player, new GUISellListingType(auctionPlayer, selected -> { + AuctionHouse.getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, selected)); })); } @@ -127,7 +127,7 @@ public final class CommandSell extends AbstractCommand { } if (itemToSell.getType() == XMaterial.AIR.parseMaterial()) { - instance.getLocale().getMessage("general.air").sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("general.air").sendPrefixedMessage(player); return ReturnType.FAILURE; } @@ -213,7 +213,7 @@ public final class CommandSell extends AbstractCommand { } // check buy now price null if (buyNowPrice == null) { - instance.getLocale().getMessage("general.please_enter_at_least_one_number").sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("general.please_enter_at_least_one_number").sendPrefixedMessage(player); return ReturnType.FAILURE; } @@ -222,7 +222,7 @@ public final class CommandSell extends AbstractCommand { // NOT USING THE BIDDING SYSTEM if (!isBiddingItem) { if (!AuctionAPI.getInstance().meetsMinItemPrice(isBundle, isBiddingItem, originalItem, buyNowPrice, isBiddingItem ? startingBid : 0)) { - instance.getLocale().getMessage("pricing.minitemprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(instance.getMinItemPriceManager().getMinPrice(originalItem).getPrice())).sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("pricing.minitemprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(AuctionHouse.getMinItemPriceManager().getMinPrice(originalItem).getPrice())).sendPrefixedMessage(player); return ReturnType.FAILURE; } @@ -232,7 +232,7 @@ public final class CommandSell extends AbstractCommand { if (isBiddingItem && startingBid != null) { if (!AuctionAPI.getInstance().meetsMinItemPrice(isBundle, isBiddingItem, originalItem, buyNowPrice, isBiddingItem ? startingBid : 0)) { - instance.getLocale().getMessage("pricing.minitemprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(instance.getMinItemPriceManager().getMinPrice(originalItem).getPrice())).sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("pricing.minitemprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(AuctionHouse.getMinItemPriceManager().getMinPrice(originalItem).getPrice())).sendPrefixedMessage(player); return ReturnType.FAILURE; } @@ -240,24 +240,24 @@ public final class CommandSell extends AbstractCommand { // check the starting bid values if (startingBid < Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble()) { - instance.getLocale().getMessage("pricing.minstartingprice").processPlaceholder("price", Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble()).sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("pricing.minstartingprice").processPlaceholder("price", Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble()).sendPrefixedMessage(player); return ReturnType.FAILURE; } if (startingBid > Settings.MAX_AUCTION_START_PRICE.getDouble()) { - instance.getLocale().getMessage("pricing.maxstartingprice").processPlaceholder("price", Settings.MAX_AUCTION_START_PRICE.getDouble()).sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("pricing.maxstartingprice").processPlaceholder("price", Settings.MAX_AUCTION_START_PRICE.getDouble()).sendPrefixedMessage(player); return ReturnType.FAILURE; } // if present check the bid increment pricing if (bidIncrement != null) { if (bidIncrement < Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble()) { - instance.getLocale().getMessage("pricing.minbidincrementprice").processPlaceholder("price", Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble()).sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("pricing.minbidincrementprice").processPlaceholder("price", Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble()).sendPrefixedMessage(player); return ReturnType.FAILURE; } if (bidIncrement > Settings.MAX_AUCTION_INCREMENT_PRICE.getDouble()) { - instance.getLocale().getMessage("pricing.maxbidincrementprice").processPlaceholder("price", Settings.MAX_AUCTION_START_PRICE.getDouble()).sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("pricing.maxbidincrementprice").processPlaceholder("price", Settings.MAX_AUCTION_START_PRICE.getDouble()).sendPrefixedMessage(player); return ReturnType.FAILURE; } } else { @@ -266,7 +266,7 @@ public final class CommandSell extends AbstractCommand { // check if the starting bid is not higher than the buy now if (Settings.BASE_PRICE_MUST_BE_HIGHER_THAN_BID_START.getBoolean() && startingBid > buyNowPrice && !(buyNowPrice <= -1)) { - instance.getLocale().getMessage("pricing.basepricetoolow").sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("pricing.basepricetoolow").sendPrefixedMessage(player); return ReturnType.FAILURE; } } @@ -280,7 +280,7 @@ public final class CommandSell extends AbstractCommand { } else { if (isBundle) { if (BundleUtil.isBundledItem(itemToSell)) { - instance.getLocale().getMessage("general.cannotsellbundleditem").sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("general.cannotsellbundleditem").sendPrefixedMessage(player); return ReturnType.FAILURE; } @@ -310,7 +310,7 @@ public final class CommandSell extends AbstractCommand { } if (isBundle) { - instance.getGuiManager().showGUI(player, new GUIBundleCreation( + AuctionHouse.getGuiManager().showGUI(player, new GUIBundleCreation( auctionPlayer, allowedTime, buyNowAllow, @@ -361,15 +361,15 @@ public final class CommandSell extends AbstractCommand { auctionedItem.setInfinite(isInfinite); auctionedItem.setAllowPartialBuy(partialBuy); - AuctionHouse.getInstance().getAuctionPlayerManager().addToSellProcess(player); + AuctionHouse.getAuctionPlayerManager().addToSellProcess(player); if (Settings.ASK_FOR_LISTING_CONFIRMATION.getBoolean()) { player.getInventory().setItemInHand(XMaterial.AIR.parseItem()); auctionPlayer.setItemBeingListed(auctionedItem.getItem()); - instance.getGuiManager().showGUI(player, new GUIListingConfirm(player, auctionedItem, result -> { + AuctionHouse.getGuiManager().showGUI(player, new GUIListingConfirm(player, auctionedItem, result -> { if (!result) { - AuctionHouse.getInstance().getAuctionPlayerManager().processSell(player); + AuctionHouse.getAuctionPlayerManager().processSell(player); player.closeInventory(); PlayerUtils.giveItem(player, auctionedItem.getCleanItem()); @@ -387,7 +387,7 @@ public final class CommandSell extends AbstractCommand { } AuctionCreator.create(auctionPlayer, auctionedItem, (auction, listingResult) -> { - AuctionHouse.getInstance().getAuctionPlayerManager().processSell(player); + AuctionHouse.getAuctionPlayerManager().processSell(player); if (listingResult != ListingResult.SUCCESS) { // PlayerUtils.giveItem(player, auction.getCleanItem()); @@ -397,7 +397,7 @@ public final class CommandSell extends AbstractCommand { if (Settings.OPEN_MAIN_AUCTION_HOUSE_AFTER_MENU_LIST.getBoolean()) { player.removeMetadata("AuctionHouseConfirmListing", AuctionHouse.getInstance()); - instance.getGuiManager().showGUI(player, new GUIAuctionHouse(auctionPlayer)); + AuctionHouse.getGuiManager().showGUI(player, new GUIAuctionHouse(auctionPlayer)); } else AuctionHouse.newChain().sync(player::closeInventory).execute(); }); @@ -417,7 +417,7 @@ public final class CommandSell extends AbstractCommand { player.getInventory().setItemInHand(XMaterial.AIR.parseItem()); AuctionCreator.create(auctionPlayer, auctionedItem, (auction, listingResult) -> { - AuctionHouse.getInstance().getAuctionPlayerManager().processSell(player); + AuctionHouse.getAuctionPlayerManager().processSell(player); if (listingResult != ListingResult.SUCCESS) { PlayerUtils.giveItem(player, auction.getItem()); @@ -427,7 +427,7 @@ public final class CommandSell extends AbstractCommand { if (Settings.OPEN_MAIN_AUCTION_HOUSE_AFTER_MENU_LIST.getBoolean()) { player.removeMetadata("AuctionHouseConfirmListing", AuctionHouse.getInstance()); - instance.getGuiManager().showGUI(player, new GUIAuctionHouse(auctionPlayer)); + AuctionHouse.getGuiManager().showGUI(player, new GUIAuctionHouse(auctionPlayer)); } else AuctionHouse.newChain().sync(player::closeInventory).execute(); }); diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSettings.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSettings.java index d37a27c..f87ede0 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSettings.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSettings.java @@ -47,8 +47,7 @@ public class CommandSettings extends AbstractCommand { Player player = (Player) sender; if (AuctionAPI.tellMigrationStatus(player)) return ReturnType.FAILURE; - final AuctionHouse instance = AuctionHouse.getInstance(); - instance.getGuiManager().showGUI(player, new PluginConfigGui(instance, instance.getLocale().getMessage("general.prefix").getMessage())); + AuctionHouse.getGuiManager().showGUI(player, new PluginConfigGui(AuctionHouse.getInstance(), AuctionHouse.getInstance().getLocale().getMessage("general.prefix").getMessage())); return ReturnType.SUCCESS; } diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandStats.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandStats.java index 0cda53a..91249e2 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandStats.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandStats.java @@ -22,6 +22,7 @@ import ca.tweetzy.auctionhouse.AuctionHouse; import ca.tweetzy.auctionhouse.auction.AuctionPlayer; import ca.tweetzy.auctionhouse.guis.statistics.GUIStatisticView; import ca.tweetzy.auctionhouse.guis.statistics.GUIStatisticViewSelect; +import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.commands.AbstractCommand; import ca.tweetzy.core.utils.TextUtils; import org.bukkit.Bukkit; @@ -39,7 +40,7 @@ import java.util.List; public class CommandStats extends AbstractCommand { public CommandStats() { - super(CommandType.PLAYER_ONLY, "stats"); + super(CommandType.PLAYER_ONLY, Settings.CMD_ALIAS_SUB_STATS.getStringList().toArray(new String[0])); } @Override @@ -47,31 +48,29 @@ public class CommandStats extends AbstractCommand { final Player player = (Player) sender; if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE; - - final AuctionHouse instance = AuctionHouse.getInstance(); - AuctionPlayer user = instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()); + AuctionPlayer user = AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()); if (user == null) { - instance.getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); + AuctionHouse.getInstance().getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); AuctionPlayer newAHPlayer = new AuctionPlayer(player); user = newAHPlayer; - instance.getAuctionPlayerManager().addPlayer(newAHPlayer); + AuctionHouse.getAuctionPlayerManager().addPlayer(newAHPlayer); } if (args.length == 0) { - instance.getGuiManager().showGUI(player, new GUIStatisticViewSelect(user)); + AuctionHouse.getGuiManager().showGUI(player, new GUIStatisticViewSelect(user)); return ReturnType.SUCCESS; } final Player target = Bukkit.getPlayerExact(args[0]); if (target == null) { - instance.getLocale().getMessage("general.playernotfound").processPlaceholder("player", args[0]).sendPrefixedMessage(sender); + AuctionHouse.getInstance().getLocale().getMessage("general.playernotfound").processPlaceholder("player", args[0]).sendPrefixedMessage(sender); return ReturnType.FAILURE; } - final AuctionPlayer targetAuctionPlayer = instance.getAuctionPlayerManager().getPlayer(target.getUniqueId()); - instance.getGuiManager().showGUI(player, new GUIStatisticView(user, targetAuctionPlayer)); + final AuctionPlayer targetAuctionPlayer = AuctionHouse.getAuctionPlayerManager().getPlayer(target.getUniqueId()); + AuctionHouse.getGuiManager().showGUI(player, new GUIStatisticView(user, targetAuctionPlayer)); return ReturnType.SUCCESS; } diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandToggleListInfo.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandToggleListInfo.java index e57be78..e2502f8 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandToggleListInfo.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandToggleListInfo.java @@ -20,6 +20,7 @@ package ca.tweetzy.auctionhouse.commands; import ca.tweetzy.auctionhouse.AuctionHouse; import ca.tweetzy.auctionhouse.auction.AuctionPlayer; +import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.commands.AbstractCommand; import ca.tweetzy.core.utils.TextUtils; import org.bukkit.Bukkit; @@ -38,7 +39,7 @@ import java.util.UUID; public class CommandToggleListInfo extends AbstractCommand { public CommandToggleListInfo() { - super(CommandType.PLAYER_ONLY, "togglelistinfo"); + super(CommandType.PLAYER_ONLY, Settings.CMD_ALIAS_SUB_TOGGLELISTINFO.getStringList().toArray(new String[0])); } @@ -46,15 +47,15 @@ public class CommandToggleListInfo extends AbstractCommand { protected ReturnType runCommand(CommandSender sender, String... args) { final Player player = (Player) sender; final UUID playerUUID = player.getUniqueId(); - final AuctionHouse instance = AuctionHouse.getInstance(); - if (instance.getAuctionPlayerManager().getPlayer(playerUUID) == null) { - instance.getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); - instance.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player)); + + if (AuctionHouse.getAuctionPlayerManager().getPlayer(playerUUID) == null) { + AuctionHouse.getInstance().getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); + AuctionHouse.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player)); } - final AuctionPlayer auctionPlayer = instance.getAuctionPlayerManager().getPlayer(playerUUID); + final AuctionPlayer auctionPlayer = AuctionHouse.getAuctionPlayerManager().getPlayer(playerUUID); auctionPlayer.setShowListingInfo(!auctionPlayer.isShowListingInfo()); - instance.getLocale().getMessage("general.toggled listing." + (auctionPlayer.isShowListingInfo() ? "on" : "off")).sendPrefixedMessage(player); + AuctionHouse.getInstance().getLocale().getMessage("general.toggled listing." + (auctionPlayer.isShowListingInfo() ? "on" : "off")).sendPrefixedMessage(player); return ReturnType.SUCCESS; } diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandTransactions.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandTransactions.java index 3a5dae1..dd967db 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandTransactions.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandTransactions.java @@ -41,7 +41,7 @@ import java.util.UUID; public class CommandTransactions extends AbstractCommand { public CommandTransactions() { - super(CommandType.PLAYER_ONLY, "transactions"); + super(CommandType.PLAYER_ONLY, Settings.CMD_ALIAS_SUB_TRANSACTIONS.getStringList().toArray(new String[0])); } @Override @@ -51,11 +51,11 @@ public class CommandTransactions extends AbstractCommand { if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE; if (args.length == 0) { - final AuctionHouse instance = AuctionHouse.getInstance(); + if (Settings.RESTRICT_ALL_TRANSACTIONS_TO_PERM.getBoolean() && !player.hasPermission("auctionhouse.transactions.viewall")) { - instance.getGuiManager().showGUI(player, new GUITransactionList(player, false)); + AuctionHouse.getGuiManager().showGUI(player, new GUITransactionList(player, false)); } else { - instance.getGuiManager().showGUI(player, new GUITransactionType(player)); + AuctionHouse.getGuiManager().showGUI(player, new GUITransactionType(player)); } return ReturnType.SUCCESS; @@ -77,7 +77,7 @@ public class CommandTransactions extends AbstractCommand { } UUID toLookup = target == null ? offlinePlayer.getUniqueId() : target.getUniqueId(); - AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUITransactionList(player, toLookup)); + AuctionHouse.getGuiManager().showGUI(player, new GUITransactionList(player, toLookup)); }).execute(); diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandUnban.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandUnban.java index 612f6ef..d18cc28 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandUnban.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandUnban.java @@ -22,6 +22,7 @@ import ca.tweetzy.auctionhouse.AuctionHouse; import ca.tweetzy.auctionhouse.api.AuctionAPI; import ca.tweetzy.auctionhouse.api.ban.Ban; import ca.tweetzy.auctionhouse.api.sync.SynchronizeResult; +import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.commands.AbstractCommand; import ca.tweetzy.core.utils.PlayerUtils; import org.bukkit.Bukkit; @@ -41,7 +42,7 @@ import java.util.UUID; public class CommandUnban extends AbstractCommand { public CommandUnban() { - super(CommandType.CONSOLE_OK, "unban"); + super(CommandType.CONSOLE_OK, Settings.CMD_ALIAS_SUB_UNBAN.getStringList().toArray(new String[0])); } @Override @@ -52,26 +53,25 @@ public class CommandUnban extends AbstractCommand { final Player target = PlayerUtils.findPlayer(args[0]); OfflinePlayer offlinePlayer = null; - final AuctionHouse instance = AuctionHouse.getInstance(); if (target == null) { offlinePlayer = Bukkit.getOfflinePlayer(args[0]); if (offlinePlayer == null || !offlinePlayer.hasPlayedBefore()) { - instance.getLocale().getMessage("general.playernotfound").processPlaceholder("player", args[0]).sendPrefixedMessage(sender); + AuctionHouse.getInstance().getLocale().getMessage("general.playernotfound").processPlaceholder("player", args[0]).sendPrefixedMessage(sender); return ReturnType.FAILURE; } } UUID toUnBan = target == null ? offlinePlayer.getUniqueId() : target.getUniqueId(); - if (!instance.getBanManager().getManagerContent().containsKey(toUnBan)) { - instance.getLocale().getMessage("ban.user not banned").processPlaceholder("player_name", args[0]).sendPrefixedMessage(sender); + if (!AuctionHouse.getBanManager().getManagerContent().containsKey(toUnBan)) { + AuctionHouse.getInstance().getLocale().getMessage("ban.user not banned").processPlaceholder("player_name", args[0]).sendPrefixedMessage(sender); return ReturnType.FAILURE; } - final Ban ban = instance.getBanManager().get(toUnBan); + final Ban ban = AuctionHouse.getBanManager().get(toUnBan); ban.unStore(result -> { if (result == SynchronizeResult.SUCCESS) { - instance.getLocale().getMessage("ban.user unbanned").processPlaceholder("player_name", args[0]).sendPrefixedMessage(sender); + AuctionHouse.getInstance().getLocale().getMessage("ban.user unbanned").processPlaceholder("player_name", args[0]).sendPrefixedMessage(sender); } }); diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandUpload.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandUpload.java index 393e27c..87025be 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandUpload.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandUpload.java @@ -59,23 +59,22 @@ public final class CommandUpload extends AbstractCommand { if (!args[0].equalsIgnoreCase("-confirm")) return ReturnType.FAILURE; - final AuctionHouse instance = AuctionHouse.getInstance(); - final DatabaseConnector databaseConnector = new SQLiteConnector(instance); - final DataManager manager = new DataManager(databaseConnector, instance, null); + final DatabaseConnector databaseConnector = new SQLiteConnector(AuctionHouse.getInstance()); + final DataManager manager = new DataManager(databaseConnector, AuctionHouse.getInstance(), null); manager.getItems((error, items) -> { if (error == null) - items.forEach(item -> instance.getDataManager().insertAuction(item, null)); + items.forEach(item -> AuctionHouse.getDataManager().insertAuction(item, null)); }); manager.getAdminLogs((error, logs) -> { if (error == null) - logs.forEach(log -> instance.getDataManager().insertLog(log)); + logs.forEach(log -> AuctionHouse.getDataManager().insertLog(log)); }); manager.getTransactions((error, transactions) -> { if (error == null) - transactions.forEach(transaction -> instance.getDataManager().insertTransaction(transaction, null)); + transactions.forEach(transaction -> AuctionHouse.getDataManager().insertTransaction(transaction, null)); }); return ReturnType.SUCCESS; diff --git a/src/main/java/ca/tweetzy/auctionhouse/database/DataManager.java b/src/main/java/ca/tweetzy/auctionhouse/database/DataManager.java index 612ebf5..a8f267e 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/database/DataManager.java +++ b/src/main/java/ca/tweetzy/auctionhouse/database/DataManager.java @@ -254,7 +254,7 @@ public class DataManager extends DataManagerAbstract { statement.setInt(12, 1); statement.setString(13, QuickItem.toString(item.getItem())); - } catch (NbtApiException e){ + } catch (NbtApiException e) { statement.setInt(12, 0); statement.setString(13, null); } @@ -318,7 +318,8 @@ public class DataManager extends DataManagerAbstract { updateStatement.setString(1, QuickItem.toString(item.getItem())); updateStatement.setString(2, resultSet.getString("id")); updateStatement.executeUpdate(); - } catch (NbtApiException ignored) {} + } catch (NbtApiException ignored) { + } } } @@ -371,7 +372,7 @@ public class DataManager extends DataManagerAbstract { try { statement.setInt(24, 1); statement.setString(25, QuickItem.toString(item.getItem())); - }catch (NbtApiException e) { + } catch (NbtApiException e) { statement.setInt(24, 0); statement.setString(25, null); } diff --git a/src/main/java/ca/tweetzy/auctionhouse/model/ListingBuilder.java b/src/main/java/ca/tweetzy/auctionhouse/model/ListingBuilder.java index 7a35bb5..e13eae7 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/model/ListingBuilder.java +++ b/src/main/java/ca/tweetzy/auctionhouse/model/ListingBuilder.java @@ -1,9 +1,5 @@ package ca.tweetzy.auctionhouse.model; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - import ca.tweetzy.auctionhouse.api.auction.Bid; import ca.tweetzy.auctionhouse.api.auction.ListingType; import ca.tweetzy.auctionhouse.impl.listing.AuctionListing; @@ -13,6 +9,10 @@ import lombok.NonNull; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + public class ListingBuilder { // Common fields diff --git a/src/main/java/ca/tweetzy/auctionhouse/model/discord/DiscordMessageCreator.java b/src/main/java/ca/tweetzy/auctionhouse/model/discord/DiscordMessageCreator.java index 77d386c..534d7ab 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/model/discord/DiscordMessageCreator.java +++ b/src/main/java/ca/tweetzy/auctionhouse/model/discord/DiscordMessageCreator.java @@ -18,7 +18,6 @@ package ca.tweetzy.auctionhouse.model.discord; -import ca.tweetzy.auctionhouse.AuctionHouse; import ca.tweetzy.auctionhouse.api.AuctionAPI; import ca.tweetzy.auctionhouse.auction.AuctionedItem; import ca.tweetzy.auctionhouse.helpers.AuctionCreator; diff --git a/src/main/java/ca/tweetzy/auctionhouse/settings/Settings.java b/src/main/java/ca/tweetzy/auctionhouse/settings/Settings.java index 7b877f6..1eb78d2 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/settings/Settings.java +++ b/src/main/java/ca/tweetzy/auctionhouse/settings/Settings.java @@ -51,6 +51,25 @@ public class Settings { public static final ConfigSetting CURRENCY_VAULT_SYMBOL = new ConfigSetting(config, "economy.currency.vault symbol", "$", "When using default/vault currency, what symbol should be used."); public static final ConfigSetting CURRENCY_BLACKLISTED = new ConfigSetting(config, "economy.currency.black listed", Collections.singletonList("UltraEconomy:Test"), "A list of owning plugins & the currency to be blacklisted. Ex. UltraEconomy:Test"); + public static final ConfigSetting CMD_ALIAS_MAIN = new ConfigSetting(config, "command aliases.main", Arrays.asList("ah", "auctions", "auctionhouses", "ahgui", "auctiongui"), "Command aliases for the main command"); + public static final ConfigSetting CMD_ALIAS_SUB_ACTIVE = new ConfigSetting(config, "command aliases.subcommands.active", Collections.singletonList("active"), "Command aliases for the active command"); + public static final ConfigSetting CMD_ALIAS_SUB_ADMIN = new ConfigSetting(config, "command aliases.subcommands.admin", Collections.singletonList("admin"), "Command aliases for the admin command"); + public static final ConfigSetting CMD_ALIAS_SUB_BAN = new ConfigSetting(config, "command aliases.subcommands.ban", Collections.singletonList("ban"), "Command aliases for the ban command"); + public static final ConfigSetting CMD_ALIAS_SUB_BIDS = new ConfigSetting(config, "command aliases.subcommands.bids", Collections.singletonList("bids"), "Command aliases for the bids command"); + public static final ConfigSetting CMD_ALIAS_SUB_CONFIRM = new ConfigSetting(config, "command aliases.subcommands.confirm", Collections.singletonList("confirm"), "Command aliases for the confirm command"); + public static final ConfigSetting CMD_ALIAS_SUB_EXPIRED = new ConfigSetting(config, "command aliases.subcommands.admin", Collections.singletonList("expired"), "Command aliases for the expired command"); + public static final ConfigSetting CMD_ALIAS_SUB_FILTER = new ConfigSetting(config, "command aliases.subcommands.admin", Collections.singletonList("filter"), "Command aliases for the filter command"); + public static final ConfigSetting CMD_ALIAS_SUB_MARKCHEST = new ConfigSetting(config, "command aliases.subcommands.admin", Collections.singletonList("markchest"), "Command aliases for the markchest command"); + public static final ConfigSetting CMD_ALIAS_SUB_MINPRICE = new ConfigSetting(config, "command aliases.subcommands.admin", Collections.singletonList("minprices"), "Command aliases for the minprices command"); + public static final ConfigSetting CMD_ALIAS_SUB_PAYMENTS = new ConfigSetting(config, "command aliases.subcommands.admin", Collections.singletonList("payments"), "Command aliases for the payments command"); + public static final ConfigSetting CMD_ALIAS_SUB_REQUEST = new ConfigSetting(config, "command aliases.subcommands.admin", Collections.singletonList("request"), "Command aliases for the request command"); + public static final ConfigSetting CMD_ALIAS_SUB_SEARCH = new ConfigSetting(config, "command aliases.subcommands.admin", Collections.singletonList("search"), "Command aliases for the search command"); + public static final ConfigSetting CMD_ALIAS_SUB_SELL = new ConfigSetting(config, "command aliases.subcommands.admin", Collections.singletonList("sell"), "Command aliases for the sell command"); + public static final ConfigSetting CMD_ALIAS_SUB_STATS = new ConfigSetting(config, "command aliases.subcommands.admin", Collections.singletonList("stats"), "Command aliases for the stats command"); + public static final ConfigSetting CMD_ALIAS_SUB_TOGGLELISTINFO = new ConfigSetting(config, "command aliases.subcommands.togglelistinfo", Collections.singletonList("togglelistinfo"), "Command aliases for the toggle list info command"); + public static final ConfigSetting CMD_ALIAS_SUB_TRANSACTIONS = new ConfigSetting(config, "command aliases.subcommands.transactions", Collections.singletonList("transactions"), "Command aliases for the transactions command"); + public static final ConfigSetting CMD_ALIAS_SUB_UNBAN = new ConfigSetting(config, "command aliases.subcommands.unban", Collections.singletonList("unban"), "Command aliases for the unban command"); + public static final ConfigSetting ALLOW_USAGE_OF_IN_GAME_EDITOR = new ConfigSetting(config, "Allow Usage Of This Menu In Game", true, "Once you set this to true, you will no longer be able to access it unless you enable it within the actual config.yml"); public static final ConfigSetting UPDATE_CHECKER = new ConfigSetting(config, "update checker", true, "If true, auction house will check for updates periodically"); @@ -76,7 +95,6 @@ public class Settings { public static final ConfigSetting DEFAULT_FILTER_SORT = new ConfigSetting(config, "auction setting.default filters.auction sort", "RECENT", "Valid Options: RECENT, OLDEST, PRICE"); public static final ConfigSetting DEFAULT_FILTER_SALE_TYPE = new ConfigSetting(config, "auction setting.default filters.sale type", "BOTH", "Valid Options: USED_BIDDING_SYSTEM, WITHOUT_BIDDING_SYSTEM, BOTH"); - public static final ConfigSetting INTERNAL_CREATE_DELAY = new ConfigSetting(config, "auction setting.internal create delay", 2, "How many ticks should auction house wait before actually creating the item."); public static final ConfigSetting MAX_AUCTION_PRICE = new ConfigSetting(config, "auction setting.pricing.max auction price", 1000000000, "The max price for buy only / buy now items"); public static final ConfigSetting MAX_AUCTION_START_PRICE = new ConfigSetting(config, "auction setting.pricing.max auction start price", 1000000000, "The max price starting a bidding auction"); @@ -90,8 +108,6 @@ public class Settings { public static final ConfigSetting MAX_REQUEST_AMOUNT = new ConfigSetting(config, "auction setting.max request amount", 64, "How much of an item should a player be able to ask for in a single request?"); public static final ConfigSetting AUTO_REFRESH_AUCTION_PAGES = new ConfigSetting(config, "auction setting.auto refresh auction pages", true, "Should auction pages auto refresh?"); public static final ConfigSetting AUTO_REFRESH_ACTIVE_AUCTION_PAGES = new ConfigSetting(config, "auction setting.auto refresh active auction pages", false, "Should the /ah active pages be auto refreshed?"); - public static final ConfigSetting AUTO_REFRESH_AUCTION_PAGE_SYNC = new ConfigSetting(config, "auction setting.auto refresh auction pages synchronously", false, "Should auction pages auto refresh use a synchronous?"); - public static final ConfigSetting AUTO_REFRESH_DOES_SLOT_CLEAR = new ConfigSetting(config, "auction setting.auto refresh does slot clear", true, "If true, on every refresh, the slots will be cleared (replaced by default item) then the actual listings will be placed."); public static final ConfigSetting USE_SHORT_NUMBERS_ON_ITEMS = new ConfigSetting(config, "auction setting.use short numbers", false, "Should numbers be shortened into a prefixed form?"); public static final ConfigSetting USE_SHORT_NUMBERS_ON_PLAYER_BALANCE = new ConfigSetting(config, "auction setting.use short numbers on balance", false, "Should numbers be shortened into a prefixed form for the player balance?"); public static final ConfigSetting INCREASE_TIME_ON_BID = new ConfigSetting(config, "auction setting.increase time on bid", true, "Should the remaining time be increased when a bid is placed?");