From d35dcaf4c65a763319cc592a63fd2f32bad465d2 Mon Sep 17 00:00:00 2001 From: Kiran Hart Date: Thu, 1 Aug 2024 14:54:51 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=9F=20used=20new=20currency=20system.?= =?UTF-8?q?=20Prep=20for=20multi=20currency=20support,=20updated=20inv=20c?= =?UTF-8?q?heck=20on=20join?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Took 1 hour 2 minutes --- .../ca/tweetzy/auctionhouse/AuctionHouse.java | 299 +++++++++--------- .../tweetzy/auctionhouse/api/AuctionAPI.java | 13 +- .../api/currency/AbstractCurrency.java | 20 ++ .../auctionhouse/api/currency/Chargeable.java | 14 + .../api/currency/IconableCurrency.java | 17 + .../auctionhouse/api/currency/Payment.java | 4 + .../api/currency/TransactionResult.java | 10 + .../auctionhouse/api/manager/ListManager.java | 51 +++ .../auctionhouse/api/statistic/Statistic.java | 6 +- .../auctionhouse/auction/AuctionPayment.java | 5 +- .../auctionhouse/auction/AuctionedItem.java | 2 - .../auctionhouse/commands/CommandAdmin.java | 7 +- .../commands/CommandAuctionHouse.java | 15 +- .../auctionhouse/commands/CommandBan.java | 2 +- .../auctionhouse/database/DataManager.java | 4 +- .../migrations/_11_AdminLogMigration.java | 2 +- .../migrations/_1_InitialMigration.java | 2 +- .../_2_FilterWhitelistMigration.java | 2 +- .../database/migrations/_3_BansMigration.java | 2 +- .../migrations/_6_BigIntMigration.java | 2 +- .../_7_TransactionBigIntMigration.java | 2 +- .../guis/admin/GUIAdminExpired.java | 2 +- .../auctionhouse/guis/admin/GUIAdminItem.java | 21 +- .../auctionhouse/guis/admin/GUIAdminLogs.java | 2 +- .../guis/admin/GUIMinItemPrices.java | 2 +- .../guis/admin/bans/GUIBanTypeSelection.java | 2 +- .../guis/admin/bans/GUIBanUser.java | 14 +- .../auctionhouse/guis/admin/bans/GUIBans.java | 2 +- .../guis/confirmation/GUIConfirmBid.java | 17 +- .../guis/confirmation/GUIConfirmCancel.java | 9 +- .../guis/confirmation/GUIConfirmPurchase.java | 35 +- .../guis/confirmation/GUIListingConfirm.java | 4 +- .../guis/core/GUIActiveAuctions.java | 7 +- .../guis/core/GUIAuctionHouse.java | 29 +- .../guis/core/GUIBundleCreation.java | 2 +- .../guis/core/GUIExpiredItems.java | 4 +- .../guis/core/GUIPaymentCollection.java | 4 +- .../auctionhouse/guis/core/bid/GUIBid.java | 19 +- .../guis/filter/GUIFilterSelection.java | 22 +- .../guis/filter/GUIFilterWhitelist.java | 18 +- .../guis/selector/GUIPlayerSelector.java | 2 +- .../guis/sell/GUIRequestItem.java | 6 +- .../guis/sell/GUISellAuction.java | 12 +- .../auctionhouse/guis/sell/GUISellBin.java | 8 +- .../guis/sell/GUISellListingType.java | 6 +- .../guis/sell/GUISellPlaceItem.java | 4 +- .../statistics/GUIStatisticLeaderboard.java | 4 +- .../guis/statistics/GUIStatisticView.java | 12 +- .../statistics/GUIStatisticViewSelect.java | 4 +- .../guis/transaction/GUITransactionList.java | 4 +- .../guis/transaction/GUITransactionType.java | 6 +- .../guis/transaction/GUITransactionView.java | 6 +- .../auctionhouse/helpers/AuctionCreator.java | 12 +- .../tweetzy/auctionhouse/impl/AuctionAPI.java | 4 +- .../impl/currency/ItemCurrency.java | 53 ++++ .../impl/currency/UltraEconomyCurrency.java | 57 ++++ .../impl/currency/VaultCurrency.java | 33 ++ .../impl/listing/AuctionItem.java | 22 +- .../auctionhouse/impl/listing/BinListing.java | 20 -- .../listeners/PlayerListeners.java | 23 +- .../model/currency/CurrencyLoader.java | 17 + .../model/currency/UltraEconomyLoader.java | 43 +++ .../model/manager/CurrencyManager.java | 102 ++++++ .../auctionhouse/settings/Settings.java | 5 + .../auctionhouse/settings/v3/Settings.java | 13 +- .../auctionhouse/tasks/TickAuctionsTask.java | 48 ++- 66 files changed, 812 insertions(+), 410 deletions(-) create mode 100644 src/main/java/ca/tweetzy/auctionhouse/api/currency/AbstractCurrency.java create mode 100644 src/main/java/ca/tweetzy/auctionhouse/api/currency/Chargeable.java create mode 100644 src/main/java/ca/tweetzy/auctionhouse/api/currency/IconableCurrency.java create mode 100644 src/main/java/ca/tweetzy/auctionhouse/api/currency/Payment.java create mode 100644 src/main/java/ca/tweetzy/auctionhouse/api/currency/TransactionResult.java create mode 100644 src/main/java/ca/tweetzy/auctionhouse/api/manager/ListManager.java create mode 100644 src/main/java/ca/tweetzy/auctionhouse/impl/currency/ItemCurrency.java create mode 100644 src/main/java/ca/tweetzy/auctionhouse/impl/currency/UltraEconomyCurrency.java create mode 100644 src/main/java/ca/tweetzy/auctionhouse/impl/currency/VaultCurrency.java create mode 100644 src/main/java/ca/tweetzy/auctionhouse/model/currency/CurrencyLoader.java create mode 100644 src/main/java/ca/tweetzy/auctionhouse/model/currency/UltraEconomyLoader.java create mode 100644 src/main/java/ca/tweetzy/auctionhouse/model/manager/CurrencyManager.java diff --git a/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java b/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java index 6ec90f7..98e6ddd 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java +++ b/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java @@ -24,10 +24,10 @@ import ca.tweetzy.auctionhouse.database.DataManager; import ca.tweetzy.auctionhouse.database.migrations.*; import ca.tweetzy.auctionhouse.helpers.UpdateChecker; import ca.tweetzy.auctionhouse.hooks.PlaceholderAPIHook; -import ca.tweetzy.auctionhouse.hooks.UltraEconomyHook; import ca.tweetzy.auctionhouse.listeners.*; import ca.tweetzy.auctionhouse.managers.*; import ca.tweetzy.auctionhouse.model.manager.BanManager; +import ca.tweetzy.auctionhouse.model.manager.CurrencyManager; import ca.tweetzy.auctionhouse.model.manager.PaymentsManager; import ca.tweetzy.auctionhouse.settings.LocaleSettings; import ca.tweetzy.auctionhouse.settings.Settings; @@ -40,9 +40,6 @@ import ca.tweetzy.core.commands.CommandManager; import ca.tweetzy.core.compatibility.ServerProject; import ca.tweetzy.core.configuration.Config; import ca.tweetzy.core.gui.GuiManager; -import ca.tweetzy.core.hooks.EconomyManager; -import ca.tweetzy.core.hooks.PluginHook; -import ca.tweetzy.core.hooks.economies.Economy; import ca.tweetzy.core.utils.Metrics; import ca.tweetzy.core.utils.TextUtils; import ca.tweetzy.flight.comp.enums.ServerVersion; @@ -53,9 +50,11 @@ import co.aikar.taskchain.TaskChain; import co.aikar.taskchain.TaskChainFactory; import lombok.Getter; import lombok.Setter; +import net.milkbowl.vault.economy.Economy; import org.bukkit.Bukkit; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.RegisteredServiceProvider; import java.io.File; import java.io.IOException; @@ -75,62 +74,47 @@ import java.util.stream.Collectors; public class AuctionHouse extends TweetyPlugin { //==========================================================================// + // "v3" stuff for organization + @Getter private static TweetzyYamlConfig migrationCoreConfig; + + private DatabaseConnector databaseConnector; + private DataManager dataManager; + + + private final CurrencyManager currencyManager = new CurrencyManager(); + private final CommandManager commandManager = new CommandManager(this); + private final GuiManager guiManager = new GuiManager(this); + + private final AuctionPlayerManager auctionPlayerManager = new AuctionPlayerManager(); + private final AuctionItemManager auctionItemManager = new AuctionItemManager(); + private final TransactionManager transactionManager = new TransactionManager(); + private final FilterManager filterManager = new FilterManager(); + private final BanManager banManager = new BanManager(); + private final AuctionStatisticManager auctionStatisticManager = new AuctionStatisticManager(); + private final MinItemPriceManager minItemPriceManager = new MinItemPriceManager(); + private final PaymentsManager paymentsManager = new PaymentsManager(); + + + // the default vault economy + private Economy economy = null; + + //==========================================================================// private static TaskChainFactory taskChainFactory; - private static AuctionHouse instance; - private PluginHook ultraEconomyHook; @Getter @Setter private boolean migrating = false; - @Getter - private final GuiManager guiManager = new GuiManager(this); - protected Metrics metrics; - @Getter - private CommandManager commandManager; - - - @Getter - private AuctionPlayerManager auctionPlayerManager; - - @Getter - private AuctionItemManager auctionItemManager; - - @Getter - private TransactionManager transactionManager; - - @Getter - private FilterManager filterManager; - - @Getter - private BanManager banManager; - - @Getter - private AuctionStatisticManager auctionStatisticManager; - - @Getter - private MinItemPriceManager minItemPriceManager; - - @Getter - private PaymentsManager paymentsManager; - - @Getter - private DatabaseConnector databaseConnector; - - @Getter - private DataManager dataManager; - @Getter private UpdateChecker.UpdateStatus status; @Override public void onPluginLoad() { - instance = this; } @Override @@ -145,64 +129,18 @@ public class AuctionHouse extends TweetyPlugin { taskChainFactory = BukkitTaskChainFactory.create(this); migrationCoreConfig = new TweetzyYamlConfig(this, "migration-config-dont-touch.yml"); - - // Settings + // Settings & Locale Settings.setup(); - - if (Settings.AUTO_BSTATS.getBoolean()) { - final File file = new File("plugins" + File.separator + "bStats" + File.separator + "config.yml"); - if (file.exists()) { - final YamlConfiguration configuration = YamlConfiguration.loadConfiguration(file); - configuration.set("enabled", true); - try { - configuration.save(file); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - this.ultraEconomyHook = PluginHook.addHook(Economy.class, "UltraEconomy", UltraEconomyHook.class); - - // translations & Settings migration stuff - Translations.init(); - ca.tweetzy.auctionhouse.settings.v3.Settings.init(); - - // Load Economy - EconomyManager.load(); - - // local setLocale(Settings.LANG.getString()); LocaleSettings.setup(); + initializeBStats(); - // Setup Economy - final String ECO_PLUGIN = Settings.ECONOMY_PLUGIN.getString(); + // settings / locales v3 + Translations.init(); + ca.tweetzy.auctionhouse.settings.v3.Settings.init(); - if (ECO_PLUGIN.startsWith("UltraEconomy")) { - EconomyManager.getManager().setPreferredHook(this.ultraEconomyHook); - } else { - EconomyManager.getManager().setPreferredHook(ECO_PLUGIN); - } - - if (!EconomyManager.getManager().isEnabled()) { - getLogger().severe("Could not find a valid economy provider for Auction House"); - getServer().getPluginManager().disablePlugin(this); - return; - } - - // listeners - Bukkit.getServer().getPluginManager().registerEvents(new PlayerListeners(), this); - Bukkit.getServer().getPluginManager().registerEvents(new MeteorClientListeners(), this); - Bukkit.getServer().getPluginManager().registerEvents(new AuctionListeners(), this); - - if (getServer().getPluginManager().isPluginEnabled("ChestShop")) - Bukkit.getServer().getPluginManager().registerEvents(new ChestShopListener(), this); - - if (getServer().getPluginManager().isPluginEnabled("CMI")) - Bukkit.getServer().getPluginManager().registerEvents(new CMIListener(), this); - // Setup the database if enabled this.databaseConnector = Settings.DATABASE_USE.getBoolean() ? new MySQLConnector( this, @@ -245,44 +183,38 @@ public class AuctionHouse extends TweetyPlugin { dataMigrationManager.runMigrations(); - // load auction items - this.auctionItemManager = new AuctionItemManager(); - this.auctionItemManager.start(); - - // load transactions - this.transactionManager = new TransactionManager(); - this.transactionManager.loadTransactions(); - - // load the filter whitelist items - this.filterManager = new FilterManager(); - this.filterManager.loadItems(); - - // load the bans - this.banManager = new BanManager(); - this.banManager.load(); - - this.minItemPriceManager = new MinItemPriceManager(); - this.minItemPriceManager.loadMinPrices(); - - this.auctionStatisticManager = new AuctionStatisticManager(); - this.auctionStatisticManager.loadStatistics(); - - // auction players - this.auctionPlayerManager = new AuctionPlayerManager(); - this.auctionPlayerManager.loadPlayers(); - - // payments - this.paymentsManager = new PaymentsManager(); - this.paymentsManager.load(); + // setup Vault Economy + setupEconomy(); // todo auto apply ultra economy currency if it was used. // gui manager this.guiManager.init(); + this.banManager.load(); + this.currencyManager.load(); + this.paymentsManager.load(); + + // listeners + Bukkit.getServer().getPluginManager().registerEvents(new PlayerListeners(), this); + Bukkit.getServer().getPluginManager().registerEvents(new MeteorClientListeners(), this); + Bukkit.getServer().getPluginManager().registerEvents(new AuctionListeners(), this); + + if (getServer().getPluginManager().isPluginEnabled("ChestShop")) + Bukkit.getServer().getPluginManager().registerEvents(new ChestShopListener(), this); + + if (getServer().getPluginManager().isPluginEnabled("CMI")) + Bukkit.getServer().getPluginManager().registerEvents(new CMIListener(), this); + + + this.auctionItemManager.start(); + this.transactionManager.loadTransactions(); + this.filterManager.loadItems(); + this.minItemPriceManager.loadMinPrices(); + this.auctionStatisticManager.loadStatistics(); + this.auctionPlayerManager.loadPlayers(); // commands - this.commandManager = new CommandManager(this); this.commandManager.setSyntaxErrorMessage(TextUtils.formatText(getLocale().getMessage("commands.invalid_syntax").getMessage().split("\n"))); this.commandManager.setNoPermsMessage(TextUtils.formatText(getLocale().getMessage("commands.no_permission").getMessage())); - this.commandManager.addCommand(new CommandAuctionHouse()).addSubCommands( + this.commandManager.registerCommandDynamically(new CommandAuctionHouse()).addSubCommands( new CommandSell(), new CommandActive(), new CommandExpired(), @@ -334,10 +266,6 @@ public class AuctionHouse extends TweetyPlugin { getLogger().severe("You will not receive any support while using a non-supported jar, support jars: Spigot or Paper"); } -// if (ServerVersion.isServerVersionBelow(ServerVersion.V1_16)) { -// getLogger().severe("You are receiving this message because you're running Auction House on a Minecraft version older than 1.16. As a heads up, Auction House 3.0 is going to be for 1.16+ only"); -// } - if (!ServerProject.isServer(ServerProject.PAPER, ServerProject.SPIGOT)) { getLogger().warning("You're running Auction House on a non supported server jar, although small, there's a chance somethings will not work or just entirely break."); } @@ -358,11 +286,26 @@ public class AuctionHouse extends TweetyPlugin { }, 1L); } + private void initializeBStats() { + if (Settings.AUTO_BSTATS.getBoolean()) { + final File file = new File("plugins" + File.separator + "bStats" + File.separator + "config.yml"); + if (file.exists()) { + final YamlConfiguration configuration = YamlConfiguration.loadConfiguration(file); + configuration.set("enabled", true); + try { + configuration.save(file); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + @Override public void onPluginDisable() { if (this.dataManager != null) { // clean up the garbage items - AuctionHouse.getInstance().getDataManager().deleteItems(AuctionHouse.getInstance().getAuctionItemManager().getDeletedItems().values().stream().map(AuctionedItem::getId).collect(Collectors.toList())); + this.dataManager.deleteItems(this.auctionItemManager.getDeletedItems().values().stream().map(AuctionedItem::getId).collect(Collectors.toList())); this.auctionItemManager.end(); this.filterManager.saveFilterWhitelist(false); @@ -374,28 +317,14 @@ public class AuctionHouse extends TweetyPlugin { @Override public void onConfigReload() { - EconomyManager.load(); Settings.setup(); - EconomyManager.getManager().setPreferredHook(Settings.ECONOMY_PLUGIN.getString()); setLocale(Settings.LANG.getString()); LocaleSettings.setup(); this.commandManager.setSyntaxErrorMessage(TextUtils.formatText(getLocale().getMessage("commands.invalid_syntax").getMessage().split("\n"))); this.commandManager.setNoPermsMessage(TextUtils.formatText(getLocale().getMessage("commands.no_permission").getMessage())); } - @Override - public List getExtraConfig() { - return null; - } - - public static AuctionHouse getInstance() { - return instance; - } - - public static TweetzyYamlConfig getMigrationCoreConfig() { - return migrationCoreConfig; - } - + //========================================== Getters ========================================== public static TaskChain newChain() { return taskChainFactory.newChain(); } @@ -404,6 +333,71 @@ public class AuctionHouse extends TweetyPlugin { return taskChainFactory.newSharedChain(name); } + public static AuctionHouse getInstance() { + return (AuctionHouse) TweetyPlugin.getInstance(); + } + + public static DataManager getDataManager() { + return getInstance().dataManager; + } + + public static DatabaseConnector getDatabaseConnector() { + return getInstance().databaseConnector; + } + + public static GuiManager getGuiManager() { + return getInstance().guiManager; + } + + public static CommandManager getCommandManager() { + return getInstance().commandManager; + } + + public static AuctionPlayerManager getAuctionPlayerManager() { + return getInstance().auctionPlayerManager; + } + + public static AuctionItemManager getAuctionItemManager() { + return getInstance().auctionItemManager; + } + + public static TransactionManager getTransactionManager() { + return getInstance().transactionManager; + } + + public static BanManager getBanManager() { + return getInstance().banManager; + } + + public static FilterManager getFilterManager() { + return getInstance().filterManager; + } + + public static AuctionStatisticManager getAuctionStatisticManager() { + return getInstance().auctionStatisticManager; + } + + public static MinItemPriceManager getMinItemPriceManager() { + return getInstance().minItemPriceManager; + } + + public static PaymentsManager getPaymentsManager() { + return getInstance().paymentsManager; + } + + public static CurrencyManager getCurrencyManager() { + return getInstance().currencyManager; + } + + public static Economy getEconomy() { + return getInstance().economy; + } + + //========================================== LEGACY ========================================== + @Override + public List getExtraConfig() { + return null; + } String IS_SONGODA_DOWNLOAD = "%%__SONGODA__%%"; String SONGODA_NODE = "%%__SONGODA_NODE__%%"; @@ -450,5 +444,18 @@ public class AuctionHouse extends TweetyPlugin { } } + // helpers + private void setupEconomy() { + if (getServer().getPluginManager().getPlugin("Vault") == null) { + return; + } + final RegisteredServiceProvider rsp = getServer().getServicesManager().getRegistration(Economy.class); + + if (rsp == null) { + return; + } + + this.economy = rsp.getProvider(); + } } diff --git a/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java b/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java index 278b610..f8084be 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java +++ b/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java @@ -24,7 +24,6 @@ import ca.tweetzy.auctionhouse.auction.MinItemPrice; import ca.tweetzy.auctionhouse.auction.enums.PaymentReason; import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.compatibility.XMaterial; -import ca.tweetzy.core.hooks.EconomyManager; import ca.tweetzy.flight.comp.enums.ServerVersion; import ca.tweetzy.flight.nbtapi.NBT; import ca.tweetzy.flight.utils.QuickItem; @@ -754,9 +753,9 @@ public class AuctionAPI { }).execute(); } else { if (Settings.FORCE_SYNC_MONEY_ACTIONS.getBoolean()) - AuctionHouse.newChain().sync(() -> EconomyManager.withdrawBalance(player, amount)).execute(); + AuctionHouse.newChain().sync(() -> AuctionHouse.getCurrencyManager().withdraw(player, amount)).execute(); else - EconomyManager.withdrawBalance(player, amount); + AuctionHouse.getCurrencyManager().withdraw(player, amount); } } @@ -764,14 +763,14 @@ public class AuctionAPI { if (Settings.STORE_PAYMENTS_FOR_MANUAL_COLLECTION.getBoolean()) { if (Settings.MANUAL_PAYMENTS_ONLY_FOR_OFFLINE_USERS.getBoolean()) { if (!player.isOnline()) { - AuctionHouse.getInstance().getDataManager().insertAuctionPayment(new AuctionPayment(player.getUniqueId(), amount, item, paidFrom.getName(), PaymentReason.ITEM_SOLD), null); + AuctionHouse.getDataManager().insertAuctionPayment(new AuctionPayment(player.getUniqueId(), amount, item, paidFrom.getName(), PaymentReason.ITEM_SOLD), null); } else { initiatePayment(player, amount); } return; } - AuctionHouse.getInstance().getDataManager().insertAuctionPayment(new AuctionPayment(player.getUniqueId(), amount, item, paidFrom.getName(), PaymentReason.ITEM_SOLD), null); + AuctionHouse.getDataManager().insertAuctionPayment(new AuctionPayment(player.getUniqueId(), amount, item, paidFrom.getName(), PaymentReason.ITEM_SOLD), null); return; } @@ -785,9 +784,9 @@ public class AuctionAPI { }).execute(); } else { if (Settings.FORCE_SYNC_MONEY_ACTIONS.getBoolean()) - AuctionHouse.newChain().sync(() -> EconomyManager.deposit(player, amount)).execute(); + AuctionHouse.newChain().sync(() -> AuctionHouse.getCurrencyManager().deposit(player, amount)).execute(); else - EconomyManager.deposit(player, amount); + AuctionHouse.getCurrencyManager().deposit(player, amount); } } diff --git a/src/main/java/ca/tweetzy/auctionhouse/api/currency/AbstractCurrency.java b/src/main/java/ca/tweetzy/auctionhouse/api/currency/AbstractCurrency.java new file mode 100644 index 0000000..d8c9f95 --- /dev/null +++ b/src/main/java/ca/tweetzy/auctionhouse/api/currency/AbstractCurrency.java @@ -0,0 +1,20 @@ +package ca.tweetzy.auctionhouse.api.currency; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; + +@Getter +@AllArgsConstructor +public abstract class AbstractCurrency implements Chargeable { + + protected String owningPlugin; + protected String currencyName; + + @Setter + protected String displayName; + + public String getStoreableName() { + return this.owningPlugin + "/" + this.currencyName + "/" + this.displayName; + } +} diff --git a/src/main/java/ca/tweetzy/auctionhouse/api/currency/Chargeable.java b/src/main/java/ca/tweetzy/auctionhouse/api/currency/Chargeable.java new file mode 100644 index 0000000..34c287b --- /dev/null +++ b/src/main/java/ca/tweetzy/auctionhouse/api/currency/Chargeable.java @@ -0,0 +1,14 @@ +package ca.tweetzy.auctionhouse.api.currency; + +import org.bukkit.OfflinePlayer; + +public interface Chargeable { + + boolean has(OfflinePlayer player, double amount); + + boolean withdraw(OfflinePlayer player, double amount); + + boolean deposit(OfflinePlayer player, double amount); + + double getBalance(OfflinePlayer player); +} diff --git a/src/main/java/ca/tweetzy/auctionhouse/api/currency/IconableCurrency.java b/src/main/java/ca/tweetzy/auctionhouse/api/currency/IconableCurrency.java new file mode 100644 index 0000000..ff82e12 --- /dev/null +++ b/src/main/java/ca/tweetzy/auctionhouse/api/currency/IconableCurrency.java @@ -0,0 +1,17 @@ +package ca.tweetzy.auctionhouse.api.currency; + +import lombok.Getter; +import lombok.Setter; +import org.bukkit.inventory.ItemStack; + +@Setter +@Getter +public abstract class IconableCurrency extends AbstractCurrency { + + protected ItemStack icon; + + public IconableCurrency(String owningPlugin, String currencyName, String displayName, ItemStack icon) { + super(owningPlugin, currencyName, displayName); + this.icon = icon; + } +} diff --git a/src/main/java/ca/tweetzy/auctionhouse/api/currency/Payment.java b/src/main/java/ca/tweetzy/auctionhouse/api/currency/Payment.java new file mode 100644 index 0000000..a0ea710 --- /dev/null +++ b/src/main/java/ca/tweetzy/auctionhouse/api/currency/Payment.java @@ -0,0 +1,4 @@ +package ca.tweetzy.auctionhouse.api.currency; + +public interface Payment { +} diff --git a/src/main/java/ca/tweetzy/auctionhouse/api/currency/TransactionResult.java b/src/main/java/ca/tweetzy/auctionhouse/api/currency/TransactionResult.java new file mode 100644 index 0000000..9637f2d --- /dev/null +++ b/src/main/java/ca/tweetzy/auctionhouse/api/currency/TransactionResult.java @@ -0,0 +1,10 @@ +package ca.tweetzy.auctionhouse.api.currency; + +public enum TransactionResult { + + SUCCESS, + FAILED_NO_MONEY, + FAILED_NO_LONGER_AVAILABLE, + FAILED_NOT_ENOUGH_ITEMS, + ERROR +} diff --git a/src/main/java/ca/tweetzy/auctionhouse/api/manager/ListManager.java b/src/main/java/ca/tweetzy/auctionhouse/api/manager/ListManager.java new file mode 100644 index 0000000..abf9846 --- /dev/null +++ b/src/main/java/ca/tweetzy/auctionhouse/api/manager/ListManager.java @@ -0,0 +1,51 @@ +package ca.tweetzy.auctionhouse.api.manager; + +import lombok.NonNull; + +import java.util.*; + +public abstract class ListManager extends Manager { + + protected final List managerContent = Collections.synchronizedList(new ArrayList<>()); + + public ListManager(@NonNull String name) { + super(name); + } + + public Optional get(@NonNull final T t) { + synchronized (this.managerContent) { + return this.managerContent.stream().filter(contents -> contents == t).findFirst(); + } + } + + public void add(@NonNull final T t) { + synchronized (this.managerContent) { + if (this.managerContent.contains(t)) return; + this.managerContent.add(t); + } + } + + public void addAll(@NonNull final Collection t) { + synchronized (this.managerContent) { + this.managerContent.addAll(t); + } + } + + public void remove(@NonNull final T t) { + synchronized (this.managerContent) { + this.managerContent.remove(t); + } + } + + public void clear() { + synchronized (this.managerContent) { + this.managerContent.clear(); + } + } + + public List getManagerContent() { + synchronized (this.managerContent) { + return new ArrayList<>(this.managerContent); + } + } +} \ No newline at end of file diff --git a/src/main/java/ca/tweetzy/auctionhouse/api/statistic/Statistic.java b/src/main/java/ca/tweetzy/auctionhouse/api/statistic/Statistic.java index b62be93..257c86b 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/api/statistic/Statistic.java +++ b/src/main/java/ca/tweetzy/auctionhouse/api/statistic/Statistic.java @@ -33,14 +33,16 @@ public interface Statistic extends Identifiable, Trackable, Storeable cmd.equalsIgnoreCase(StringUtils.join(args, ' ').trim()))) { + if (args.length == 1 && AuctionHouse.getCommandManager().getSubCommands("auctionhouse").stream().noneMatch(cmd -> cmd.equalsIgnoreCase(StringUtils.join(args, ' ').trim()))) { if (args[0].equalsIgnoreCase("NaN")) return ReturnType.FAILURE; - instance.getGuiManager().showGUI(player, new GUIAuctionHouse(instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()), StringUtils.join(args, ' ').trim())); + AuctionHouse.getGuiManager().showGUI(player, new GUIAuctionHouse(AuctionHouse.getAuctionPlayerManager().getPlayer(player.getUniqueId()), StringUtils.join(args, ' ').trim())); } } return ReturnType.SUCCESS; @@ -72,7 +71,7 @@ public class CommandAuctionHouse extends AbstractCommand { @Override protected List onTab(CommandSender sender, String... args) { final Player player = (Player) sender; - return AuctionHouse.getInstance().getCommandManager().getAllCommands().stream().filter(cmd -> cmd.getPermissionNode() == null || player.hasPermission(cmd.getPermissionNode())).map(AbstractCommand::getSyntax).collect(Collectors.toList()); + return AuctionHouse.getCommandManager().getAllCommands().stream().filter(cmd -> cmd.getPermissionNode() == null || player.hasPermission(cmd.getPermissionNode())).map(AbstractCommand::getSyntax).collect(Collectors.toList()); } @Override diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandBan.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandBan.java index 72ea022..37c14ec 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandBan.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandBan.java @@ -38,7 +38,7 @@ import java.util.stream.Collectors; public class CommandBan extends AbstractCommand { public CommandBan() { - super(CommandType.PLAYER_ONLY, "ban"); + super(CommandType.PLAYER_ONLY, "ban"); } @Override diff --git a/src/main/java/ca/tweetzy/auctionhouse/database/DataManager.java b/src/main/java/ca/tweetzy/auctionhouse/database/DataManager.java index 9954d81..14b496d 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/database/DataManager.java +++ b/src/main/java/ca/tweetzy/auctionhouse/database/DataManager.java @@ -160,7 +160,7 @@ public class DataManager extends DataManagerAbstract { public void saveFilterWhitelist(List filterItems, boolean async) { String saveItems = "INSERT INTO " + this.getTablePrefix() + "filter_whitelist(data) VALUES(?)"; - String truncate = AuctionHouse.getInstance().getDatabaseConnector() instanceof MySQLConnector ? "TRUNCATE TABLE " + this.getTablePrefix() + "filter_whitelist" : "DELETE FROM " + this.getTablePrefix() + "filter_whitelist"; + String truncate = AuctionHouse.getDatabaseConnector() instanceof MySQLConnector ? "TRUNCATE TABLE " + this.getTablePrefix() + "filter_whitelist" : "DELETE FROM " + this.getTablePrefix() + "filter_whitelist"; if (async) { this.runAsync(() -> this.databaseConnector.connect(connection -> { @@ -585,7 +585,7 @@ public class DataManager extends DataManagerAbstract { "VALUES (?, ?, ?, ?, ?)"; - if (AuctionHouse.getInstance().getDatabaseConnector() instanceof MySQLConnector) { + if (AuctionHouse.getDatabaseConnector() instanceof MySQLConnector) { insertQuery = "INSERT INTO " + getTablePrefix() + "player " + "(uuid, filter_sale_type, filter_item_category, filter_sort_type, last_listed_item) " + "VALUES (?, ?, ?, ?, ?) " + diff --git a/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_11_AdminLogMigration.java b/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_11_AdminLogMigration.java index e07879b..702e227 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_11_AdminLogMigration.java +++ b/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_11_AdminLogMigration.java @@ -41,7 +41,7 @@ public final class _11_AdminLogMigration extends DataMigration { @Override public void migrate(Connection connection, String tablePrefix) throws SQLException { try (Statement statement = connection.createStatement()) { - String autoIncrement = AuctionHouse.getInstance().getDatabaseConnector() instanceof MySQLConnector ? " AUTO_INCREMENT" : ""; + String autoIncrement = AuctionHouse.getDatabaseConnector() instanceof MySQLConnector ? " AUTO_INCREMENT" : ""; statement.execute("CREATE TABLE IF NOT EXISTS " + tablePrefix + "admin_logs (" + diff --git a/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_1_InitialMigration.java b/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_1_InitialMigration.java index 19c79df..da8f7a8 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_1_InitialMigration.java +++ b/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_1_InitialMigration.java @@ -40,7 +40,7 @@ public class _1_InitialMigration extends DataMigration { @Override public void migrate(Connection connection, String tablePrefix) throws SQLException { - String autoIncrement = AuctionHouse.getInstance().getDatabaseConnector() instanceof MySQLConnector ? " AUTO_INCREMENT" : ""; + String autoIncrement = AuctionHouse.getDatabaseConnector() instanceof MySQLConnector ? " AUTO_INCREMENT" : ""; try (Statement statement = connection.createStatement()) { statement.execute("CREATE TABLE " + tablePrefix + "items (" + diff --git a/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_2_FilterWhitelistMigration.java b/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_2_FilterWhitelistMigration.java index b1a6ddc..16d108f 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_2_FilterWhitelistMigration.java +++ b/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_2_FilterWhitelistMigration.java @@ -40,7 +40,7 @@ public class _2_FilterWhitelistMigration extends DataMigration { @Override public void migrate(Connection connection, String tablePrefix) throws SQLException { - String autoIncrement = AuctionHouse.getInstance().getDatabaseConnector() instanceof MySQLConnector ? " AUTO_INCREMENT" : ""; + String autoIncrement = AuctionHouse.getDatabaseConnector() instanceof MySQLConnector ? " AUTO_INCREMENT" : ""; try (Statement statement = connection.createStatement()) { statement.execute("CREATE TABLE " + tablePrefix + "filter_whitelist (" + diff --git a/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_3_BansMigration.java b/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_3_BansMigration.java index 32f93c4..9e5294c 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_3_BansMigration.java +++ b/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_3_BansMigration.java @@ -40,7 +40,7 @@ public class _3_BansMigration extends DataMigration { @Override public void migrate(Connection connection, String tablePrefix) throws SQLException { - String autoIncrement = AuctionHouse.getInstance().getDatabaseConnector() instanceof MySQLConnector ? " AUTO_INCREMENT" : ""; + String autoIncrement = AuctionHouse.getDatabaseConnector() instanceof MySQLConnector ? " AUTO_INCREMENT" : ""; try (Statement statement = connection.createStatement()) { statement.execute("CREATE TABLE " + tablePrefix + "bans (" + diff --git a/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_6_BigIntMigration.java b/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_6_BigIntMigration.java index cb03875..73e4be1 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_6_BigIntMigration.java +++ b/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_6_BigIntMigration.java @@ -42,7 +42,7 @@ public class _6_BigIntMigration extends DataMigration { public void migrate(Connection connection, String tablePrefix) throws SQLException { try (Statement statement = connection.createStatement()) { - if (AuctionHouse.getInstance().getDatabaseConnector() instanceof MySQLConnector) { + if (AuctionHouse.getDatabaseConnector() instanceof MySQLConnector) { statement.execute("ALTER TABLE " + tablePrefix + "auctions MODIFY COLUMN expires_at BigInt(20)"); } else { diff --git a/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_7_TransactionBigIntMigration.java b/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_7_TransactionBigIntMigration.java index 4d61f67..49440ce 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_7_TransactionBigIntMigration.java +++ b/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_7_TransactionBigIntMigration.java @@ -42,7 +42,7 @@ public class _7_TransactionBigIntMigration extends DataMigration { public void migrate(Connection connection, String tablePrefix) throws SQLException { try (Statement statement = connection.createStatement()) { - if (AuctionHouse.getInstance().getDatabaseConnector() instanceof MySQLConnector) { + if (AuctionHouse.getDatabaseConnector() instanceof MySQLConnector) { statement.execute("ALTER TABLE " + tablePrefix + "transactions MODIFY COLUMN transaction_time BigInt(20)"); } else { diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminExpired.java b/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminExpired.java index 66db61f..504462a 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminExpired.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminExpired.java @@ -56,7 +56,7 @@ public final class GUIAdminExpired extends AuctionPagedGUI { @Override protected ItemStack makeDisplayItem(AuctionedItem auctionedItem) { final ItemStack item = auctionedItem.getItem().clone(); - return QuickItem.of(item).lore(this.player,Settings.GUI_EXPIRED_ITEMS_ADMIN_ITEMS_LORE.getStringList()).make(); + return QuickItem.of(item).lore(this.player, Settings.GUI_EXPIRED_ITEMS_ADMIN_ITEMS_LORE.getStringList()).make(); } @Override diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminItem.java b/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminItem.java index 5aa2a20..b796ea0 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminItem.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminItem.java @@ -30,7 +30,6 @@ import ca.tweetzy.auctionhouse.events.AuctionAdminEvent; import ca.tweetzy.auctionhouse.guis.AuctionBaseGUI; import ca.tweetzy.auctionhouse.guis.core.GUIAuctionHouse; import ca.tweetzy.auctionhouse.settings.Settings; -import ca.tweetzy.core.hooks.EconomyManager; import ca.tweetzy.core.utils.PlayerUtils; import ca.tweetzy.flight.utils.QuickItem; import org.bukkit.Bukkit; @@ -72,7 +71,7 @@ public class GUIAdminItem extends AuctionBaseGUI { private void drawReturnButton() { if (Settings.ADMIN_OPTION_SHOW_RETURN_ITEM.getBoolean()) - setButton(1, 1, QuickItem.of(Settings.GUI_ITEM_ADMIN_ITEMS_RETURN_ITEM.getString()).name(Settings.GUI_ITEM_ADMIN_ITEMS_RETURN_NAME.getString()).lore(this.player,Settings.GUI_ITEM_ADMIN_ITEMS_RETURN_LORE.getStringList()).make(), click -> { + setButton(1, 1, QuickItem.of(Settings.GUI_ITEM_ADMIN_ITEMS_RETURN_ITEM.getString()).name(Settings.GUI_ITEM_ADMIN_ITEMS_RETURN_NAME.getString()).lore(this.player, Settings.GUI_ITEM_ADMIN_ITEMS_RETURN_LORE.getStringList()).make(), click -> { if (!click.player.hasPermission("auctionhouse.admin.returnitem")) return; @@ -90,10 +89,10 @@ public class GUIAdminItem extends AuctionBaseGUI { if (Settings.STORE_PAYMENTS_FOR_MANUAL_COLLECTION.getBoolean()) AuctionHouse.getInstance().getDataManager().insertAuctionPayment(new AuctionPayment(oldBidder.getUniqueId(), auctionItem.getCurrentPrice(), auctionItem.getItem(), click.player.getName(), PaymentReason.ADMIN_REMOVED), null); - else EconomyManager.deposit(oldBidder, auctionItem.getCurrentPrice()); + else AuctionHouse.getCurrencyManager().deposit(oldBidder, auctionItem.getCurrentPrice()); if (oldBidder.isOnline()) - AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(this.auctionItem.getCurrentPrice())).sendPrefixedMessage(oldBidder.getPlayer()); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(this.auctionItem.getCurrentPrice())).sendPrefixedMessage(oldBidder.getPlayer()); } @@ -103,7 +102,7 @@ public class GUIAdminItem extends AuctionBaseGUI { private void drawClaimButton() { if (Settings.ADMIN_OPTION_SHOW_CLAIM_ITEM.getBoolean()) - setButton(1, 3, QuickItem.of(Settings.GUI_ITEM_ADMIN_ITEMS_CLAIM_ITEM.getString()).name(Settings.GUI_ITEM_ADMIN_ITEMS_CLAIM_NAME.getString()).lore(this.player,Settings.GUI_ITEM_ADMIN_ITEMS_CLAIM_LORE.getStringList()).make(), click -> { + setButton(1, 3, QuickItem.of(Settings.GUI_ITEM_ADMIN_ITEMS_CLAIM_ITEM.getString()).name(Settings.GUI_ITEM_ADMIN_ITEMS_CLAIM_NAME.getString()).lore(this.player, Settings.GUI_ITEM_ADMIN_ITEMS_CLAIM_LORE.getStringList()).make(), click -> { if (!click.player.hasPermission("auctionhouse.admin.claimitem")) return; @@ -118,10 +117,10 @@ public class GUIAdminItem extends AuctionBaseGUI { if (Settings.STORE_PAYMENTS_FOR_MANUAL_COLLECTION.getBoolean()) AuctionHouse.getInstance().getDataManager().insertAuctionPayment(new AuctionPayment(oldBidder.getUniqueId(), auctionItem.getCurrentPrice(), auctionItem.getItem(), click.player.getName(), PaymentReason.ADMIN_REMOVED), null); - else EconomyManager.deposit(oldBidder, auctionItem.getCurrentPrice()); + else AuctionHouse.getCurrencyManager().deposit(oldBidder, auctionItem.getCurrentPrice()); if (oldBidder.isOnline()) - AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(this.auctionItem.getCurrentPrice())).sendPrefixedMessage(oldBidder.getPlayer()); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(this.auctionItem.getCurrentPrice())).sendPrefixedMessage(oldBidder.getPlayer()); } @@ -132,7 +131,7 @@ public class GUIAdminItem extends AuctionBaseGUI { private void drawDeleteButton() { if (Settings.ADMIN_OPTION_SHOW_DELETE_ITEM.getBoolean()) - setButton(1, 5, QuickItem.of(Settings.GUI_ITEM_ADMIN_ITEMS_DELETE_ITEM.getString()).name(Settings.GUI_ITEM_ADMIN_ITEMS_DELETE_NAME.getString()).lore(this.player,Settings.GUI_ITEM_ADMIN_ITEMS_DELETE_LORE.getStringList()).make(), click -> { + setButton(1, 5, QuickItem.of(Settings.GUI_ITEM_ADMIN_ITEMS_DELETE_ITEM.getString()).name(Settings.GUI_ITEM_ADMIN_ITEMS_DELETE_NAME.getString()).lore(this.player, Settings.GUI_ITEM_ADMIN_ITEMS_DELETE_LORE.getStringList()).make(), click -> { if (!click.player.hasPermission("auctionhouse.admin.deleteitem")) return; AuctionAdminEvent event = new AuctionAdminEvent(createLog(click.player, AdminAction.DELETE_ITEM)); @@ -151,10 +150,10 @@ public class GUIAdminItem extends AuctionBaseGUI { PaymentReason.ADMIN_REMOVED ), null); else - EconomyManager.deposit(oldBidder, auctionItem.getCurrentPrice()); + AuctionHouse.getCurrencyManager().deposit(oldBidder, auctionItem.getCurrentPrice()); if (oldBidder.isOnline()) - AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(this.auctionItem.getCurrentPrice())).sendPrefixedMessage(oldBidder.getPlayer()); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(this.auctionItem.getCurrentPrice())).sendPrefixedMessage(oldBidder.getPlayer()); } @@ -165,7 +164,7 @@ public class GUIAdminItem extends AuctionBaseGUI { private void drawCopyButton() { if (Settings.ADMIN_OPTION_SHOW_COPY_ITEM.getBoolean()) - setButton(1, 7, QuickItem.of(Settings.GUI_ITEM_ADMIN_ITEMS_COPY_ITEM.getString()).name(Settings.GUI_ITEM_ADMIN_ITEMS_COPY_NAME.getString()).lore(this.player,Settings.GUI_ITEM_ADMIN_ITEMS_COPY_LORE.getStringList()).make(), click -> { + setButton(1, 7, QuickItem.of(Settings.GUI_ITEM_ADMIN_ITEMS_COPY_ITEM.getString()).name(Settings.GUI_ITEM_ADMIN_ITEMS_COPY_NAME.getString()).lore(this.player, Settings.GUI_ITEM_ADMIN_ITEMS_COPY_LORE.getStringList()).make(), click -> { if (!click.player.hasPermission("auctionhouse.admin.copyitem")) return; if (Settings.ITEM_COPY_REQUIRES_GMC.getBoolean() && click.player.getGameMode() != GameMode.CREATIVE) { diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminLogs.java b/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminLogs.java index 21afc97..14cf5d1 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminLogs.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminLogs.java @@ -60,7 +60,7 @@ public final class GUIAdminLogs extends AuctionPagedGUI { return QuickItem .of(log.getItem()) .name(AuctionAPI.getInstance().getItemName(log.getItem())) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_LOGS_LORE.getStringList(), + .lore(this.player, Replacer.replaceVariables(Settings.GUI_LOGS_LORE.getStringList(), "admin", log.getAdminName(), "target", log.getTargetName(), "admin_uuid", log.getAdmin(), diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIMinItemPrices.java b/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIMinItemPrices.java index c21d45f..feb611c 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIMinItemPrices.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIMinItemPrices.java @@ -58,7 +58,7 @@ public final class GUIMinItemPrices extends AuctionPagedGUI { return QuickItem .of(minItemPrice.getItemStack().clone()) .name(AuctionAPI.getInstance().getItemName(minItemPrice.getItemStack())) - .lore(this.player,Replacer.replaceVariables(lore, "price", AuctionAPI.getInstance().formatNumber(minItemPrice.getPrice()))) + .lore(this.player, Replacer.replaceVariables(lore, "price", AuctionAPI.getInstance().formatNumber(minItemPrice.getPrice()))) .make(); } diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/admin/bans/GUIBanTypeSelection.java b/src/main/java/ca/tweetzy/auctionhouse/guis/admin/bans/GUIBanTypeSelection.java index 51f2341..0ae741c 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/admin/bans/GUIBanTypeSelection.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/admin/bans/GUIBanTypeSelection.java @@ -38,7 +38,7 @@ public final class GUIBanTypeSelection extends AuctionPagedGUI { return QuickItem .of(this.ban.getTypes().contains(banType) ? CompMaterial.LIME_STAINED_GLASS_PANE : CompMaterial.RED_STAINED_GLASS_PANE) .name(Settings.GUI_BAN_TYPES_ITEMS_TYPE_NAME.getString().replace("%ban_type%", ChatUtil.capitalizeFully(banType))) - .lore(this.player,Settings.GUI_BAN_TYPES_ITEMS_TYPE_LORE.getStringList()) + .lore(this.player, Settings.GUI_BAN_TYPES_ITEMS_TYPE_LORE.getStringList()) .make(); } diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/admin/bans/GUIBanUser.java b/src/main/java/ca/tweetzy/auctionhouse/guis/admin/bans/GUIBanUser.java index a26134a..96252c8 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/admin/bans/GUIBanUser.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/admin/bans/GUIBanUser.java @@ -31,7 +31,7 @@ public final class GUIBanUser extends AuctionBaseGUI { setItem(1, 4, QuickItem .of(Bukkit.getOfflinePlayer(ban.getId())) .name(Settings.GUI_BAN_ITEMS_PLAYER_NAME.getString().replace("%player_name%", this.ban.locatePlayer().getName())) - .lore(this.player,Settings.GUI_BAN_ITEMS_PLAYER_LORE.getStringList()) + .lore(this.player, Settings.GUI_BAN_ITEMS_PLAYER_LORE.getStringList()) .make()); // types @@ -49,7 +49,7 @@ public final class GUIBanUser extends AuctionBaseGUI { setButton(getRows() - 1, 4, QuickItem .of(Settings.GUI_BAN_ITEMS_CREATE_ITEM.getString()) .name(Settings.GUI_BAN_ITEMS_CREATE_NAME.getString()) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_BAN_ITEMS_CREATE_LORE.getStringList())) + .lore(this.player, Replacer.replaceVariables(Settings.GUI_BAN_ITEMS_CREATE_LORE.getStringList())) .make(), click -> { if (this.ban.getTypes().isEmpty()) { @@ -57,7 +57,7 @@ public final class GUIBanUser extends AuctionBaseGUI { return; } - AuctionHouse.getInstance().getBanManager().registerBan(this.ban, created -> { + AuctionHouse.getBanManager().registerBan(this.ban, created -> { if (created) { AuctionHouse.getInstance().getLocale().getMessage("ban.user banned").processPlaceholder("player_name", this.ban.locatePlayer().getName()).sendPrefixedMessage(click.player); AuctionHouse.newChain().sync(click.gui::close).execute(); @@ -70,7 +70,7 @@ public final class GUIBanUser extends AuctionBaseGUI { setButton(3, 1, QuickItem .of(Settings.GUI_BAN_ITEMS_TYPES_ITEM.getString()) .name(Settings.GUI_BAN_ITEMS_TYPES_NAME.getString()) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_BAN_ITEMS_TYPES_LORE.getStringList(), "ban_type_list", this.ban.getBansAsString())) + .lore(this.player, Replacer.replaceVariables(Settings.GUI_BAN_ITEMS_TYPES_LORE.getStringList(), "ban_type_list", this.ban.getBansAsString())) .make(), click -> click.manager.showGUI(click.player, new GUIBanTypeSelection(click.player, this.ban))); } @@ -78,7 +78,7 @@ public final class GUIBanUser extends AuctionBaseGUI { setButton(3, 3, QuickItem .of(Settings.GUI_BAN_ITEMS_PERMA_ITEM.getString()) .name(Settings.GUI_BAN_ITEMS_PERMA_NAME.getString()) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_BAN_ITEMS_PERMA_LORE.getStringList(), "is_true", (this.ban.isPermanent() ? "&aTrue" : "&cFalse"))) + .lore(this.player, Replacer.replaceVariables(Settings.GUI_BAN_ITEMS_PERMA_LORE.getStringList(), "is_true", (this.ban.isPermanent() ? "&aTrue" : "&cFalse"))) .make(), click -> { this.ban.setIsPermanent(!this.ban.isPermanent()); @@ -90,7 +90,7 @@ public final class GUIBanUser extends AuctionBaseGUI { setButton(3, 5, QuickItem .of(Settings.GUI_BAN_ITEMS_REASON_ITEM.getString()) .name(Settings.GUI_BAN_ITEMS_REASON_NAME.getString()) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_BAN_ITEMS_REASON_LORE.getStringList(), "ban_reason", this.ban.getReason())) + .lore(this.player, Replacer.replaceVariables(Settings.GUI_BAN_ITEMS_REASON_LORE.getStringList(), "ban_reason", this.ban.getReason())) .make(), click -> new TitleInput(AuctionHouse.getInstance(), click.player, AuctionHouse.getInstance().getLocale().getMessage("titles.ban reason.title").getMessage(), AuctionHouse.getInstance().getLocale().getMessage("titles.ban reason.subtitle").getMessage()) { @Override @@ -111,7 +111,7 @@ public final class GUIBanUser extends AuctionBaseGUI { setButton(3, 7, QuickItem .of(Settings.GUI_BAN_ITEMS_TIME_ITEM.getString()) .name(Settings.GUI_BAN_ITEMS_TIME_NAME.getString()) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_BAN_ITEMS_TIME_LORE.getStringList(), "ban_time", this.ban.getReadableExpirationDate())) + .lore(this.player, Replacer.replaceVariables(Settings.GUI_BAN_ITEMS_TIME_LORE.getStringList(), "ban_time", this.ban.getReadableExpirationDate())) .make(), click -> new TitleInput(AuctionHouse.getInstance(), click.player, AuctionHouse.getInstance().getLocale().getMessage("titles.ban length.title").getMessage(), AuctionHouse.getInstance().getLocale().getMessage("titles.ban length.subtitle").getMessage()) { @Override diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/admin/bans/GUIBans.java b/src/main/java/ca/tweetzy/auctionhouse/guis/admin/bans/GUIBans.java index cb072a7..f88ac66 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/admin/bans/GUIBans.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/admin/bans/GUIBans.java @@ -30,7 +30,7 @@ public final class GUIBans extends AuctionPagedGUI { return QuickItem .of(Bukkit.getOfflinePlayer(ban.getId())) .name(Settings.GUI_BANS_ITEMS_BAN_NAME.getString().replace("%player_name%", ban.locatePlayer().getName())) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_BANS_ITEMS_BAN_LORE.getStringList(), + .lore(this.player, Replacer.replaceVariables(Settings.GUI_BANS_ITEMS_BAN_LORE.getStringList(), "ban_banner", Bukkit.getOfflinePlayer(ban.getBanner()).getName(), "ban_date", AuctionAPI.getInstance().convertMillisToDate(ban.getTimeCreated()), "ban_expiration", ban.getReadableExpirationDate(), diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmBid.java b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmBid.java index a9b9ec6..b0af895 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmBid.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmBid.java @@ -29,7 +29,6 @@ import ca.tweetzy.auctionhouse.guis.AuctionUpdatingPagedGUI; import ca.tweetzy.auctionhouse.guis.core.GUIAuctionHouse; import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.gui.events.GuiClickEvent; -import ca.tweetzy.core.hooks.EconomyManager; import ca.tweetzy.flight.utils.QuickItem; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; @@ -81,7 +80,7 @@ public class GUIConfirmBid extends AuctionUpdatingPagedGUI { setButton(slot, QuickItem .of(Settings.GUI_CONFIRM_BID_YES_ITEM.getString()) .name(Settings.GUI_CONFIRM_BID_YES_NAME.getString()) - .lore(this.player,Settings.GUI_CONFIRM_BID_YES_LORE.getStringList()) + .lore(this.player, Settings.GUI_CONFIRM_BID_YES_LORE.getStringList()) .make(), click -> { // Re-select the item to ensure that it's available @@ -112,7 +111,7 @@ public class GUIConfirmBid extends AuctionUpdatingPagedGUI { newBiddingAmount = Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(newBiddingAmount) : newBiddingAmount; - if (Settings.PLAYER_NEEDS_TOTAL_PRICE_TO_BID.getBoolean() && !EconomyManager.hasBalance(click.player, newBiddingAmount)) { + if (Settings.PLAYER_NEEDS_TOTAL_PRICE_TO_BID.getBoolean() && !AuctionHouse.getCurrencyManager().has(click.player, newBiddingAmount)) { AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(click.player); return; } @@ -129,7 +128,7 @@ public class GUIConfirmBid extends AuctionUpdatingPagedGUI { if (Settings.BIDDING_TAKES_MONEY.getBoolean()) { final double oldBidAmount = auctionItem.getCurrentPrice(); - if (!EconomyManager.hasBalance(click.player, newBiddingAmount)) { + if (!AuctionHouse.getCurrencyManager().has(click.player, newBiddingAmount)) { AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(click.player); return; } @@ -148,15 +147,15 @@ public class GUIConfirmBid extends AuctionUpdatingPagedGUI { PaymentReason.BID_RETURNED ), null); else - EconomyManager.deposit(oldBidder, oldBidAmount); + AuctionHouse.getCurrencyManager().deposit(oldBidder, oldBidAmount); if (oldBidder.isOnline()) - AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(oldBidAmount)).sendPrefixedMessage(oldBidder.getPlayer()); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(oldBidAmount)).sendPrefixedMessage(oldBidder.getPlayer()); } - EconomyManager.withdrawBalance(click.player, newBiddingAmount); - AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(click.player))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(newBiddingAmount)).sendPrefixedMessage(click.player); + AuctionHouse.getCurrencyManager().withdraw(click.player, newBiddingAmount); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(click.player))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(newBiddingAmount)).sendPrefixedMessage(click.player); } @@ -205,7 +204,7 @@ public class GUIConfirmBid extends AuctionUpdatingPagedGUI { setButton(slot, QuickItem .of(Settings.GUI_CONFIRM_BID_NO_ITEM.getString()) .name(Settings.GUI_CONFIRM_BID_NO_NAME.getString()) - .lore(this.player,Settings.GUI_CONFIRM_BID_NO_LORE.getStringList()) + .lore(this.player, Settings.GUI_CONFIRM_BID_NO_LORE.getStringList()) .make(), click -> { cancelTask(); diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmCancel.java b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmCancel.java index 6bf557d..1d1a76f 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmCancel.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmCancel.java @@ -28,7 +28,6 @@ import ca.tweetzy.auctionhouse.auction.enums.PaymentReason; import ca.tweetzy.auctionhouse.guis.AuctionBaseGUI; import ca.tweetzy.auctionhouse.guis.core.GUIActiveAuctions; import ca.tweetzy.auctionhouse.settings.Settings; -import ca.tweetzy.core.hooks.EconomyManager; import ca.tweetzy.flight.utils.QuickItem; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; @@ -68,7 +67,7 @@ public class GUIConfirmCancel extends AuctionBaseGUI { setButton(slot, QuickItem .of(Settings.GUI_CONFIRM_CANCEL_NO_ITEM.getString()) .name(Settings.GUI_CONFIRM_CANCEL_NO_NAME.getString()) - .lore(this.player,Settings.GUI_CONFIRM_CANCEL_NO_LORE.getStringList()) + .lore(this.player, Settings.GUI_CONFIRM_CANCEL_NO_LORE.getStringList()) .make(), click -> click.manager.showGUI(click.player, new GUIActiveAuctions(this.auctionPlayer))); } @@ -76,7 +75,7 @@ public class GUIConfirmCancel extends AuctionBaseGUI { setButton(slot, QuickItem .of(Settings.GUI_CONFIRM_CANCEL_YES_ITEM.getString()) .name(Settings.GUI_CONFIRM_CANCEL_YES_NAME.getString()) - .lore(this.player,Settings.GUI_CONFIRM_CANCEL_YES_LORE.getStringList()) + .lore(this.player, Settings.GUI_CONFIRM_CANCEL_YES_LORE.getStringList()) .make(), click -> { // Re-select the item to ensure that it's available @@ -101,10 +100,10 @@ public class GUIConfirmCancel extends AuctionBaseGUI { ), null); else - EconomyManager.deposit(oldBidder, located.getCurrentPrice()); + AuctionHouse.getCurrencyManager().deposit(oldBidder, located.getCurrentPrice()); if (oldBidder.isOnline()) - AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(located.getCurrentPrice())).sendPrefixedMessage(oldBidder.getPlayer()); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(located.getCurrentPrice())).sendPrefixedMessage(oldBidder.getPlayer()); } diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmPurchase.java b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmPurchase.java index abeb85e..b7adad3 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmPurchase.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmPurchase.java @@ -34,7 +34,6 @@ import ca.tweetzy.auctionhouse.guis.core.GUIContainerInspect; import ca.tweetzy.auctionhouse.managers.SoundManager; import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.gui.events.GuiClickEvent; -import ca.tweetzy.core.hooks.EconomyManager; import ca.tweetzy.core.utils.PlayerUtils; import ca.tweetzy.flight.nbtapi.NBT; import ca.tweetzy.flight.utils.QuickItem; @@ -155,14 +154,14 @@ public class GUIConfirmPurchase extends AuctionBaseGUI { final OfflinePlayer requester = Bukkit.getOfflinePlayer(this.auctionItem.getOwner()); // check if the requester even has money - if (!EconomyManager.hasBalance(requester, buyNowPrice)) { + if (!AuctionHouse.getCurrencyManager().has(requester, buyNowPrice)) { AuctionHouse.getInstance().getLocale().getMessage("general.requesterhasnomoney").sendPrefixedMessage(e.player); return; } // transfer funds - EconomyManager.withdrawBalance(requester, buyNowPrice); - EconomyManager.deposit(e.player, Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? buyNowPrice : buyNowPrice - tax); + AuctionHouse.getCurrencyManager().withdraw(requester, buyNowPrice); + AuctionHouse.getCurrencyManager().deposit(e.player, Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? buyNowPrice : buyNowPrice - tax); // transfer items AuctionAPI.getInstance().removeSpecificItemQuantityFromPlayer(this.player, this.auctionItem.getItem(), amountNeeded); @@ -191,9 +190,9 @@ public class GUIConfirmPurchase extends AuctionBaseGUI { player.closeInventory(); }); - AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(e.player))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(this.auctionItem.getBasePrice())).sendPrefixedMessage(e.player); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(e.player))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(this.auctionItem.getBasePrice())).sendPrefixedMessage(e.player); if (requester.isOnline()) - AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(requester.getPlayer()))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(this.auctionItem.getBasePrice())).sendPrefixedMessage(requester.getPlayer()); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(requester.getPlayer()))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(this.auctionItem.getBasePrice())).sendPrefixedMessage(requester.getPlayer()); e.gui.close(); return; @@ -204,7 +203,7 @@ public class GUIConfirmPurchase extends AuctionBaseGUI { // languageNodes.put("pricing.moneyadd", "&a&l+ $%price% &7(%player_balance%)"); // Check economy - if (!EconomyManager.hasBalance(e.player, buyNowPrice + (Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? tax : 0D))) { + if (!AuctionHouse.getCurrencyManager().has(e.player, buyNowPrice + (Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? tax : 0D))) { AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player); SoundManager.getInstance().playSound(e.player, Settings.SOUNDS_NOT_ENOUGH_MONEY.getString()); e.gui.close(); @@ -263,10 +262,10 @@ public class GUIConfirmPurchase extends AuctionBaseGUI { PaymentReason.BID_RETURNED ), null); else - EconomyManager.deposit(oldBidder, auctionItem.getCurrentPrice()); + AuctionHouse.getCurrencyManager().deposit(oldBidder, auctionItem.getCurrentPrice()); if (oldBidder.isOnline()) - AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(located.getCurrentPrice())).sendPrefixedMessage(oldBidder.getPlayer()); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(located.getCurrentPrice())).sendPrefixedMessage(oldBidder.getPlayer()); } @@ -338,7 +337,7 @@ public class GUIConfirmPurchase extends AuctionBaseGUI { double totalPrice = overwritePrice ? price : located.getBasePrice(); double tax = Settings.TAX_ENABLED.getBoolean() ? (Settings.TAX_SALES_TAX_BUY_NOW_PERCENTAGE.getDouble() / 100) * totalPrice : 0D; - AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(e.player))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? totalPrice - tax : totalPrice)).sendPrefixedMessage(e.player); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(e.player))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? totalPrice - tax : totalPrice)).sendPrefixedMessage(e.player); AuctionHouse.getInstance().getLocale().getMessage("general.bought_item").processPlaceholder("amount", qtyOverride).processPlaceholder("item", AuctionAPI.getInstance().getItemName(located.getItem())).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? totalPrice - tax : totalPrice)).sendPrefixedMessage(e.player); if (Bukkit.getOfflinePlayer(located.getOwner()).isOnline()) { @@ -348,7 +347,7 @@ public class GUIConfirmPurchase extends AuctionBaseGUI { .processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? totalPrice : totalPrice - tax)) .processPlaceholder("buyer_name", e.player.getName()) .sendPrefixedMessage(Bukkit.getOfflinePlayer(located.getOwner()).getPlayer()); - AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(Bukkit.getOfflinePlayer(located.getOwner())))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? totalPrice : totalPrice - tax)).sendPrefixedMessage(Bukkit.getOfflinePlayer(located.getOwner()).getPlayer()); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(Bukkit.getOfflinePlayer(located.getOwner())))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? totalPrice : totalPrice - tax)).sendPrefixedMessage(Bukkit.getOfflinePlayer(located.getOwner()).getPlayer()); } } @@ -361,7 +360,7 @@ public class GUIConfirmPurchase extends AuctionBaseGUI { .of(Settings.GUI_CONFIRM_QTY_INFO_ITEM.getString()) .amount(qty) .name(Settings.GUI_CONFIRM_QTY_INFO_NAME.getString()) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_CONFIRM_QTY_INFO_LORE.getStringList(), + .lore(this.player, Replacer.replaceVariables(Settings.GUI_CONFIRM_QTY_INFO_LORE.getStringList(), "original_stack_size", maxStackSize, "original_stack_price", AuctionAPI.getInstance().formatNumber(auctionItem.getBasePrice()), "price_per_item", AuctionAPI.getInstance().formatNumber(pricePerItem), @@ -372,26 +371,26 @@ public class GUIConfirmPurchase extends AuctionBaseGUI { } private ItemStack getIncreaseQtyButtonItem() { - return QuickItem.of(Settings.GUI_CONFIRM_INCREASE_QTY_ITEM.getString()).name(Settings.GUI_CONFIRM_INCREASE_QTY_NAME.getString()).lore(this.player,Settings.GUI_CONFIRM_INCREASE_QTY_LORE.getStringList()).make(); + return QuickItem.of(Settings.GUI_CONFIRM_INCREASE_QTY_ITEM.getString()).name(Settings.GUI_CONFIRM_INCREASE_QTY_NAME.getString()).lore(this.player, Settings.GUI_CONFIRM_INCREASE_QTY_LORE.getStringList()).make(); } private ItemStack getDecreaseQtyButtonItem() { - return QuickItem.of(Settings.GUI_CONFIRM_DECREASE_QTY_ITEM.getString()).name(Settings.GUI_CONFIRM_DECREASE_QTY_NAME.getString()).lore(this.player,Settings.GUI_CONFIRM_DECREASE_QTY_LORE.getStringList()).make(); + return QuickItem.of(Settings.GUI_CONFIRM_DECREASE_QTY_ITEM.getString()).name(Settings.GUI_CONFIRM_DECREASE_QTY_NAME.getString()).lore(this.player, Settings.GUI_CONFIRM_DECREASE_QTY_LORE.getStringList()).make(); } protected ItemStack getConfirmBuyYesItem() { - return QuickItem.of(Settings.GUI_CONFIRM_BUY_YES_ITEM.getString()).name(Settings.GUI_CONFIRM_BUY_YES_NAME.getString()).lore(this.player,Settings.GUI_CONFIRM_BUY_YES_LORE.getStringList()).make(); + return QuickItem.of(Settings.GUI_CONFIRM_BUY_YES_ITEM.getString()).name(Settings.GUI_CONFIRM_BUY_YES_NAME.getString()).lore(this.player, Settings.GUI_CONFIRM_BUY_YES_LORE.getStringList()).make(); } protected ItemStack getConfirmBuyNoItem() { - return QuickItem.of(Settings.GUI_CONFIRM_BUY_NO_ITEM.getString()).name(Settings.GUI_CONFIRM_BUY_NO_NAME.getString()).lore(this.player,Settings.GUI_CONFIRM_BUY_NO_LORE.getStringList()).make(); + return QuickItem.of(Settings.GUI_CONFIRM_BUY_NO_ITEM.getString()).name(Settings.GUI_CONFIRM_BUY_NO_NAME.getString()).lore(this.player, Settings.GUI_CONFIRM_BUY_NO_LORE.getStringList()).make(); } protected ItemStack getConfirmRequestYesItem() { - return QuickItem.of(Settings.GUI_CONFIRM_REQUEST_YES_ITEM.getString()).name(Settings.GUI_CONFIRM_REQUEST_YES_NAME.getString()).lore(this.player,Settings.GUI_CONFIRM_REQUEST_YES_LORE.getStringList()).make(); + return QuickItem.of(Settings.GUI_CONFIRM_REQUEST_YES_ITEM.getString()).name(Settings.GUI_CONFIRM_REQUEST_YES_NAME.getString()).lore(this.player, Settings.GUI_CONFIRM_REQUEST_YES_LORE.getStringList()).make(); } protected ItemStack getConfirmRequestNoItem() { - return QuickItem.of(Settings.GUI_CONFIRM_REQUEST_NO_ITEM.getString()).name(Settings.GUI_CONFIRM_REQUEST_NO_NAME.getString()).lore(this.player,Settings.GUI_CONFIRM_REQUEST_NO_LORE.getStringList()).make(); + return QuickItem.of(Settings.GUI_CONFIRM_REQUEST_NO_ITEM.getString()).name(Settings.GUI_CONFIRM_REQUEST_NO_NAME.getString()).lore(this.player, Settings.GUI_CONFIRM_REQUEST_NO_LORE.getStringList()).make(); } } diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIListingConfirm.java b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIListingConfirm.java index 1c94006..14b7cac 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIListingConfirm.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIListingConfirm.java @@ -94,7 +94,7 @@ public final class GUIListingConfirm extends AuctionBaseGUI { setButton(slot, QuickItem .of(Settings.GUI_CONFIRM_LISTING_NO_ITEM.getString()) .name(Settings.GUI_CONFIRM_LISTING_NO_NAME.getString()) - .lore(this.player,Settings.GUI_CONFIRM_LISTING_NO_LORE.getStringList()) + .lore(this.player, Settings.GUI_CONFIRM_LISTING_NO_LORE.getStringList()) .make(), click -> { if (resulted.contains(click.player.getUniqueId())) return; @@ -111,7 +111,7 @@ public final class GUIListingConfirm extends AuctionBaseGUI { setButton(slot, QuickItem .of(Settings.GUI_CONFIRM_LISTING_YES_ITEM.getString()) .name(Settings.GUI_CONFIRM_LISTING_YES_NAME.getString()) - .lore(this.player,Settings.GUI_CONFIRM_LISTING_YES_LORE.getStringList()) + .lore(this.player, Settings.GUI_CONFIRM_LISTING_YES_LORE.getStringList()) .make(), click -> { if (resulted.contains(click.player.getUniqueId())) return; diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/core/GUIActiveAuctions.java b/src/main/java/ca/tweetzy/auctionhouse/guis/core/GUIActiveAuctions.java index f09d6c5..74a5b47 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/core/GUIActiveAuctions.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/core/GUIActiveAuctions.java @@ -29,7 +29,6 @@ import ca.tweetzy.auctionhouse.guis.AuctionUpdatingPagedGUI; import ca.tweetzy.auctionhouse.guis.confirmation.GUIConfirmCancel; import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.gui.events.GuiClickEvent; -import ca.tweetzy.core.hooks.EconomyManager; import ca.tweetzy.flight.utils.Common; import ca.tweetzy.flight.utils.QuickItem; import ca.tweetzy.flight.utils.messages.Titles; @@ -111,10 +110,10 @@ public class GUIActiveAuctions extends AuctionUpdatingPagedGUI { PaymentReason.BID_RETURNED ), null); else - EconomyManager.deposit(oldBidder, item.getCurrentPrice()); + AuctionHouse.getCurrencyManager().deposit(oldBidder, item.getCurrentPrice()); if (oldBidder.isOnline()) - AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(item.getCurrentPrice())).sendPrefixedMessage(oldBidder.getPlayer()); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(item.getCurrentPrice())).sendPrefixedMessage(oldBidder.getPlayer()); } @@ -157,7 +156,7 @@ public class GUIActiveAuctions extends AuctionUpdatingPagedGUI { setButton(5, 1, QuickItem .of(Settings.GUI_ACTIVE_AUCTIONS_ITEM.getString()) .name(Settings.GUI_ACTIVE_AUCTIONS_NAME.getString()) - .lore(this.player,Settings.GUI_ACTIVE_AUCTIONS_LORE.getStringList()) + .lore(this.player, Settings.GUI_ACTIVE_AUCTIONS_LORE.getStringList()) .make(), e -> { if (Settings.ASK_FOR_CANCEL_CONFIRM_ON_ALL_ITEMS.getBoolean()) { diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/core/GUIAuctionHouse.java b/src/main/java/ca/tweetzy/auctionhouse/guis/core/GUIAuctionHouse.java index 2db5cb8..1125cea 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/core/GUIAuctionHouse.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/core/GUIAuctionHouse.java @@ -24,7 +24,6 @@ import ca.tweetzy.auctionhouse.helpers.input.TitleInput; import ca.tweetzy.auctionhouse.hooks.FloodGateHook; import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.gui.events.GuiClickEvent; -import ca.tweetzy.core.hooks.EconomyManager; import ca.tweetzy.core.utils.NumberUtils; import ca.tweetzy.flight.comp.enums.ServerVersion; import ca.tweetzy.flight.utils.QuickItem; @@ -198,7 +197,7 @@ public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI { + .lore(this.player, Replacer.replaceVariables(Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_LORE.getStringList(), "active_player_auctions", auctionPlayer.getItems(false).size(), "player_balance", Settings.USE_SHORT_NUMBERS_ON_PLAYER_BALANCE.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(AuctionHouse.getCurrencyManager().getBalance(auctionPlayer.getPlayer())) : AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(auctionPlayer.getPlayer())))).make(), e -> { cancelTask(); e.manager.showGUI(e.player, new GUIActiveAuctions(this.auctionPlayer)); @@ -469,7 +468,7 @@ public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI { if (AuctionHouse.getInstance().getBanManager().isStillBanned(e.player, BanType.EVERYTHING, BanType.SELL)) return; @@ -516,7 +515,7 @@ public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI { @@ -629,7 +628,7 @@ public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI { diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/core/GUIExpiredItems.java b/src/main/java/ca/tweetzy/auctionhouse/guis/core/GUIExpiredItems.java index 8daafd8..6962225 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/core/GUIExpiredItems.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/core/GUIExpiredItems.java @@ -123,14 +123,14 @@ public class GUIExpiredItems extends AuctionPagedGUI { if (Settings.STORE_PAYMENTS_FOR_MANUAL_COLLECTION.getBoolean()) { setButton(5, 2, QuickItem .of(Settings.GUI_EXPIRED_AUCTIONS_PAYMENTS_ITEM.getString()) - .name(Settings.GUI_EXPIRED_AUCTIONS_PAYMENTS_NAME.getString()).lore(this.player,Settings.GUI_EXPIRED_AUCTIONS_PAYMENTS_LORE.getStringList()) + .name(Settings.GUI_EXPIRED_AUCTIONS_PAYMENTS_NAME.getString()).lore(this.player, Settings.GUI_EXPIRED_AUCTIONS_PAYMENTS_LORE.getStringList()) .make(), e -> e.manager.showGUI(e.player, new GUIPaymentCollection(this, this.auctionPlayer))); } setButton(5, 1, QuickItem .of(Settings.GUI_EXPIRED_AUCTIONS_ITEM.getString()) .name(Settings.GUI_EXPIRED_AUCTIONS_NAME.getString()) - .lore(this.player,Settings.GUI_EXPIRED_AUCTIONS_LORE.getStringList()) + .lore(this.player, Settings.GUI_EXPIRED_AUCTIONS_LORE.getStringList()) .make(), e -> { if (AuctionHouse.getInstance().getBanManager().isStillBanned(e.player, BanType.EVERYTHING, BanType.ITEM_COLLECTION)) return; diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/core/GUIPaymentCollection.java b/src/main/java/ca/tweetzy/auctionhouse/guis/core/GUIPaymentCollection.java index 8dcb338..447110f 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/core/GUIPaymentCollection.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/core/GUIPaymentCollection.java @@ -67,7 +67,7 @@ public class GUIPaymentCollection extends AuctionPagedGUI { return QuickItem .of(Settings.GUI_PAYMENT_COLLECTION_PAYMENT_ITEM.getString()) .name(Replacer.replaceVariables(Settings.GUI_PAYMENT_COLLECTION_PAYMENT_NAME.getString(), "payment_amount", AuctionAPI.getInstance().formatNumber(payment.getAmount()))) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_PAYMENT_COLLECTION_PAYMENT_LORE.getStringList(), + .lore(this.player, Replacer.replaceVariables(Settings.GUI_PAYMENT_COLLECTION_PAYMENT_LORE.getStringList(), "item_name", AuctionAPI.getInstance().getItemName(payment.getItem()), "from_name", payment.getFromName(), "payment_reason", payment.getReason().getTranslation() @@ -98,7 +98,7 @@ public class GUIPaymentCollection extends AuctionPagedGUI { setButton(5, 1, QuickItem.of(Settings.GUI_PAYMENT_COLLECTION_ITEM.getString()) .name(Settings.GUI_PAYMENT_COLLECTION_NAME.getString()) - .lore(this.player,Settings.GUI_PAYMENT_COLLECTION_LORE.getStringList()) + .lore(this.player, Settings.GUI_PAYMENT_COLLECTION_LORE.getStringList()) .make(), e -> { if (this.lastClicked == null) { diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/core/bid/GUIBid.java b/src/main/java/ca/tweetzy/auctionhouse/guis/core/bid/GUIBid.java index 29d9090..79e608a 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/core/bid/GUIBid.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/core/bid/GUIBid.java @@ -30,7 +30,6 @@ import ca.tweetzy.auctionhouse.guis.confirmation.GUIConfirmBid; import ca.tweetzy.auctionhouse.guis.core.GUIAuctionHouse; import ca.tweetzy.auctionhouse.helpers.input.TitleInput; import ca.tweetzy.auctionhouse.settings.Settings; -import ca.tweetzy.core.hooks.EconomyManager; import ca.tweetzy.core.utils.NumberUtils; import ca.tweetzy.flight.utils.QuickItem; import org.bukkit.Bukkit; @@ -66,9 +65,9 @@ public class GUIBid extends AuctionBaseGUI { setButton(1, 2, QuickItem .of(Settings.GUI_BIDDING_ITEMS_DEFAULT_ITEM.getString()) .name(Settings.GUI_BIDDING_ITEMS_DEFAULT_NAME.getString()) - .lore(this.player,Settings.GUI_BIDDING_ITEMS_DEFAULT_LORE.getStringList()).make(), e -> { + .lore(this.player, Settings.GUI_BIDDING_ITEMS_DEFAULT_LORE.getStringList()).make(), e -> { - if (Settings.PLAYER_NEEDS_TOTAL_PRICE_TO_BID.getBoolean() && !EconomyManager.hasBalance(e.player, auctionItem.getCurrentPrice() + auctionItem.getBidIncrementPrice())) { + if (Settings.PLAYER_NEEDS_TOTAL_PRICE_TO_BID.getBoolean() && !AuctionHouse.getCurrencyManager().has(e.player, auctionItem.getCurrentPrice() + auctionItem.getBidIncrementPrice())) { AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player); return; } @@ -83,7 +82,7 @@ public class GUIBid extends AuctionBaseGUI { setButton(1, 6, QuickItem .of(Settings.GUI_BIDDING_ITEMS_CUSTOM_ITEM.getString()) .name(Settings.GUI_BIDDING_ITEMS_CUSTOM_NAME.getString()) - .lore(this.player,Settings.GUI_BIDDING_ITEMS_CUSTOM_LORE.getStringList()) + .lore(this.player, Settings.GUI_BIDDING_ITEMS_CUSTOM_LORE.getStringList()) .make(), e -> { e.gui.exit(); @@ -145,7 +144,7 @@ public class GUIBid extends AuctionBaseGUI { newBiddingAmount = Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(newBiddingAmount) : newBiddingAmount; - if (Settings.PLAYER_NEEDS_TOTAL_PRICE_TO_BID.getBoolean() && !EconomyManager.hasBalance(e.player, newBiddingAmount)) { + if (Settings.PLAYER_NEEDS_TOTAL_PRICE_TO_BID.getBoolean() && !AuctionHouse.getCurrencyManager().has(e.player, newBiddingAmount)) { AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player); return true; } @@ -167,7 +166,7 @@ public class GUIBid extends AuctionBaseGUI { if (Settings.BIDDING_TAKES_MONEY.getBoolean()) { final double oldBidAmount = auctionItem.getCurrentPrice(); - if (!EconomyManager.hasBalance(e.player, newBiddingAmount)) { + if (!AuctionHouse.getCurrencyManager().has(e.player, newBiddingAmount)) { AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player); return true; } @@ -186,13 +185,13 @@ public class GUIBid extends AuctionBaseGUI { PaymentReason.BID_RETURNED ), null); else - EconomyManager.deposit(oldBidder, oldBidAmount); + AuctionHouse.getCurrencyManager().deposit(oldBidder, oldBidAmount); if (oldBidder.isOnline()) - AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(oldBidAmount)).sendPrefixedMessage(oldBidder.getPlayer()); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(oldBidAmount)).sendPrefixedMessage(oldBidder.getPlayer()); } - EconomyManager.withdrawBalance(e.player, newBiddingAmount); - AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(e.player))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(newBiddingAmount)).sendPrefixedMessage(e.player); + AuctionHouse.getCurrencyManager().withdraw(e.player, newBiddingAmount); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(e.player))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(newBiddingAmount)).sendPrefixedMessage(e.player); } diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/filter/GUIFilterSelection.java b/src/main/java/ca/tweetzy/auctionhouse/guis/filter/GUIFilterSelection.java index 274abfc..0d30e9a 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/filter/GUIFilterSelection.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/filter/GUIFilterSelection.java @@ -54,21 +54,21 @@ public class GUIFilterSelection extends AuctionBaseGUI { protected void draw() { if (AuctionItemCategory.ALL.isEnabled()) - setButton(1, 3, QuickItem.of(Settings.GUI_FILTER_ITEMS_ALL_ITEM.getString()).name(Settings.GUI_FILTER_ITEMS_ALL_NAME.getString()).lore(this.player,Settings.GUI_FILTER_ITEMS_ALL_LORE.getStringList()).make(), e -> { + setButton(1, 3, QuickItem.of(Settings.GUI_FILTER_ITEMS_ALL_ITEM.getString()).name(Settings.GUI_FILTER_ITEMS_ALL_NAME.getString()).lore(this.player, Settings.GUI_FILTER_ITEMS_ALL_LORE.getStringList()).make(), e -> { this.auctionPlayer.setSelectedFilter(AuctionItemCategory.ALL); updatePlayerFilter(this.auctionPlayer); e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer)); }); if (AuctionItemCategory.SELF.isEnabled()) - setButton(1, 4, QuickItem.of(this.player).name(Settings.GUI_FILTER_ITEMS_OWN_NAME.getString()).lore(this.player,Settings.GUI_FILTER_ITEMS_OWN_LORE.getStringList()).make(), e -> { + setButton(1, 4, QuickItem.of(this.player).name(Settings.GUI_FILTER_ITEMS_OWN_NAME.getString()).lore(this.player, Settings.GUI_FILTER_ITEMS_OWN_LORE.getStringList()).make(), e -> { this.auctionPlayer.setSelectedFilter(AuctionItemCategory.SELF); updatePlayerFilter(this.auctionPlayer); e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer)); }); if (AuctionItemCategory.SEARCH.isEnabled()) - setButton(1, 5, QuickItem.of(Settings.GUI_FILTER_ITEMS_SEARCH_ITEM.getString()).name(Settings.GUI_FILTER_ITEMS_SEARCH_NAME.getString()).lore(this.player,Replacer.replaceVariables(Settings.GUI_FILTER_ITEMS_SEARCH_LORE.getStringList(), "filter_search_phrase", this.auctionPlayer.getCurrentSearchPhrase())).make(), e -> { + setButton(1, 5, QuickItem.of(Settings.GUI_FILTER_ITEMS_SEARCH_ITEM.getString()).name(Settings.GUI_FILTER_ITEMS_SEARCH_NAME.getString()).lore(this.player, Replacer.replaceVariables(Settings.GUI_FILTER_ITEMS_SEARCH_LORE.getStringList(), "filter_search_phrase", this.auctionPlayer.getCurrentSearchPhrase())).make(), e -> { if (!e.player.hasPermission("auctionhouse.cmd.search")) { AuctionHouse.getInstance().getLocale().getMessage("commands.no_permission").sendPrefixedMessage(e.player); return; @@ -86,56 +86,56 @@ public class GUIFilterSelection extends AuctionBaseGUI { }); if (AuctionItemCategory.MISC.isEnabled()) - setButton(2, 1, QuickItem.of(Settings.GUI_FILTER_ITEMS_MISC_ITEM.getString()).name(Settings.GUI_FILTER_ITEMS_MISC_NAME.getString()).lore(this.player,Settings.GUI_FILTER_ITEMS_MISC_LORE.getStringList()).make(), e -> { + setButton(2, 1, QuickItem.of(Settings.GUI_FILTER_ITEMS_MISC_ITEM.getString()).name(Settings.GUI_FILTER_ITEMS_MISC_NAME.getString()).lore(this.player, Settings.GUI_FILTER_ITEMS_MISC_LORE.getStringList()).make(), e -> { this.auctionPlayer.setSelectedFilter(AuctionItemCategory.MISC); updatePlayerFilter(this.auctionPlayer); e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer)); }); if (AuctionItemCategory.ENCHANTS.isEnabled()) - setButton(2, 2, QuickItem.of(Settings.GUI_FILTER_ITEMS_ENCHANTS_ITEM.getString()).name(Settings.GUI_FILTER_ITEMS_ENCHANTS_NAME.getString()).lore(this.player,Settings.GUI_FILTER_ITEMS_ENCHANTS_LORE.getStringList()).make(), e -> { + setButton(2, 2, QuickItem.of(Settings.GUI_FILTER_ITEMS_ENCHANTS_ITEM.getString()).name(Settings.GUI_FILTER_ITEMS_ENCHANTS_NAME.getString()).lore(this.player, Settings.GUI_FILTER_ITEMS_ENCHANTS_LORE.getStringList()).make(), e -> { this.auctionPlayer.setSelectedFilter(AuctionItemCategory.ENCHANTS); updatePlayerFilter(this.auctionPlayer); e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer)); }); if (AuctionItemCategory.ARMOR.isEnabled()) - setButton(2, 3, QuickItem.of(Settings.GUI_FILTER_ITEMS_ARMOR_ITEM.getString()).name(Settings.GUI_FILTER_ITEMS_ARMOR_NAME.getString()).lore(this.player,Settings.GUI_FILTER_ITEMS_ARMOR_LORE.getStringList()).make(), e -> { + setButton(2, 3, QuickItem.of(Settings.GUI_FILTER_ITEMS_ARMOR_ITEM.getString()).name(Settings.GUI_FILTER_ITEMS_ARMOR_NAME.getString()).lore(this.player, Settings.GUI_FILTER_ITEMS_ARMOR_LORE.getStringList()).make(), e -> { this.auctionPlayer.setSelectedFilter(AuctionItemCategory.ARMOR); updatePlayerFilter(this.auctionPlayer); e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer)); }); if (AuctionItemCategory.WEAPONS.isEnabled()) - setButton(2, 4, QuickItem.of(Settings.GUI_FILTER_ITEMS_WEAPONS_ITEM.getString()).name(Settings.GUI_FILTER_ITEMS_WEAPONS_NAME.getString()).lore(this.player,Settings.GUI_FILTER_ITEMS_WEAPONS_LORE.getStringList()).make(), e -> { + setButton(2, 4, QuickItem.of(Settings.GUI_FILTER_ITEMS_WEAPONS_ITEM.getString()).name(Settings.GUI_FILTER_ITEMS_WEAPONS_NAME.getString()).lore(this.player, Settings.GUI_FILTER_ITEMS_WEAPONS_LORE.getStringList()).make(), e -> { this.auctionPlayer.setSelectedFilter(AuctionItemCategory.WEAPONS); updatePlayerFilter(this.auctionPlayer); e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer)); }); if (AuctionItemCategory.TOOLS.isEnabled()) - setButton(2, 5, QuickItem.of(Settings.GUI_FILTER_ITEMS_TOOLS_ITEM.getString()).name(Settings.GUI_FILTER_ITEMS_TOOLS_NAME.getString()).lore(this.player,Settings.GUI_FILTER_ITEMS_TOOLS_LORE.getStringList()).make(), e -> { + setButton(2, 5, QuickItem.of(Settings.GUI_FILTER_ITEMS_TOOLS_ITEM.getString()).name(Settings.GUI_FILTER_ITEMS_TOOLS_NAME.getString()).lore(this.player, Settings.GUI_FILTER_ITEMS_TOOLS_LORE.getStringList()).make(), e -> { this.auctionPlayer.setSelectedFilter(AuctionItemCategory.TOOLS); updatePlayerFilter(this.auctionPlayer); e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer)); }); if (AuctionItemCategory.SPAWNERS.isEnabled()) - setButton(2, 6, QuickItem.of(Settings.GUI_FILTER_ITEMS_SPAWNERS_ITEM.getString()).name(Settings.GUI_FILTER_ITEMS_SPAWNERS_NAME.getString()).lore(this.player,Settings.GUI_FILTER_ITEMS_SPAWNERS_LORE.getStringList()).make(), e -> { + setButton(2, 6, QuickItem.of(Settings.GUI_FILTER_ITEMS_SPAWNERS_ITEM.getString()).name(Settings.GUI_FILTER_ITEMS_SPAWNERS_NAME.getString()).lore(this.player, Settings.GUI_FILTER_ITEMS_SPAWNERS_LORE.getStringList()).make(), e -> { this.auctionPlayer.setSelectedFilter(AuctionItemCategory.SPAWNERS); updatePlayerFilter(this.auctionPlayer); e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer)); }); if (AuctionItemCategory.BLOCKS.isEnabled()) - setButton(2, 7, QuickItem.of(Settings.GUI_FILTER_ITEMS_BLOCKS_ITEM.getString()).name(Settings.GUI_FILTER_ITEMS_BLOCKS_NAME.getString()).lore(this.player,Settings.GUI_FILTER_ITEMS_BLOCKS_LORE.getStringList()).make(), e -> { + setButton(2, 7, QuickItem.of(Settings.GUI_FILTER_ITEMS_BLOCKS_ITEM.getString()).name(Settings.GUI_FILTER_ITEMS_BLOCKS_NAME.getString()).lore(this.player, Settings.GUI_FILTER_ITEMS_BLOCKS_LORE.getStringList()).make(), e -> { this.auctionPlayer.setSelectedFilter(AuctionItemCategory.BLOCKS); updatePlayerFilter(this.auctionPlayer); e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer)); }); if (AuctionItemCategory.POTIONS.isEnabled()) - setButton(3, 4, QuickItem.of(Settings.GUI_FILTER_ITEMS_POTIONS_ITEM.getString()).name(Settings.GUI_FILTER_ITEMS_POTIONS_NAME.getString()).lore(this.player,Settings.GUI_FILTER_ITEMS_POTIONS_LORE.getStringList()).make(), e -> { + setButton(3, 4, QuickItem.of(Settings.GUI_FILTER_ITEMS_POTIONS_ITEM.getString()).name(Settings.GUI_FILTER_ITEMS_POTIONS_NAME.getString()).lore(this.player, Settings.GUI_FILTER_ITEMS_POTIONS_LORE.getStringList()).make(), e -> { this.auctionPlayer.setSelectedFilter(AuctionItemCategory.POTIONS); updatePlayerFilter(this.auctionPlayer); e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer)); diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/filter/GUIFilterWhitelist.java b/src/main/java/ca/tweetzy/auctionhouse/guis/filter/GUIFilterWhitelist.java index c289380..de0cee9 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/filter/GUIFilterWhitelist.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/filter/GUIFilterWhitelist.java @@ -42,41 +42,41 @@ public class GUIFilterWhitelist extends AuctionBaseGUI { protected void draw() { applyBackExit(); - setButton(1, 1, QuickItem.of(Settings.GUI_FILTER_WHITELIST_ITEMS_BLOCKS_ITEM.getString()).name(Settings.GUI_FILTER_WHITELIST_ITEMS_BLOCKS_NAME.getString()).lore(this.player,Settings.GUI_FILTER_WHITELIST_ITEMS_BLOCKS_LORE.getStringList()).make(), e -> { + setButton(1, 1, QuickItem.of(Settings.GUI_FILTER_WHITELIST_ITEMS_BLOCKS_ITEM.getString()).name(Settings.GUI_FILTER_WHITELIST_ITEMS_BLOCKS_NAME.getString()).lore(this.player, Settings.GUI_FILTER_WHITELIST_ITEMS_BLOCKS_LORE.getStringList()).make(), e -> { e.manager.showGUI(e.player, new GUIFilterWhitelistList(e.player, AuctionItemCategory.BLOCKS)); }); - setButton(1, 3, QuickItem.of(Settings.GUI_FILTER_WHITELIST_ITEMS_FOOD_ITEM.getString()).name(Settings.GUI_FILTER_WHITELIST_ITEMS_FOOD_NAME.getString()).lore(this.player,Settings.GUI_FILTER_WHITELIST_ITEMS_FOOD_LORE.getStringList()).make(), e -> { + setButton(1, 3, QuickItem.of(Settings.GUI_FILTER_WHITELIST_ITEMS_FOOD_ITEM.getString()).name(Settings.GUI_FILTER_WHITELIST_ITEMS_FOOD_NAME.getString()).lore(this.player, Settings.GUI_FILTER_WHITELIST_ITEMS_FOOD_LORE.getStringList()).make(), e -> { e.manager.showGUI(e.player, new GUIFilterWhitelistList(e.player, AuctionItemCategory.FOOD)); }); - setButton(1, 5, QuickItem.of(Settings.GUI_FILTER_WHITELIST_ITEMS_ARMOR_ITEM.getString()).name(Settings.GUI_FILTER_WHITELIST_ITEMS_ARMOR_NAME.getString()).lore(this.player,Settings.GUI_FILTER_WHITELIST_ITEMS_ARMOR_LORE.getStringList()).make(), e -> { + setButton(1, 5, QuickItem.of(Settings.GUI_FILTER_WHITELIST_ITEMS_ARMOR_ITEM.getString()).name(Settings.GUI_FILTER_WHITELIST_ITEMS_ARMOR_NAME.getString()).lore(this.player, Settings.GUI_FILTER_WHITELIST_ITEMS_ARMOR_LORE.getStringList()).make(), e -> { e.manager.showGUI(e.player, new GUIFilterWhitelistList(e.player, AuctionItemCategory.ARMOR)); }); - setButton(1, 7, QuickItem.of(Settings.GUI_FILTER_WHITELIST_ITEMS_TOOLS_ITEM.getString()).name(Settings.GUI_FILTER_WHITELIST_ITEMS_TOOLS_NAME.getString()).lore(this.player,Settings.GUI_FILTER_WHITELIST_ITEMS_TOOLS_LORE.getStringList()).make(), e -> { + setButton(1, 7, QuickItem.of(Settings.GUI_FILTER_WHITELIST_ITEMS_TOOLS_ITEM.getString()).name(Settings.GUI_FILTER_WHITELIST_ITEMS_TOOLS_NAME.getString()).lore(this.player, Settings.GUI_FILTER_WHITELIST_ITEMS_TOOLS_LORE.getStringList()).make(), e -> { e.manager.showGUI(e.player, new GUIFilterWhitelistList(e.player, AuctionItemCategory.TOOLS)); }); // 2ND ROW STARTS - setButton(2, 1, QuickItem.of(Settings.GUI_FILTER_WHITELIST_ITEMS_SPAWNERS_ITEM.getString()).name(Settings.GUI_FILTER_WHITELIST_ITEMS_SPAWNERS_NAME.getString()).lore(this.player,Settings.GUI_FILTER_WHITELIST_ITEMS_SPAWNERS_LORE.getStringList()).make(), e -> { + setButton(2, 1, QuickItem.of(Settings.GUI_FILTER_WHITELIST_ITEMS_SPAWNERS_ITEM.getString()).name(Settings.GUI_FILTER_WHITELIST_ITEMS_SPAWNERS_NAME.getString()).lore(this.player, Settings.GUI_FILTER_WHITELIST_ITEMS_SPAWNERS_LORE.getStringList()).make(), e -> { e.manager.showGUI(e.player, new GUIFilterWhitelistList(e.player, AuctionItemCategory.SPAWNERS)); }); - setButton(2, 3, QuickItem.of(Settings.GUI_FILTER_WHITELIST_ITEMS_ENCHANTS_ITEM.getString()).name(Settings.GUI_FILTER_WHITELIST_ITEMS_ENCHANTS_NAME.getString()).lore(this.player,Settings.GUI_FILTER_WHITELIST_ITEMS_ENCHANTS_LORE.getStringList()).make(), e -> { + setButton(2, 3, QuickItem.of(Settings.GUI_FILTER_WHITELIST_ITEMS_ENCHANTS_ITEM.getString()).name(Settings.GUI_FILTER_WHITELIST_ITEMS_ENCHANTS_NAME.getString()).lore(this.player, Settings.GUI_FILTER_WHITELIST_ITEMS_ENCHANTS_LORE.getStringList()).make(), e -> { e.manager.showGUI(e.player, new GUIFilterWhitelistList(e.player, AuctionItemCategory.ENCHANTS)); }); - setButton(2, 5, QuickItem.of(Settings.GUI_FILTER_WHITELIST_ITEMS_WEAPONS_ITEM.getString()).name(Settings.GUI_FILTER_WHITELIST_ITEMS_WEAPONS_NAME.getString()).lore(this.player,Settings.GUI_FILTER_WHITELIST_ITEMS_WEAPONS_LORE.getStringList()).make(), e -> { + setButton(2, 5, QuickItem.of(Settings.GUI_FILTER_WHITELIST_ITEMS_WEAPONS_ITEM.getString()).name(Settings.GUI_FILTER_WHITELIST_ITEMS_WEAPONS_NAME.getString()).lore(this.player, Settings.GUI_FILTER_WHITELIST_ITEMS_WEAPONS_LORE.getStringList()).make(), e -> { e.manager.showGUI(e.player, new GUIFilterWhitelistList(e.player, AuctionItemCategory.WEAPONS)); }); - setButton(2, 7, QuickItem.of(Settings.GUI_FILTER_WHITELIST_ITEMS_MISC_ITEM.getString()).name(Settings.GUI_FILTER_WHITELIST_ITEMS_MISC_NAME.getString()).lore(this.player,Settings.GUI_FILTER_WHITELIST_ITEMS_MISC_LORE.getStringList()).make(), e -> { + setButton(2, 7, QuickItem.of(Settings.GUI_FILTER_WHITELIST_ITEMS_MISC_ITEM.getString()).name(Settings.GUI_FILTER_WHITELIST_ITEMS_MISC_NAME.getString()).lore(this.player, Settings.GUI_FILTER_WHITELIST_ITEMS_MISC_LORE.getStringList()).make(), e -> { e.manager.showGUI(e.player, new GUIFilterWhitelistList(e.player, AuctionItemCategory.MISC)); }); - setButton(3, 1, QuickItem.of(Settings.GUI_FILTER_WHITELIST_ITEMS_POTIONS_ITEM.getString()).name(Settings.GUI_FILTER_WHITELIST_ITEMS_POTIONS_NAME.getString()).lore(this.player,Settings.GUI_FILTER_WHITELIST_ITEMS_POTIONS_LORE.getStringList()).make(), e -> { + setButton(3, 1, QuickItem.of(Settings.GUI_FILTER_WHITELIST_ITEMS_POTIONS_ITEM.getString()).name(Settings.GUI_FILTER_WHITELIST_ITEMS_POTIONS_NAME.getString()).lore(this.player, Settings.GUI_FILTER_WHITELIST_ITEMS_POTIONS_LORE.getStringList()).make(), e -> { e.manager.showGUI(e.player, new GUIFilterWhitelistList(e.player, AuctionItemCategory.POTIONS)); }); diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/selector/GUIPlayerSelector.java b/src/main/java/ca/tweetzy/auctionhouse/guis/selector/GUIPlayerSelector.java index fc09519..517d258 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/selector/GUIPlayerSelector.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/selector/GUIPlayerSelector.java @@ -30,7 +30,7 @@ public final class GUIPlayerSelector extends AuctionPagedGUI { return QuickItem .of(player) .name(Settings.GUI_PLAYER_SELECTOR_ITEMS_PLAYER_NAME.getString().replace("%player_name%", name)) - .lore(this.player,Settings.GUI_PLAYER_SELECTOR_ITEMS_PLAYER_LORE.getStringList()) + .lore(this.player, Settings.GUI_PLAYER_SELECTOR_ITEMS_PLAYER_LORE.getStringList()) .make(); } diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUIRequestItem.java b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUIRequestItem.java index 112feaa..1801cdb 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUIRequestItem.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUIRequestItem.java @@ -60,7 +60,7 @@ public final class GUIRequestItem extends AuctionBaseGUI { setButton(3, 2, QuickItem .of(Settings.GUI_REQUEST_ITEMS_AMT_ITEM.getString()) .name(Settings.GUI_REQUEST_ITEMS_AMT_NAME.getString()) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_REQUEST_ITEMS_AMT_LORE.getStringList(), "request_amount", amount)) + .lore(this.player, Replacer.replaceVariables(Settings.GUI_REQUEST_ITEMS_AMT_LORE.getStringList(), "request_amount", amount)) .make(), click -> { click.gui.exit(); @@ -106,7 +106,7 @@ public final class GUIRequestItem extends AuctionBaseGUI { setButton(3, 6, QuickItem .of(Settings.GUI_REQUEST_ITEMS_PRICE_ITEM.getString()) .name(Settings.GUI_REQUEST_ITEMS_PRICE_NAME.getString()) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_REQUEST_ITEMS_PRICE_LORE.getStringList(), "request_price", AuctionAPI.getInstance().formatNumber(price))) + .lore(this.player, Replacer.replaceVariables(Settings.GUI_REQUEST_ITEMS_PRICE_LORE.getStringList(), "request_price", AuctionAPI.getInstance().formatNumber(price))) .make(), click -> { click.gui.exit(); @@ -154,7 +154,7 @@ public final class GUIRequestItem extends AuctionBaseGUI { setButton(getRows() - 1, 4, QuickItem .of(Settings.GUI_REQUEST_ITEMS_REQUEST_ITEM.getString()) .name(Settings.GUI_REQUEST_ITEMS_REQUEST_NAME.getString()) - .lore(this.player,Settings.GUI_REQUEST_ITEMS_REQUEST_LORE.getStringList()) + .lore(this.player, Settings.GUI_REQUEST_ITEMS_REQUEST_LORE.getStringList()) .make(), click -> { // Check for block items diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellAuction.java b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellAuction.java index 2fca426..e1c9ad2 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellAuction.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellAuction.java @@ -100,7 +100,7 @@ public final class GUISellAuction extends AuctionBaseGUI { setButton(3, 1, QuickItem .of(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_TIME_ITEM.getString()) .name(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_TIME_NAME.getString()) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_TIME_LORE.getStringList(), + .lore(this.player, Replacer.replaceVariables(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_TIME_LORE.getStringList(), "remaining_days", times[0], "remaining_hours", times[1], "remaining_minutes", times[2], @@ -152,7 +152,7 @@ public final class GUISellAuction extends AuctionBaseGUI { setButton(3, 4, QuickItem .of(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_BUYOUT_PRICE_ITEM.getString()) .name(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_BUYOUT_PRICE_NAME.getString()) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_BUYOUT_PRICE_LORE.getStringList(), "listing_bin_price", AuctionAPI.getInstance().formatNumber(binPrice))) + .lore(this.player, Replacer.replaceVariables(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_BUYOUT_PRICE_LORE.getStringList(), "listing_bin_price", AuctionAPI.getInstance().formatNumber(binPrice))) .make(), click -> { click.gui.exit(); @@ -201,7 +201,7 @@ public final class GUISellAuction extends AuctionBaseGUI { setButton(3, 3, QuickItem .of(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_STARTING_PRICE_ITEM.getString()) .name(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_STARTING_PRICE_NAME.getString()) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_STARTING_PRICE_LORE.getStringList(), "listing_start_price", AuctionAPI.getInstance().formatNumber(startingBid))) + .lore(this.player, Replacer.replaceVariables(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_STARTING_PRICE_LORE.getStringList(), "listing_start_price", AuctionAPI.getInstance().formatNumber(startingBid))) .make(), click -> { click.gui.exit(); @@ -259,7 +259,7 @@ public final class GUISellAuction extends AuctionBaseGUI { setButton(3, 5, QuickItem .of(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_INCREMENT_PRICE_ITEM.getString()) .name(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_INCREMENT_PRICE_NAME.getString()) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_INCREMENT_PRICE_LORE.getStringList(), "listing_increment_price", AuctionAPI.getInstance().formatNumber(bidIncrement))) + .lore(this.player, Replacer.replaceVariables(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_INCREMENT_PRICE_LORE.getStringList(), "listing_increment_price", AuctionAPI.getInstance().formatNumber(bidIncrement))) .make(), click -> { click.gui.exit(); @@ -311,7 +311,7 @@ public final class GUISellAuction extends AuctionBaseGUI { setButton(getRows() - 1, 4, QuickItem .of(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_CONTINUE_ITEM.getString()) .name(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_CONTINUE_NAME.getString()) - .lore(this.player,Settings.GUI_SELL_AUCTION_ITEM_ITEMS_CONTINUE_LORE.getStringList()) + .lore(this.player, Settings.GUI_SELL_AUCTION_ITEM_ITEMS_CONTINUE_LORE.getStringList()) .make(), click -> { if (!AuctionAPI.getInstance().meetsListingRequirements(click.player, this.auctionPlayer.getItemBeingListed())) return; @@ -341,7 +341,7 @@ public final class GUISellAuction extends AuctionBaseGUI { setButton(3, 7, QuickItem .of(this.allowBuyNow ? Settings.GUI_SELL_AUCTION_ITEM_ITEMS_BUYOUT_ENABLED_ITEM.getString() : Settings.GUI_SELL_AUCTION_ITEM_ITEMS_BUYOUT_DISABLED_ITEM.getString()) .name(this.allowBuyNow ? Settings.GUI_SELL_AUCTION_ITEM_ITEMS_BUYOUT_ENABLED_NAME.getString() : Settings.GUI_SELL_AUCTION_ITEM_ITEMS_BUYOUT_DISABLED_NAME.getString()) - .lore(this.player,this.allowBuyNow ? Settings.GUI_SELL_AUCTION_ITEM_ITEMS_BUYOUT_ENABLED_LORE.getStringList() : Settings.GUI_SELL_AUCTION_ITEM_ITEMS_BUYOUT_DISABLED_LORE.getStringList()) + .lore(this.player, this.allowBuyNow ? Settings.GUI_SELL_AUCTION_ITEM_ITEMS_BUYOUT_ENABLED_LORE.getStringList() : Settings.GUI_SELL_AUCTION_ITEM_ITEMS_BUYOUT_DISABLED_LORE.getStringList()) .make(), e -> { this.allowBuyNow = !allowBuyNow; diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellBin.java b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellBin.java index 4b50db0..97c528e 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellBin.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellBin.java @@ -95,7 +95,7 @@ public final class GUISellBin extends AuctionBaseGUI { setButton(3, 1, QuickItem .of(Settings.GUI_SELL_BIN_ITEM_ITEMS_TIME_ITEM.getString()) .name(Settings.GUI_SELL_BIN_ITEM_ITEMS_TIME_NAME.getString()) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_SELL_BIN_ITEM_ITEMS_TIME_LORE.getStringList(), + .lore(this.player, Replacer.replaceVariables(Settings.GUI_SELL_BIN_ITEM_ITEMS_TIME_LORE.getStringList(), "remaining_days", times[0], "remaining_hours", times[1], "remaining_minutes", times[2], @@ -134,7 +134,7 @@ public final class GUISellBin extends AuctionBaseGUI { setButton(3, 4, QuickItem .of(Settings.GUI_SELL_BIN_ITEM_ITEMS_PRICE_ITEM.getString()) .name(Settings.GUI_SELL_BIN_ITEM_ITEMS_PRICE_NAME.getString()) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_SELL_BIN_ITEM_ITEMS_PRICE_LORE.getStringList(), "listing_bin_price", AuctionAPI.getInstance().formatNumber(listingPrice))) + .lore(this.player, Replacer.replaceVariables(Settings.GUI_SELL_BIN_ITEM_ITEMS_PRICE_LORE.getStringList(), "listing_bin_price", AuctionAPI.getInstance().formatNumber(listingPrice))) .make(), click -> { click.gui.exit(); @@ -177,7 +177,7 @@ public final class GUISellBin extends AuctionBaseGUI { setButton(getRows() - 1, 4, QuickItem .of(Settings.GUI_SELL_BIN_ITEM_ITEMS_CONTINUE_ITEM.getString()) .name(Settings.GUI_SELL_BIN_ITEM_ITEMS_CONTINUE_NAME.getString()) - .lore(this.player,Settings.GUI_SELL_BIN_ITEM_ITEMS_CONTINUE_LORE.getStringList()) + .lore(this.player, Settings.GUI_SELL_BIN_ITEM_ITEMS_CONTINUE_LORE.getStringList()) .make(), click -> { if (!AuctionAPI.getInstance().meetsListingRequirements(click.player, this.auctionPlayer.getItemBeingListed())) return; @@ -223,7 +223,7 @@ public final class GUISellBin extends AuctionBaseGUI { setButton(3, 7, QuickItem .of(this.allowPartialBuy ? Settings.GUI_SELL_BIN_ITEM_ITEMS_PARTIAL_ENABLED_ITEM.getString() : Settings.GUI_SELL_BIN_ITEM_ITEMS_PARTIAL_DISABLED_ITEM.getString()) .name(this.allowPartialBuy ? Settings.GUI_SELL_BIN_ITEM_ITEMS_PARTIAL_ENABLED_NAME.getString() : Settings.GUI_SELL_BIN_ITEM_ITEMS_PARTIAL_DISABLED_NAME.getString()) - .lore(this.player,this.allowPartialBuy ? Settings.GUI_SELL_BIN_ITEM_ITEMS_PARTIAL_ENABLED_LORE.getStringList() : Settings.GUI_SELL_BIN_ITEM_ITEMS_PARTIAL_DISABLED_LORE.getStringList()) + .lore(this.player, this.allowPartialBuy ? Settings.GUI_SELL_BIN_ITEM_ITEMS_PARTIAL_ENABLED_LORE.getStringList() : Settings.GUI_SELL_BIN_ITEM_ITEMS_PARTIAL_DISABLED_LORE.getStringList()) .make(), e -> { this.allowPartialBuy = !allowPartialBuy; diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellListingType.java b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellListingType.java index b289e5d..a1ee679 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellListingType.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellListingType.java @@ -57,7 +57,7 @@ public final class GUISellListingType extends AuctionBaseGUI { setButton(getRows() - 1, 0, QuickItem .of(Settings.GUI_SELL_LISTING_TYPE_ITEMS_RETURN_ITEM.getString()) .name(Settings.GUI_SELL_LISTING_TYPE_ITEMS_RETURN_NAME.getString()) - .lore(this.player,Settings.GUI_SELL_LISTING_TYPE_ITEMS_RETURN_LORE.getStringList()) + .lore(this.player, Settings.GUI_SELL_LISTING_TYPE_ITEMS_RETURN_LORE.getStringList()) .make(), click -> click.manager.showGUI(click.player, new GUIAuctionHouse(this.auctionPlayer))); } @@ -65,7 +65,7 @@ public final class GUISellListingType extends AuctionBaseGUI { setButton(1, col, QuickItem .of(Settings.GUI_SELL_LISTING_TYPE_ITEMS_AUCTION_ITEM.getString()) .name(Settings.GUI_SELL_LISTING_TYPE_ITEMS_AUCTION_NAME.getString()) - .lore(this.player,Settings.GUI_SELL_LISTING_TYPE_ITEMS_AUCTION_LORE.getStringList()) + .lore(this.player, Settings.GUI_SELL_LISTING_TYPE_ITEMS_AUCTION_LORE.getStringList()) .make(), click -> { if (this.listingType != null) @@ -77,7 +77,7 @@ public final class GUISellListingType extends AuctionBaseGUI { setButton(1, col, QuickItem .of(Settings.GUI_SELL_LISTING_TYPE_ITEMS_BIN_ITEM.getString()) .name(Settings.GUI_SELL_LISTING_TYPE_ITEMS_BIN_NAME.getString()) - .lore(this.player,Settings.GUI_SELL_LISTING_TYPE_ITEMS_BIN_LORE.getStringList()) + .lore(this.player, Settings.GUI_SELL_LISTING_TYPE_ITEMS_BIN_LORE.getStringList()) .make(), click -> { if (this.listingType != null) diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellPlaceItem.java b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellPlaceItem.java index 0e6ff8e..8598736 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellPlaceItem.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellPlaceItem.java @@ -95,7 +95,7 @@ public final class GUISellPlaceItem extends AuctionBaseGUI { setButton(getRows() - 1, 4, QuickItem .of(Settings.GUI_SELL_PLACE_ITEM_ITEMS_CONTINUE_ITEM.getString()) .name(Settings.GUI_SELL_PLACE_ITEM_ITEMS_CONTINUE_NAME.getString()) - .lore(this.player,Settings.GUI_SELL_PLACE_ITEM_ITEMS_CONTINUE_LORE.getStringList()) + .lore(this.player, Settings.GUI_SELL_PLACE_ITEM_ITEMS_CONTINUE_LORE.getStringList()) .make(), click -> { final ArrayList items = gatherSellableItems(); @@ -133,7 +133,7 @@ public final class GUISellPlaceItem extends AuctionBaseGUI { setButton(getRows() - 1, 8, QuickItem .of(this.viewMode == ViewMode.SINGLE_ITEM ? Settings.GUI_SELL_PLACE_ITEM_ITEMS_SINGLE_ITEM.getString() : Settings.GUI_SELL_PLACE_ITEM_ITEMS_BUNDLE_ITEM.getString()) .name(this.viewMode == ViewMode.SINGLE_ITEM ? Settings.GUI_SELL_PLACE_ITEM_ITEMS_SINGLE_NAME.getString() : Settings.GUI_SELL_PLACE_ITEM_ITEMS_BUNDLE_NAME.getString()) - .lore(this.player,this.viewMode == ViewMode.SINGLE_ITEM ? Settings.GUI_SELL_PLACE_ITEM_ITEMS_SINGLE_LORE.getStringList() : Settings.GUI_SELL_PLACE_ITEM_ITEMS_BUNDLE_LORE.getStringList()) + .lore(this.player, this.viewMode == ViewMode.SINGLE_ITEM ? Settings.GUI_SELL_PLACE_ITEM_ITEMS_SINGLE_LORE.getStringList() : Settings.GUI_SELL_PLACE_ITEM_ITEMS_BUNDLE_LORE.getStringList()) .make(), click -> { if (auctionPlayer.isAtBundleLimit()) { diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/statistics/GUIStatisticLeaderboard.java b/src/main/java/ca/tweetzy/auctionhouse/guis/statistics/GUIStatisticLeaderboard.java index b57ceb9..b07e92f 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/statistics/GUIStatisticLeaderboard.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/statistics/GUIStatisticLeaderboard.java @@ -66,7 +66,7 @@ public final class GUIStatisticLeaderboard extends AuctionPagedGUI click.manager.showGUI(click.player, new GUIStatisticLeaderboard(this.auctionPlayer, this.statisticType.next()))); } @@ -79,7 +79,7 @@ public final class GUIStatisticLeaderboard extends AuctionPagedGUI click.manager.showGUI(click.player, new GUIStatisticView(this.auctionPlayer, this.auctionPlayer))); setButton(1, 6, QuickItem.of(Settings.GUI_STATS_VIEW_SELECT_ITEMS_LEADERBOARD_ITEM.getString()) .name(Settings.GUI_STATS_VIEW_SELECT_ITEMS_LEADERBOARD_NAME.getString()) - .lore(this.player,Settings.GUI_STATS_VIEW_SELECT_ITEMS_LEADERBOARD_LORE.getStringList()) + .lore(this.player, Settings.GUI_STATS_VIEW_SELECT_ITEMS_LEADERBOARD_LORE.getStringList()) .make(), click -> click.manager.showGUI(click.player, new GUIStatisticLeaderboard(this.auctionPlayer, AuctionStatisticType.MONEY_EARNED))); } } diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionList.java b/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionList.java index b4680e5..afeec2b 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionList.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionList.java @@ -123,7 +123,7 @@ public class GUITransactionList extends AuctionPagedGUI { setButton(Settings.GUI_TRANSACTIONS_ITEMS_FILTER_SLOT.getInt(), QuickItem .of(Settings.GUI_TRANSACTIONS_ITEMS_FILTER_ITEM.getString()) .name(Settings.GUI_TRANSACTIONS_ITEMS_FILTER_NAME.getString()) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_TRANSACTIONS_ITEMS_FILTER_LORE.getStringList(), + .lore(this.player, Replacer.replaceVariables(Settings.GUI_TRANSACTIONS_ITEMS_FILTER_LORE.getStringList(), "filter_category", auctionPlayer.getSelectedTransactionFilter().getTranslatedType(), "filter_auction_type", auctionPlayer.getSelectedTransactionSaleType().getTranslatedType(), "filter_sort_order", auctionPlayer.getTransactionSortType().getTranslatedType(), @@ -173,7 +173,7 @@ public class GUITransactionList extends AuctionPagedGUI { return QuickItem .of(item) .name(Replacer.replaceVariables(Settings.GUI_TRANSACTIONS_ITEM_TRANSACTION_NAME.getString(), "item_name", AuctionAPI.getInstance().getItemName(item), "transaction_id", transaction.getId().toString())) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_TRANSACTIONS_ITEM_TRANSACTION_LORE.getStringList(), + .lore(this.player, Replacer.replaceVariables(Settings.GUI_TRANSACTIONS_ITEM_TRANSACTION_LORE.getStringList(), "transaction_id", transaction.getId().toString(), "seller", seller.hasPlayedBefore() ? seller.getName() : SERVER_LISTING_NAME, "buyer", Bukkit.getOfflinePlayer(transaction.getBuyer()).getName(), diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionType.java b/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionType.java index 655c0df..2ccb7aa 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionType.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionType.java @@ -58,7 +58,7 @@ public final class GUITransactionType extends AuctionBaseGUI { setButton(11, QuickItem .of(Settings.GUI_TRANSACTIONS_TYPE_ITEMS_ALL_TRANSACTIONS_ITEM.getString()) .name(Settings.GUI_TRANSACTIONS_TYPE_ITEMS_ALL_TRANSACTIONS_NAME.getString()) - .lore(this.player,Settings.GUI_TRANSACTIONS_TYPE_ITEMS_ALL_TRANSACTIONS_LORE.getStringList()) + .lore(this.player, Settings.GUI_TRANSACTIONS_TYPE_ITEMS_ALL_TRANSACTIONS_LORE.getStringList()) .make(), e -> { if (Settings.RESTRICT_ALL_TRANSACTIONS_TO_PERM.getBoolean() && !e.player.hasPermission("auctionhouse.transactions.viewall")) { @@ -72,7 +72,7 @@ public final class GUITransactionType extends AuctionBaseGUI { setButton(15, QuickItem .of(Settings.GUI_TRANSACTIONS_TYPE_ITEMS_SELF_TRANSACTIONS_ITEM.getString()) .name(Settings.GUI_TRANSACTIONS_TYPE_ITEMS_SELF_TRANSACTIONS_NAME.getString()) - .lore(this.player,Settings.GUI_TRANSACTIONS_TYPE_ITEMS_SELF_TRANSACTIONS_LORE.getStringList()) + .lore(this.player, Settings.GUI_TRANSACTIONS_TYPE_ITEMS_SELF_TRANSACTIONS_LORE.getStringList()) .make(), e -> e.manager.showGUI(e.player, new GUITransactionList(e.player, false))); if (player.isOp() || player.hasPermission("auctionhouse.admin")) { @@ -80,7 +80,7 @@ public final class GUITransactionType extends AuctionBaseGUI { setButton(3, 8, QuickItem .of(Settings.GUI_TRANSACTIONS_TYPE_ITEMS_DELETE_ITEM.getString()) .name(Settings.GUI_TRANSACTIONS_TYPE_ITEMS_DELETE_NAME.getString()) - .lore(this.player,Settings.GUI_TRANSACTIONS_TYPE_ITEMS_DELETE_LORE.getStringList()) + .lore(this.player, Settings.GUI_TRANSACTIONS_TYPE_ITEMS_DELETE_LORE.getStringList()) .make(), e -> { e.gui.close(); diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionView.java b/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionView.java index 19c06cc..44d2192 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionView.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionView.java @@ -62,7 +62,7 @@ public class GUITransactionView extends AuctionBaseGUI { setItem(3, 2, QuickItem .of(AuctionAPI.getInstance().getPlayerHead(seller.getName())) .name(Replacer.replaceVariables(Settings.GUI_TRANSACTION_VIEW_ITEM_SELLER_NAME.getString(), "seller", seller.hasPlayedBefore() ? seller.getName() : SERVER_LISTING_NAME)) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_TRANSACTION_VIEW_ITEM_SELLER_LORE.getStringList(), + .lore(this.player, Replacer.replaceVariables(Settings.GUI_TRANSACTION_VIEW_ITEM_SELLER_LORE.getStringList(), "transaction_id", transaction.getId().toString(), "seller", seller.hasPlayedBefore() ? seller.getName() : SERVER_LISTING_NAME, "buyer", buyer.getName(), @@ -72,7 +72,7 @@ public class GUITransactionView extends AuctionBaseGUI { setItem(3, 6, QuickItem .of(AuctionAPI.getInstance().getPlayerHead(Bukkit.getOfflinePlayer(transaction.getBuyer()).getName())) .name(Replacer.replaceVariables(Settings.GUI_TRANSACTION_VIEW_ITEM_BUYER_NAME.getString(), "buyer", buyer.getName())) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_TRANSACTION_VIEW_ITEM_BUYER_LORE.getStringList(), + .lore(this.player, Replacer.replaceVariables(Settings.GUI_TRANSACTION_VIEW_ITEM_BUYER_LORE.getStringList(), "transaction_id", transaction.getId().toString(), "seller", seller.hasPlayedBefore() ? seller.getName() : SERVER_LISTING_NAME, "buyer", buyer.getName(), @@ -83,7 +83,7 @@ public class GUITransactionView extends AuctionBaseGUI { setItem(3, 4, QuickItem .of(Settings.GUI_TRANSACTION_VIEW_ITEM_INFO_ITEM.getString()) .name(Replacer.replaceVariables(Settings.GUI_TRANSACTION_VIEW_ITEM_INFO_NAME.getString(), "transaction_id", transaction.getId().toString())) - .lore(this.player,Replacer.replaceVariables(Settings.GUI_TRANSACTION_VIEW_ITEM_INFO_LORE.getStringList(), + .lore(this.player, Replacer.replaceVariables(Settings.GUI_TRANSACTION_VIEW_ITEM_INFO_LORE.getStringList(), "transaction_id", transaction.getId().toString(), "sale_type", transaction.getAuctionSaleType() == AuctionSaleType.USED_BIDDING_SYSTEM ? AuctionHouse.getInstance().getLocale().getMessage("transaction.sale_type.bid_won").getMessage() : AuctionHouse.getInstance().getLocale().getMessage("transaction.sale_type.immediate_buy").getMessage(), "transaction_date", AuctionAPI.getInstance().convertMillisToDate(transaction.getTransactionTime()), diff --git a/src/main/java/ca/tweetzy/auctionhouse/helpers/AuctionCreator.java b/src/main/java/ca/tweetzy/auctionhouse/helpers/AuctionCreator.java index 48a19e9..9843a10 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/helpers/AuctionCreator.java +++ b/src/main/java/ca/tweetzy/auctionhouse/helpers/AuctionCreator.java @@ -28,10 +28,8 @@ import ca.tweetzy.auctionhouse.auction.enums.PaymentReason; import ca.tweetzy.auctionhouse.events.AuctionStartEvent; import ca.tweetzy.auctionhouse.managers.SoundManager; import ca.tweetzy.auctionhouse.settings.Settings; -import ca.tweetzy.core.hooks.EconomyManager; import ca.tweetzy.core.utils.PlayerUtils; import ca.tweetzy.core.utils.TextUtils; -import ca.tweetzy.flight.utils.Common; import lombok.NonNull; import lombok.experimental.UtilityClass; import org.bukkit.Bukkit; @@ -108,15 +106,15 @@ public final class AuctionCreator { // check tax if (Settings.TAX_ENABLED.getBoolean() && Settings.TAX_CHARGE_LISTING_FEE.getBoolean() && !auctionItem.isServerItem() && !auctionItem.isRequest()) { - if (!EconomyManager.hasBalance(seller, listingFee)) { + if (!AuctionHouse.getCurrencyManager().has(seller, listingFee)) { instance.getLocale().getMessage("auction.tax.cannotpaylistingfee").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(listingFee)).sendPrefixedMessage(seller); result.accept(auctionItem, CANNOT_PAY_LISTING_FEE); return; } - EconomyManager.withdrawBalance(seller, listingFee); + AuctionHouse.getCurrencyManager().withdraw(seller, listingFee); AuctionHouse.getInstance().getLocale().getMessage("auction.tax.paidlistingfee").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(listingFee)).sendPrefixedMessage(seller); - AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(seller))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(listingFee)).sendPrefixedMessage(seller); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(seller))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(listingFee)).sendPrefixedMessage(seller); } // final item adjustments @@ -215,8 +213,8 @@ public final class AuctionCreator { PaymentReason.LISTING_FAILED ), null); else - EconomyManager.deposit(seller, listingFee); - AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(seller))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(listingFee)).sendPrefixedMessage(seller); + AuctionHouse.getCurrencyManager().deposit(seller, listingFee); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(seller))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(listingFee)).sendPrefixedMessage(seller); } result.accept(auctionItem, UNKNOWN); diff --git a/src/main/java/ca/tweetzy/auctionhouse/impl/AuctionAPI.java b/src/main/java/ca/tweetzy/auctionhouse/impl/AuctionAPI.java index b4ab0ea..204df1e 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/impl/AuctionAPI.java +++ b/src/main/java/ca/tweetzy/auctionhouse/impl/AuctionAPI.java @@ -18,5 +18,7 @@ package ca.tweetzy.auctionhouse.impl; -public final class AuctionAPI { +import ca.tweetzy.auctionhouse.api.AuctionHouseAPI; + +public final class AuctionAPI implements AuctionHouseAPI { } diff --git a/src/main/java/ca/tweetzy/auctionhouse/impl/currency/ItemCurrency.java b/src/main/java/ca/tweetzy/auctionhouse/impl/currency/ItemCurrency.java new file mode 100644 index 0000000..74ddd95 --- /dev/null +++ b/src/main/java/ca/tweetzy/auctionhouse/impl/currency/ItemCurrency.java @@ -0,0 +1,53 @@ +package ca.tweetzy.auctionhouse.impl.currency; + +import ca.tweetzy.auctionhouse.api.currency.AbstractCurrency; +import ca.tweetzy.flight.utils.PlayerUtil; +import org.bukkit.OfflinePlayer; +import org.bukkit.inventory.ItemStack; + +public final class ItemCurrency extends AbstractCurrency { + + public ItemCurrency() { + super("Markets", "Item", "&bCustom Item"); + } + + public boolean has(OfflinePlayer player, double amount, ItemStack item) { + if (player == null || player.getPlayer() == null || !player.isOnline()) return false; + return PlayerUtil.getItemCountInPlayerInventory(player.getPlayer(), item) >= amount; + } + + public boolean withdraw(OfflinePlayer player, double amount, ItemStack item) { + if (player == null || player.getPlayer() == null || !player.isOnline()) return false; + PlayerUtil.removeSpecificItemQuantityFromPlayer(player.getPlayer(), item, (int) amount); + return true; + } + + public boolean deposit(OfflinePlayer player, double amount, ItemStack item) { + if (player == null || player.getPlayer() == null || !player.isOnline()) return false; + + for (int i = 0; i < amount; i++) + PlayerUtil.giveItem(player.getPlayer(), item); + + return true; + } + + @Override + public double getBalance(OfflinePlayer player) { + return 0; + } + + @Override + public boolean has(OfflinePlayer player, double amount) { + return false; + } + + @Override + public boolean withdraw(OfflinePlayer player, double amount) { + return false; + } + + @Override + public boolean deposit(OfflinePlayer player, double amount) { + return false; + } +} diff --git a/src/main/java/ca/tweetzy/auctionhouse/impl/currency/UltraEconomyCurrency.java b/src/main/java/ca/tweetzy/auctionhouse/impl/currency/UltraEconomyCurrency.java new file mode 100644 index 0000000..d50e1a1 --- /dev/null +++ b/src/main/java/ca/tweetzy/auctionhouse/impl/currency/UltraEconomyCurrency.java @@ -0,0 +1,57 @@ +package ca.tweetzy.auctionhouse.impl.currency; + +import ca.tweetzy.auctionhouse.api.currency.IconableCurrency; +import ca.tweetzy.flight.comp.enums.CompMaterial; +import me.TechsCode.UltraEconomy.UltraEconomy; +import me.TechsCode.UltraEconomy.objects.Account; +import me.TechsCode.UltraEconomy.objects.Currency; +import org.bukkit.OfflinePlayer; + +public final class UltraEconomyCurrency extends IconableCurrency { + + private final Currency currency; + + public UltraEconomyCurrency(String currencyName) { + super("UltraEconomy", currencyName, "", CompMaterial.PAPER.parseItem()); + + this.currency = UltraEconomy.getInstance().getCurrencies().name(currencyName).orElse(null); + + if (this.currency != null) { + setDisplayName(this.currency.getName()); + } + } + + @Override + public boolean has(OfflinePlayer player, double amount) { + final Account account = UltraEconomy.getInstance().getAccounts().uuid(player.getUniqueId()).orElse(null); + if (account == null) return false; + + return account.getBalance(this.currency).getSum() >= amount; + } + + @Override + public boolean withdraw(OfflinePlayer player, double amount) { + final Account account = UltraEconomy.getInstance().getAccounts().uuid(player.getUniqueId()).orElse(null); + if (account == null) return false; + + account.removeBalance(this.currency, amount); + return true; + } + + @Override + public boolean deposit(OfflinePlayer player, double amount) { + final Account account = UltraEconomy.getInstance().getAccounts().uuid(player.getUniqueId()).orElse(null); + if (account == null) return false; + + account.addBalance(this.currency, amount); + return true; + } + + @Override + public double getBalance(OfflinePlayer player) { + final Account account = UltraEconomy.getInstance().getAccounts().uuid(player.getUniqueId()).orElse(null); + if (account == null) return 0; + return account.getBalance(this.currency).getSum(); + } +} + diff --git a/src/main/java/ca/tweetzy/auctionhouse/impl/currency/VaultCurrency.java b/src/main/java/ca/tweetzy/auctionhouse/impl/currency/VaultCurrency.java new file mode 100644 index 0000000..85cabba --- /dev/null +++ b/src/main/java/ca/tweetzy/auctionhouse/impl/currency/VaultCurrency.java @@ -0,0 +1,33 @@ +package ca.tweetzy.auctionhouse.impl.currency; + +import ca.tweetzy.auctionhouse.AuctionHouse; +import ca.tweetzy.auctionhouse.api.currency.AbstractCurrency; +import ca.tweetzy.auctionhouse.settings.Settings; +import org.bukkit.OfflinePlayer; + +public final class VaultCurrency extends AbstractCurrency { + + public VaultCurrency() { + super("Vault", "Vault", Settings.CURRENCY_VAULT_SYMBOL.getString()); + } + + @Override + public boolean has(OfflinePlayer player, double amount) { + return AuctionHouse.getEconomy().has(player, amount); + } + + @Override + public boolean withdraw(OfflinePlayer player, double amount) { + return AuctionHouse.getEconomy().withdrawPlayer(player, amount).transactionSuccess(); + } + + @Override + public boolean deposit(OfflinePlayer player, double amount) { + return AuctionHouse.getEconomy().depositPlayer(player, amount).transactionSuccess(); + } + + @Override + public double getBalance(OfflinePlayer player) { + return AuctionHouse.getEconomy().getBalance(player); + } +} diff --git a/src/main/java/ca/tweetzy/auctionhouse/impl/listing/AuctionItem.java b/src/main/java/ca/tweetzy/auctionhouse/impl/listing/AuctionItem.java index 01d4841..bbd7205 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/impl/listing/AuctionItem.java +++ b/src/main/java/ca/tweetzy/auctionhouse/impl/listing/AuctionItem.java @@ -25,7 +25,6 @@ import ca.tweetzy.auctionhouse.api.sync.Storeable; import ca.tweetzy.auctionhouse.api.sync.Unstoreable; import lombok.AllArgsConstructor; import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.Nullable; import java.util.function.Consumer; @@ -36,17 +35,12 @@ public abstract class AuctionItem implements Auction, Storeable, Un protected final ListingType listingType; @Override - public void unStore(@Nullable Consumer result) { -// AuctionHouse.getDataManager().deleteListing(this, (error, status) -> { -// if (error != null && result != null) { -// error.printStackTrace(); -// result.accept(ListingDeleteResult.NOT_DELETED); -// return; -// } -// -// if (result != null) -// result.accept(status); -// -// }); + public void store(Consumer stored) { + } -} \ No newline at end of file + + @Override + public void sync(Consumer wasSuccess) { + + } +} diff --git a/src/main/java/ca/tweetzy/auctionhouse/impl/listing/BinListing.java b/src/main/java/ca/tweetzy/auctionhouse/impl/listing/BinListing.java index f16d8d4..2fe160c 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/impl/listing/BinListing.java +++ b/src/main/java/ca/tweetzy/auctionhouse/impl/listing/BinListing.java @@ -29,7 +29,6 @@ import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.List; import java.util.UUID; -import java.util.function.Consumer; public class BinListing extends AuctionItem { @@ -164,10 +163,6 @@ public class BinListing extends AuctionItem { this.currency = currency; } - public void setCurrencyItem(ItemStack currencyItem) { - this.currencyItem = currencyItem; - } - @Override public void setBinPrice(double binPrice) { this.binPrice = binPrice; @@ -193,21 +188,6 @@ public class BinListing extends AuctionItem { return 0; } - @Override - public void sync(Consumer wasSuccess) { - - } - - @Override - public void store(Consumer stored) { -// AuctionHouse.getDataManager().createListing(this, (error, created) -> { -// if (error != null) return; -// -// if (stored != null) -// stored.accept(created); -// }); - } - @Override public List getDisplayLore(@NonNull ListingDisplayMode displayMode) { final List displayLore = new ArrayList<>(ItemUtil.getItemLore(this.item)); diff --git a/src/main/java/ca/tweetzy/auctionhouse/listeners/PlayerListeners.java b/src/main/java/ca/tweetzy/auctionhouse/listeners/PlayerListeners.java index 060010c..601e623 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/listeners/PlayerListeners.java +++ b/src/main/java/ca/tweetzy/auctionhouse/listeners/PlayerListeners.java @@ -92,7 +92,6 @@ public class PlayerListeners implements Listener { if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) return; final Player player = event.getPlayer(); AuctionHouse.getInstance().getAuctionPlayerManager().addPlayer(player); - } @EventHandler(priority = EventPriority.HIGH) @@ -101,24 +100,22 @@ public class PlayerListeners implements Listener { final AuctionHouse instance = AuctionHouse.getInstance(); Titles.sendTitle(player, 1, 1, 1, " ", " "); -// instance.getAuctionPlayerManager().addPlayer(player); - // DUPE TRACKING - for (ItemStack item : player.getInventory().getStorageContents()) { - if (item == null || item.getType() == XMaterial.AIR.parseMaterial() || item.getAmount() == 0) continue; + AuctionHouse.newChain().async(() -> { + for (ItemStack item : player.getInventory().getStorageContents()) { + if (item == null || item.getType() == XMaterial.AIR.parseMaterial() || item.getAmount() == 0) continue; - final UUID auctionItemId = NBT.get(item, nbt -> (UUID) nbt.getUUID("AuctionDupeTracking")); - if (auctionItemId == null) return; + final UUID auctionItemId = NBT.get(item, nbt -> (UUID) nbt.getUUID("AuctionDupeTracking")); + if (auctionItemId == null) continue; - if (AuctionHouse.getInstance().getAuctionItemManager().getItem(auctionItemId) != null) { - player.getInventory().remove(item); - Bukkit.getServer().getConsoleSender().sendMessage(Common.colorize("&8[&eAuctionHouse&8] &CRemoving duped item from " + player.getName() + "'s inventory!")); + if (AuctionHouse.getInstance().getAuctionItemManager().getItem(auctionItemId) != null) { + player.getInventory().remove(item); + Bukkit.getServer().getConsoleSender().sendMessage(Common.colorize("&8[&eAuctionHouse&8] &CRemoving duped item from " + player.getName() + "'s inventory!")); + } } - } - + }).execute(); Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(AuctionHouse.getInstance(), () -> { - if (Settings.UPDATE_CHECKER.getBoolean() && instance.getStatus() == UpdateChecker.UpdateStatus.UNRELEASED_VERSION && player.isOp()) { instance.getLocale().newMessage(TextUtils.formatText(String.format("&dYou're running an unreleased version of Auction House &f(&c%s&f)", instance.getDescription().getVersion()))).sendPrefixedMessage(player); } diff --git a/src/main/java/ca/tweetzy/auctionhouse/model/currency/CurrencyLoader.java b/src/main/java/ca/tweetzy/auctionhouse/model/currency/CurrencyLoader.java new file mode 100644 index 0000000..9c5f45f --- /dev/null +++ b/src/main/java/ca/tweetzy/auctionhouse/model/currency/CurrencyLoader.java @@ -0,0 +1,17 @@ +package ca.tweetzy.auctionhouse.model.currency; + +import ca.tweetzy.auctionhouse.api.currency.AbstractCurrency; +import lombok.NonNull; + +import java.util.List; + +public abstract class CurrencyLoader { + + protected String owningPlugin; + + public CurrencyLoader(@NonNull final String owningPlugin) { + this.owningPlugin = owningPlugin; + } + + public abstract List getCurrencies(); +} diff --git a/src/main/java/ca/tweetzy/auctionhouse/model/currency/UltraEconomyLoader.java b/src/main/java/ca/tweetzy/auctionhouse/model/currency/UltraEconomyLoader.java new file mode 100644 index 0000000..42a40d3 --- /dev/null +++ b/src/main/java/ca/tweetzy/auctionhouse/model/currency/UltraEconomyLoader.java @@ -0,0 +1,43 @@ +package ca.tweetzy.auctionhouse.model.currency; + +import ca.tweetzy.auctionhouse.api.currency.AbstractCurrency; +import ca.tweetzy.auctionhouse.impl.currency.UltraEconomyCurrency; +import ca.tweetzy.auctionhouse.settings.Settings; +import me.TechsCode.UltraEconomy.UltraEconomy; +import me.TechsCode.UltraEconomy.objects.Currency; + +import java.util.ArrayList; +import java.util.List; + +public final class UltraEconomyLoader extends CurrencyLoader { + + public UltraEconomyLoader() { + super("UltraEconomy"); + } + + + @Override + public List getCurrencies() { + final List currencies = new ArrayList<>(); + + for (Currency currency : UltraEconomy.getInstance().getCurrencies()) { + boolean blackListed = false; + + for (String blacklisted : Settings.CURRENCY_BLACKLISTED.getStringList()) { + final String[] blacklistSplit = blacklisted.split(":"); + + if (blacklistSplit.length != 2) continue; + if (!blacklistSplit[0].equalsIgnoreCase(this.owningPlugin)) continue; + + if (blacklistSplit[1].equalsIgnoreCase(currency.getName())) + blackListed = true; + + } + + if (!blackListed) + currencies.add(new UltraEconomyCurrency(currency.getName())); + } + + return currencies; + } +} diff --git a/src/main/java/ca/tweetzy/auctionhouse/model/manager/CurrencyManager.java b/src/main/java/ca/tweetzy/auctionhouse/model/manager/CurrencyManager.java new file mode 100644 index 0000000..2a6d3af --- /dev/null +++ b/src/main/java/ca/tweetzy/auctionhouse/model/manager/CurrencyManager.java @@ -0,0 +1,102 @@ +package ca.tweetzy.auctionhouse.model.manager; + +import ca.tweetzy.auctionhouse.AuctionHouse; +import ca.tweetzy.auctionhouse.api.currency.AbstractCurrency; +import ca.tweetzy.auctionhouse.api.manager.ListManager; +import ca.tweetzy.auctionhouse.impl.currency.ItemCurrency; +import ca.tweetzy.auctionhouse.impl.currency.VaultCurrency; +import ca.tweetzy.auctionhouse.model.currency.UltraEconomyLoader; +import ca.tweetzy.auctionhouse.settings.Settings; +import lombok.NonNull; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.inventory.ItemStack; + +public final class CurrencyManager extends ListManager { + + public CurrencyManager() { + super("Currency"); + } + + public AbstractCurrency locateCurrency(@NonNull final String owningPlugin, @NonNull final String currencyName) { + return getManagerContent().stream().filter(currency -> currency.getOwningPlugin().equals(owningPlugin) && currency.getCurrencyName().equals(currencyName)).findFirst().orElse(null); + } + + public boolean has(@NonNull final OfflinePlayer offlinePlayer, @NonNull final String owningPlugin, @NonNull final String currencyName, final double amount) { + if (owningPlugin.equalsIgnoreCase("vault") || currencyName.equalsIgnoreCase("vault")) + return AuctionHouse.getEconomy().has(offlinePlayer, amount); + + return locateCurrency(owningPlugin, currencyName).has(offlinePlayer, amount); + } + + public double getBalance(@NonNull final OfflinePlayer offlinePlayer, @NonNull final String owningPlugin, @NonNull final String currencyName) { + if (owningPlugin.equalsIgnoreCase("vault") || currencyName.equalsIgnoreCase("vault")) + return AuctionHouse.getEconomy().getBalance(offlinePlayer); + return locateCurrency(owningPlugin, currencyName).getBalance(offlinePlayer); + } + + public boolean withdraw(@NonNull final OfflinePlayer offlinePlayer, @NonNull final String owningPlugin, @NonNull final String currencyName, final double amount) { + if (owningPlugin.equalsIgnoreCase("vault") || currencyName.equalsIgnoreCase("vault")) { + AuctionHouse.getEconomy().withdrawPlayer(offlinePlayer, amount); + return true; + } + + return locateCurrency(owningPlugin, currencyName).withdraw(offlinePlayer, amount); + } + + public boolean deposit(@NonNull final OfflinePlayer offlinePlayer, @NonNull final String owningPlugin, @NonNull final String currencyName, final double amount) { + if (owningPlugin.equalsIgnoreCase("vault") || currencyName.equalsIgnoreCase("vault")) { + AuctionHouse.getEconomy().depositPlayer(offlinePlayer, amount); + return true; + } + + return locateCurrency(owningPlugin, currencyName).deposit(offlinePlayer, amount); + } + + public boolean has(@NonNull final OfflinePlayer offlinePlayer, @NonNull final ItemStack itemStack, final int amount) { + return ((ItemCurrency) locateCurrency("Markets", "Item")).has(offlinePlayer, amount, itemStack); + + } + + public boolean withdraw(@NonNull final OfflinePlayer offlinePlayer, @NonNull final ItemStack itemStack, final int amount) { + return ((ItemCurrency) locateCurrency("Markets", "Item")).withdraw(offlinePlayer, amount, itemStack); + } + + public boolean deposit(@NonNull final OfflinePlayer offlinePlayer, @NonNull final ItemStack itemStack, final int amount) { + return ((ItemCurrency) locateCurrency("Markets", "Item")).deposit(offlinePlayer, amount, itemStack); + } + + public boolean has(@NonNull final OfflinePlayer offlinePlayer, final double amount) { + final String[] CURRENCY_DEFAULT = Settings.CURRENCY_DEFAULT_SELECTED.getString().split("/"); + return has(offlinePlayer, CURRENCY_DEFAULT[0], CURRENCY_DEFAULT[1], amount); + + } + + public boolean withdraw(@NonNull final OfflinePlayer offlinePlayer, final double amount) { + final String[] CURRENCY_DEFAULT = Settings.CURRENCY_DEFAULT_SELECTED.getString().split("/"); + return withdraw(offlinePlayer, CURRENCY_DEFAULT[0], CURRENCY_DEFAULT[1], amount); + } + + public boolean deposit(@NonNull final OfflinePlayer offlinePlayer, final double amount) { + final String[] CURRENCY_DEFAULT = Settings.CURRENCY_DEFAULT_SELECTED.getString().split("/"); + return deposit(offlinePlayer, CURRENCY_DEFAULT[0], CURRENCY_DEFAULT[1], amount); + } + + public double getBalance(@NonNull final OfflinePlayer offlinePlayer) { + final String[] CURRENCY_DEFAULT = Settings.CURRENCY_DEFAULT_SELECTED.getString().split("/"); + return getBalance(offlinePlayer, CURRENCY_DEFAULT[0], CURRENCY_DEFAULT[1]); + } + + @Override + public void load() { + clear(); + + // add vault by default + add(new VaultCurrency()); +// add(new ItemCurrency()); + + // load currencies from providers that allow multiple currencies + if (Bukkit.getServer().getPluginManager().isPluginEnabled("UltraEconomy")) + new UltraEconomyLoader().getCurrencies().forEach(this::add); + } +} diff --git a/src/main/java/ca/tweetzy/auctionhouse/settings/Settings.java b/src/main/java/ca/tweetzy/auctionhouse/settings/Settings.java index 5d7f108..f23d348 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/settings/Settings.java +++ b/src/main/java/ca/tweetzy/auctionhouse/settings/Settings.java @@ -47,6 +47,11 @@ public class Settings { "You have the following supported economy plugins installed: \"" + EconomyManager.getManager().getPossiblePlugins().stream().collect(Collectors.joining("\", \"")) + "\"." ); + public static final ConfigSetting CURRENCY_DEFAULT_SELECTED = new ConfigSetting(config, "settings.currency.default selection", "Vault/Vault", "The default currency selection, PluginName/CurrencyName -> Ex. Vault/Vault or UltraEconomy/Gems etc"); + public static final ConfigSetting CURRENCY_VAULT_SYMBOL = new ConfigSetting(config, "settings.currency.vault symbol", "$", "When using default/vault currency, what symbol should be used."); + public static final ConfigSetting CURRENCY_BLACKLISTED = new ConfigSetting(config, "settings.currency.black listed", Collections.singletonList("UltraEconomy:Test"), "A list of owning plugins & the currency to be blacklisted. Ex. UltraEconomy:Test"); + + 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"); diff --git a/src/main/java/ca/tweetzy/auctionhouse/settings/v3/Settings.java b/src/main/java/ca/tweetzy/auctionhouse/settings/v3/Settings.java index 3b04f75..e8328ec 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/settings/v3/Settings.java +++ b/src/main/java/ca/tweetzy/auctionhouse/settings/v3/Settings.java @@ -46,6 +46,18 @@ public final class Settings extends SettingTemp { public static ConfigEntry MYSQL_PASSWORD = create("settings.mysql.password", "password123", "The password of the database"); public static ConfigEntry MYSQL_PARAMS = create("settings.mysql.params", "?useUnicode=yes&characterEncoding=UTF-8&useServerPrepStmts=false&rewriteBatchedStatements=true&useSSL=true", "Do not touch this if you don't know what your doing"); + /* + ============================================================== + Economy Settings + ============================================================== + */ + public static ConfigEntry CURRENCY_ALLOW_PICK = create("settings.currency.allow user to pick", true).withComment("If true, players will be able to select which currency they want to use."); + public static ConfigEntry CURRENCY_DEFAULT_SELECTED = create("settings.currency.default selection", "Vault/Vault").withComment("The default currency selection, PluginName/CurrencyName -> Ex. Vault/Vault"); + public static ConfigEntry CURRENCY_ITEM_DEFAULT_SELECTED = create("settings.currency.default item selection", "DIAMOND").withComment("The default currency selection if using item only mode"); + public static ConfigEntry CURRENCY_VAULT_SYMBOL = create("settings.currency.vault symbol", "$").withComment("When using default/vault currency, what symbol should be used."); + public static ConfigEntry CURRENCY_USE_ITEM_ONLY = create("settings.currency.use item only", false).withComment("If true, Auction House will only allow the usage of another item for currency."); + public static ConfigEntry CURRENCY_BLACKLISTED = create("settings.currency.black listed", Collections.singletonList("UltraEconomy:Test")).withComment("A list of owning plugins & the currency to be blacklisted. Ex. UltraEconomy:Test"); + /* ============================================================== TBD @@ -88,7 +100,6 @@ public final class Settings extends SettingTemp { public static ConfigEntry DATE_FORMAT = create("settings.formatting.date format", "MMMM/dd/yyyy - hh:mm a", "The default date format to be used"); public static ConfigEntry TIME_FORMAT = create("settings.formatting.time format", "hh:mm:ss a", "The default time format to be used"); public static ConfigEntry DATETIME_FORMAT = create("settings.formatting.datetime format", "MMMM/dd/yyyy - hh:mm:ss a", "The default combined date/time format to be used"); - public static ConfigEntry CURRENCY_FORMAT = create("settings.formatting.number format", "%,.2f", "The default currency formatting (#,###.##)"); /* diff --git a/src/main/java/ca/tweetzy/auctionhouse/tasks/TickAuctionsTask.java b/src/main/java/ca/tweetzy/auctionhouse/tasks/TickAuctionsTask.java index faea75f..12f46ad 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/tasks/TickAuctionsTask.java +++ b/src/main/java/ca/tweetzy/auctionhouse/tasks/TickAuctionsTask.java @@ -24,7 +24,6 @@ import ca.tweetzy.auctionhouse.auction.AuctionedItem; import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType; import ca.tweetzy.auctionhouse.events.AuctionEndEvent; import ca.tweetzy.auctionhouse.settings.Settings; -import ca.tweetzy.core.hooks.EconomyManager; import ca.tweetzy.core.utils.PlayerUtils; import ca.tweetzy.core.utils.TextUtils; import ca.tweetzy.flight.nbtapi.NBT; @@ -64,8 +63,7 @@ public class TickAuctionsTask extends BukkitRunnable { public void run() { clock += Settings.TICK_UPDATE_TIME.getInt(); - final AuctionHouse instance = AuctionHouse.getInstance(); - Set> entrySet = instance.getAuctionItemManager().getItems().entrySet(); + Set> entrySet = AuctionHouse.getAuctionItemManager().getItems().entrySet(); Iterator> auctionItemIterator = entrySet.iterator(); @@ -74,26 +72,26 @@ public class TickAuctionsTask extends BukkitRunnable { AuctionedItem auctionItem = entry.getValue(); ItemStack itemStack = auctionItem.getItem(); - if (instance.getAuctionItemManager().getGarbageBin().containsKey(auctionItem.getId())) { - instance.getAuctionItemManager().getGarbageBin().remove(auctionItem.getId()); - instance.getAuctionItemManager().getDeletedItems().put(auctionItem.getId(), auctionItem); + if (AuctionHouse.getAuctionItemManager().getGarbageBin().containsKey(auctionItem.getId())) { + AuctionHouse.getAuctionItemManager().getGarbageBin().remove(auctionItem.getId()); + AuctionHouse.getAuctionItemManager().getDeletedItems().put(auctionItem.getId(), auctionItem); auctionItemIterator.remove(); continue; } // begin the scuffed deletion - if (!instance.getAuctionItemManager().getDeletedItems().keySet().isEmpty()) { + if (!AuctionHouse.getAuctionItemManager().getDeletedItems().keySet().isEmpty()) { if (Settings.GARBAGE_DELETION_TIMED_MODE.getBoolean() && clock % Settings.GARBAGE_DELETION_TIMED_DELAY.getInt() == 0) { - instance.getDataManager().deleteItemsAsync(instance.getAuctionItemManager().getDeletedItems().values().stream().map(AuctionedItem::getId).collect(Collectors.toList())); + AuctionHouse.getDataManager().deleteItemsAsync(AuctionHouse.getAuctionItemManager().getDeletedItems().values().stream().map(AuctionedItem::getId).collect(Collectors.toList())); if (!Settings.DISABLE_CLEANUP_MSG.getBoolean()) - instance.getLocale().newMessage(TextUtils.formatText("&aCleaned a total of &e" + instance.getAuctionItemManager().getDeletedItems().size() + "&a items.")).sendPrefixedMessage(Bukkit.getConsoleSender()); - instance.getAuctionItemManager().getDeletedItems().clear(); + AuctionHouse.getInstance().getLocale().newMessage(TextUtils.formatText("&aCleaned a total of &e" + AuctionHouse.getAuctionItemManager().getDeletedItems().size() + "&a items.")).sendPrefixedMessage(Bukkit.getConsoleSender()); + AuctionHouse.getAuctionItemManager().getDeletedItems().clear(); } else { - if (instance.getAuctionItemManager().getDeletedItems().size() >= Settings.GARBAGE_DELETION_MAX_ITEMS.getInt()) { - instance.getDataManager().deleteItemsAsync(instance.getAuctionItemManager().getDeletedItems().values().stream().map(AuctionedItem::getId).collect(Collectors.toList())); + if (AuctionHouse.getAuctionItemManager().getDeletedItems().size() >= Settings.GARBAGE_DELETION_MAX_ITEMS.getInt()) { + AuctionHouse.getDataManager().deleteItemsAsync(AuctionHouse.getAuctionItemManager().getDeletedItems().values().stream().map(AuctionedItem::getId).collect(Collectors.toList())); if (!Settings.DISABLE_CLEANUP_MSG.getBoolean()) - instance.getLocale().newMessage(TextUtils.formatText("&aCleaned a total of &e" + instance.getAuctionItemManager().getDeletedItems().size() + "&a items.")).sendPrefixedMessage(Bukkit.getConsoleSender()); - instance.getAuctionItemManager().getDeletedItems().clear(); + AuctionHouse.getInstance().getLocale().newMessage(TextUtils.formatText("&aCleaned a total of &e" + AuctionHouse.getAuctionItemManager().getDeletedItems().size() + "&a items.")).sendPrefixedMessage(Bukkit.getConsoleSender()); + AuctionHouse.getAuctionItemManager().getDeletedItems().clear(); } } } @@ -108,7 +106,7 @@ public class TickAuctionsTask extends BukkitRunnable { if (!auctionItem.isExpired()) { if (Settings.BROADCAST_AUCTION_ENDING.getBoolean()) { if (timeRemaining <= Settings.BROADCAST_AUCTION_ENDING_AT_TIME.getInt() && timeRemaining % 10 == 0 && timeRemaining != 0) { - Bukkit.getOnlinePlayers().forEach(player -> instance.getLocale().getMessage("auction.broadcast.ending") + Bukkit.getOnlinePlayers().forEach(player -> AuctionHouse.getInstance().getLocale().getMessage("auction.broadcast.ending") .processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemStack)) .processPlaceholder("seconds", timeRemaining) .sendPrefixedMessage(player)); @@ -121,7 +119,7 @@ public class TickAuctionsTask extends BukkitRunnable { // the owner is the highest bidder, so just expire if (auctionItem.getHighestBidder().equals(auctionItem.getOwner())) { if (auctionItem.isServerItem() || auctionItem.isRequest()) - instance.getAuctionItemManager().sendToGarbage(auctionItem); + AuctionHouse.getAuctionItemManager().sendToGarbage(auctionItem); else auctionItem.setExpired(true); continue; @@ -133,9 +131,9 @@ public class TickAuctionsTask extends BukkitRunnable { double tax = Settings.TAX_ENABLED.getBoolean() ? (Settings.TAX_SALES_TAX_AUCTION_WON_PERCENTAGE.getDouble() / 100) * auctionItem.getCurrentPrice() : 0D; if (!Settings.BIDDING_TAKES_MONEY.getBoolean()) - if (!EconomyManager.hasBalance(auctionWinner, Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice + tax : finalPrice)) { + if (!AuctionHouse.getCurrencyManager().has(auctionWinner, Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice + tax : finalPrice)) { if (auctionItem.isServerItem()) - instance.getAuctionItemManager().sendToGarbage(auctionItem); + AuctionHouse.getAuctionItemManager().sendToGarbage(auctionItem); else auctionItem.setExpired(true); continue; @@ -143,7 +141,7 @@ public class TickAuctionsTask extends BukkitRunnable { AuctionEndEvent auctionEndEvent = new AuctionEndEvent(Bukkit.getOfflinePlayer(auctionItem.getOwner()), auctionWinner, auctionItem, AuctionSaleType.USED_BIDDING_SYSTEM, tax); - instance.getServer().getPluginManager().callEvent(auctionEndEvent); + AuctionHouse.getInstance().getServer().getPluginManager().callEvent(auctionEndEvent); if (auctionEndEvent.isCancelled()) continue; @@ -154,26 +152,26 @@ public class TickAuctionsTask extends BukkitRunnable { // alert seller and buyer if (Bukkit.getOfflinePlayer(auctionItem.getOwner()).isOnline()) { - instance.getLocale().getMessage("auction.itemsold") + AuctionHouse.getInstance().getLocale().getMessage("auction.itemsold") .processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemStack)) .processPlaceholder("amount", itemStack.clone().getAmount()) .processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice : finalPrice - tax)) .processPlaceholder("buyer_name", Bukkit.getOfflinePlayer(auctionItem.getHighestBidder()).getName()) .processPlaceholder("buyer_displayname", AuctionAPI.getInstance().getDisplayName(Bukkit.getOfflinePlayer(auctionItem.getHighestBidder()))) .sendPrefixedMessage(Bukkit.getOfflinePlayer(auctionItem.getOwner()).getPlayer()); - instance.getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(Bukkit.getOfflinePlayer(auctionItem.getOwner())))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice : finalPrice - tax)).sendPrefixedMessage(Bukkit.getOfflinePlayer(auctionItem.getOwner()).getPlayer()); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(Bukkit.getOfflinePlayer(auctionItem.getOwner())))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice : finalPrice - tax)).sendPrefixedMessage(Bukkit.getOfflinePlayer(auctionItem.getOwner()).getPlayer()); } if (auctionWinner.isOnline()) { assert auctionWinner.getPlayer() != null; - instance.getLocale().getMessage("auction.bidwon") + AuctionHouse.getInstance().getLocale().getMessage("auction.bidwon") .processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemStack)) .processPlaceholder("amount", itemStack.getAmount()) .processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice + tax : finalPrice)) .sendPrefixedMessage(auctionWinner.getPlayer()); if (!Settings.BIDDING_TAKES_MONEY.getBoolean()) - instance.getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(auctionWinner.getPlayer()))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice + tax : finalPrice)).sendPrefixedMessage(auctionWinner.getPlayer()); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(auctionWinner.getPlayer()))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice + tax : finalPrice)).sendPrefixedMessage(auctionWinner.getPlayer()); // remove the dupe tracking NBT.modify(itemStack, nbt -> { @@ -189,7 +187,7 @@ public class TickAuctionsTask extends BukkitRunnable { else PlayerUtils.giveItem(auctionWinner.getPlayer(), itemStack); - instance.getAuctionItemManager().sendToGarbage(auctionItem); + AuctionHouse.getAuctionItemManager().sendToGarbage(auctionItem); continue; } } else { @@ -198,7 +196,7 @@ public class TickAuctionsTask extends BukkitRunnable { else PlayerUtils.giveItem(auctionWinner.getPlayer(), itemStack); - instance.getAuctionItemManager().sendToGarbage(auctionItem); + AuctionHouse.getAuctionItemManager().sendToGarbage(auctionItem); continue; } }