mirror of
https://github.com/kiranhart/Auction-House.git
synced 2025-02-15 19:11:31 +01:00
💎 added currency filter in main menu
Took 17 minutes
This commit is contained in:
parent
234c13f11c
commit
f12fd3ec7b
@ -19,6 +19,7 @@
|
|||||||
package ca.tweetzy.auctionhouse.auction;
|
package ca.tweetzy.auctionhouse.auction;
|
||||||
|
|
||||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||||
|
import ca.tweetzy.auctionhouse.api.currency.AbstractCurrency;
|
||||||
import ca.tweetzy.auctionhouse.auction.enums.AuctionItemCategory;
|
import ca.tweetzy.auctionhouse.auction.enums.AuctionItemCategory;
|
||||||
import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType;
|
import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType;
|
||||||
import ca.tweetzy.auctionhouse.auction.enums.AuctionSortType;
|
import ca.tweetzy.auctionhouse.auction.enums.AuctionSortType;
|
||||||
@ -59,7 +60,6 @@ public class AuctionPlayer {
|
|||||||
private AuctionSortType transactionSortType;
|
private AuctionSortType transactionSortType;
|
||||||
private TransactionViewFilter transactionViewFilter;
|
private TransactionViewFilter transactionViewFilter;
|
||||||
|
|
||||||
|
|
||||||
private boolean showListingInfo;
|
private boolean showListingInfo;
|
||||||
private long lastListedItem;
|
private long lastListedItem;
|
||||||
|
|
||||||
@ -67,6 +67,7 @@ public class AuctionPlayer {
|
|||||||
private int assignedTaskId;
|
private int assignedTaskId;
|
||||||
|
|
||||||
private long endAllRequestTime;
|
private long endAllRequestTime;
|
||||||
|
private AbstractCurrency selectedCurrencyFilter;
|
||||||
|
|
||||||
public AuctionPlayer(UUID uuid) {
|
public AuctionPlayer(UUID uuid) {
|
||||||
this(
|
this(
|
||||||
@ -84,7 +85,8 @@ public class AuctionPlayer {
|
|||||||
-1,
|
-1,
|
||||||
null,
|
null,
|
||||||
-1,
|
-1,
|
||||||
-1
|
-1,
|
||||||
|
AuctionHouse.getCurrencyManager().getAllCurrency()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,9 +20,11 @@ package ca.tweetzy.auctionhouse.auction;
|
|||||||
|
|
||||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||||
import ca.tweetzy.auctionhouse.api.AuctionAPI;
|
import ca.tweetzy.auctionhouse.api.AuctionAPI;
|
||||||
|
import ca.tweetzy.auctionhouse.api.currency.AbstractCurrency;
|
||||||
import ca.tweetzy.auctionhouse.auction.enums.AuctionItemCategory;
|
import ca.tweetzy.auctionhouse.auction.enums.AuctionItemCategory;
|
||||||
import ca.tweetzy.auctionhouse.auction.enums.AuctionStackType;
|
import ca.tweetzy.auctionhouse.auction.enums.AuctionStackType;
|
||||||
import ca.tweetzy.auctionhouse.helpers.BundleUtil;
|
import ca.tweetzy.auctionhouse.helpers.BundleUtil;
|
||||||
|
import ca.tweetzy.auctionhouse.impl.currency.ItemCurrency;
|
||||||
import ca.tweetzy.auctionhouse.model.MaterialCategorizer;
|
import ca.tweetzy.auctionhouse.model.MaterialCategorizer;
|
||||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||||
import ca.tweetzy.core.utils.TextUtils;
|
import ca.tweetzy.core.utils.TextUtils;
|
||||||
@ -363,4 +365,12 @@ public class AuctionedItem {
|
|||||||
public boolean isListingPriorityActive() {
|
public boolean isListingPriorityActive() {
|
||||||
return this.hasListingPriority && this.priorityExpiresAt > System.currentTimeMillis();
|
return this.hasListingPriority && this.priorityExpiresAt > System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean currencyMatches(AbstractCurrency currencyToCheck) {
|
||||||
|
final String[] split = this.currency.split("/");
|
||||||
|
if (split[0].equalsIgnoreCase("AuctionHouse") && split[1].equalsIgnoreCase("Item") && currencyToCheck instanceof ItemCurrency)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return split[0].equalsIgnoreCase(currencyToCheck.getOwningPlugin()) && split[1].equalsIgnoreCase(currencyToCheck.getCurrencyName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -967,7 +967,8 @@ public class DataManager extends DataManagerAbstract {
|
|||||||
resultSet.getLong("last_listed_item"),
|
resultSet.getLong("last_listed_item"),
|
||||||
null,
|
null,
|
||||||
-1,
|
-1,
|
||||||
-1
|
-1,
|
||||||
|
AuctionHouse.getCurrencyManager().getAllCurrency()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,6 +107,11 @@ public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI<AuctionedItem
|
|||||||
} else if (this.auctionPlayer.getAuctionSortType() == AuctionSortType.OLDEST) {
|
} else if (this.auctionPlayer.getAuctionSortType() == AuctionSortType.OLDEST) {
|
||||||
this.items = this.items.stream().sorted(Comparator.comparingLong(AuctionedItem::getExpiresAt)).collect(Collectors.toList());
|
this.items = this.items.stream().sorted(Comparator.comparingLong(AuctionedItem::getExpiresAt)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// currency
|
||||||
|
if (this.auctionPlayer.getSelectedCurrencyFilter() != AuctionHouse.getCurrencyManager().getAllCurrency()) {
|
||||||
|
this.items = this.items.stream().filter(item -> item.currencyMatches(this.auctionPlayer.getSelectedCurrencyFilter())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.items.sort(Comparator.comparing(AuctionedItem::isInfinite).reversed());
|
this.items.sort(Comparator.comparing(AuctionedItem::isInfinite).reversed());
|
||||||
@ -652,6 +657,7 @@ public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI<AuctionedItem
|
|||||||
.lore(this.player, Replacer.replaceVariables(Settings.GUI_AUCTION_HOUSE_ITEMS_FILTER_LORE.getStringList(),
|
.lore(this.player, Replacer.replaceVariables(Settings.GUI_AUCTION_HOUSE_ITEMS_FILTER_LORE.getStringList(),
|
||||||
"filter_category", auctionPlayer.getSelectedFilter().getTranslatedType(),
|
"filter_category", auctionPlayer.getSelectedFilter().getTranslatedType(),
|
||||||
"filter_auction_type", auctionPlayer.getSelectedSaleType().getTranslatedType(),
|
"filter_auction_type", auctionPlayer.getSelectedSaleType().getTranslatedType(),
|
||||||
|
"filter_currency", auctionPlayer.getSelectedCurrencyFilter().getDisplayName(),
|
||||||
"filter_sort_order", auctionPlayer.getAuctionSortType().getTranslatedType()))
|
"filter_sort_order", auctionPlayer.getAuctionSortType().getTranslatedType()))
|
||||||
.make(), e -> {
|
.make(), e -> {
|
||||||
|
|
||||||
@ -683,6 +689,11 @@ public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI<AuctionedItem
|
|||||||
updatePlayerFilter(this.auctionPlayer);
|
updatePlayerFilter(this.auctionPlayer);
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (e.clickType == ClickType.valueOf(Settings.CLICKS_FILTER_CURRENCY.getString().toUpperCase())) {
|
||||||
|
this.auctionPlayer.setSelectedCurrencyFilter(AuctionHouse.getCurrencyManager().getNext(this.auctionPlayer.getSelectedCurrencyFilter()));
|
||||||
|
draw();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
package ca.tweetzy.auctionhouse.impl.currency;
|
||||||
|
|
||||||
|
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||||
|
import ca.tweetzy.auctionhouse.api.currency.AbstractCurrency;
|
||||||
|
import ca.tweetzy.flight.utils.Common;
|
||||||
|
import ca.tweetzy.flight.utils.PlayerUtil;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public final class AllCurrency extends AbstractCurrency {
|
||||||
|
|
||||||
|
// used for filtering only
|
||||||
|
public AllCurrency() {
|
||||||
|
super("AuctionHouse", "AllCurrencies", Common.colorize(AuctionHouse.getInstance().getLocale().getMessage("auction_filter.currency.all currencies").getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean has(OfflinePlayer player, double amount, ItemStack item) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean withdraw(OfflinePlayer player, double amount, ItemStack item) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean deposit(OfflinePlayer player, double amount, ItemStack 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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
package ca.tweetzy.auctionhouse.impl.currency;
|
package ca.tweetzy.auctionhouse.impl.currency;
|
||||||
|
|
||||||
|
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||||
import ca.tweetzy.auctionhouse.api.currency.AbstractCurrency;
|
import ca.tweetzy.auctionhouse.api.currency.AbstractCurrency;
|
||||||
|
import ca.tweetzy.flight.utils.Common;
|
||||||
import ca.tweetzy.flight.utils.PlayerUtil;
|
import ca.tweetzy.flight.utils.PlayerUtil;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -8,7 +10,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
public final class ItemCurrency extends AbstractCurrency {
|
public final class ItemCurrency extends AbstractCurrency {
|
||||||
|
|
||||||
public ItemCurrency() {
|
public ItemCurrency() {
|
||||||
super("AuctionHouse", "Item", "&bCustom Item");
|
super("AuctionHouse", "Item", Common.colorize(AuctionHouse.getInstance().getLocale().getMessage("auction_filter.currency.item currency").getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean has(OfflinePlayer player, double amount, ItemStack item) {
|
public boolean has(OfflinePlayer player, double amount, ItemStack item) {
|
||||||
|
@ -3,6 +3,7 @@ package ca.tweetzy.auctionhouse.model.manager;
|
|||||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||||
import ca.tweetzy.auctionhouse.api.currency.AbstractCurrency;
|
import ca.tweetzy.auctionhouse.api.currency.AbstractCurrency;
|
||||||
import ca.tweetzy.auctionhouse.api.manager.ListManager;
|
import ca.tweetzy.auctionhouse.api.manager.ListManager;
|
||||||
|
import ca.tweetzy.auctionhouse.impl.currency.AllCurrency;
|
||||||
import ca.tweetzy.auctionhouse.impl.currency.ItemCurrency;
|
import ca.tweetzy.auctionhouse.impl.currency.ItemCurrency;
|
||||||
import ca.tweetzy.auctionhouse.impl.currency.VaultCurrency;
|
import ca.tweetzy.auctionhouse.impl.currency.VaultCurrency;
|
||||||
import ca.tweetzy.auctionhouse.model.currency.EcoBitsEconomyLoader;
|
import ca.tweetzy.auctionhouse.model.currency.EcoBitsEconomyLoader;
|
||||||
@ -14,6 +15,7 @@ import lombok.NonNull;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.checkerframework.checker.units.qual.A;
|
||||||
|
|
||||||
public final class CurrencyManager extends ListManager<AbstractCurrency> {
|
public final class CurrencyManager extends ListManager<AbstractCurrency> {
|
||||||
|
|
||||||
@ -29,6 +31,15 @@ public final class CurrencyManager extends ListManager<AbstractCurrency> {
|
|||||||
return getManagerContent().stream().filter(currency -> currency.getCurrencyName().equalsIgnoreCase(currencyName)).findFirst().orElse(null);
|
return getManagerContent().stream().filter(currency -> currency.getCurrencyName().equalsIgnoreCase(currencyName)).findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AbstractCurrency getDefaultCurrency() {
|
||||||
|
final String[] CURRENCY_DEFAULT = Settings.CURRENCY_DEFAULT_SELECTED.getString().split("/");
|
||||||
|
return locateCurrency(CURRENCY_DEFAULT[0], CURRENCY_DEFAULT[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbstractCurrency getAllCurrency() {
|
||||||
|
return locateCurrency("AuctionHouse", "AllCurrencies");
|
||||||
|
}
|
||||||
|
|
||||||
public boolean has(@NonNull final OfflinePlayer offlinePlayer, @NonNull final String owningPlugin, @NonNull final String currencyName, final double amount) {
|
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"))
|
if (owningPlugin.equalsIgnoreCase("vault") || currencyName.equalsIgnoreCase("vault"))
|
||||||
return AuctionHouse.getEconomy().has(offlinePlayer, amount);
|
return AuctionHouse.getEconomy().has(offlinePlayer, amount);
|
||||||
@ -114,10 +125,23 @@ public final class CurrencyManager extends ListManager<AbstractCurrency> {
|
|||||||
return AuctionHouse.getAPI().getFinalizedCurrencyNumber(getBalance(offlinePlayer, currency.split("/")[0], currency.split("/")[1]), currency, currencyItem);
|
return AuctionHouse.getAPI().getFinalizedCurrencyNumber(getBalance(offlinePlayer, currency.split("/")[0], currency.split("/")[1]), currency, currencyItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AbstractCurrency getNext(@NonNull final AbstractCurrency current) {
|
||||||
|
int currentIndex = getManagerContent().indexOf(current);
|
||||||
|
if (currentIndex == -1) {
|
||||||
|
return locateCurrency("Vault");
|
||||||
|
}
|
||||||
|
|
||||||
|
int next = (currentIndex + 1) % getManagerContent().size();
|
||||||
|
return managerContent.get(next);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
|
// used to filter for all items, not actually a valid currency to be used
|
||||||
|
add(new AllCurrency());
|
||||||
|
|
||||||
// add vault by default
|
// add vault by default
|
||||||
add(new VaultCurrency());
|
add(new VaultCurrency());
|
||||||
add(new ItemCurrency());
|
add(new ItemCurrency());
|
||||||
|
@ -215,6 +215,9 @@ public class LocaleSettings {
|
|||||||
languageNodes.put("auction_filter.sort_order.price", "Price");
|
languageNodes.put("auction_filter.sort_order.price", "Price");
|
||||||
languageNodes.put("auction_filter.sort_order.oldest", "Oldest");
|
languageNodes.put("auction_filter.sort_order.oldest", "Oldest");
|
||||||
|
|
||||||
|
languageNodes.put("auction_filter.currency.all currencies", "All Currencies");
|
||||||
|
languageNodes.put("auction_filter.currency.item currency", "Item Currency");
|
||||||
|
|
||||||
languageNodes.put("transaction_filter.buy_type.sold", "Sold");
|
languageNodes.put("transaction_filter.buy_type.sold", "Sold");
|
||||||
languageNodes.put("transaction_filter.buy_type.bought", "Bought");
|
languageNodes.put("transaction_filter.buy_type.bought", "Bought");
|
||||||
languageNodes.put("transaction_filter.buy_type.all", "All");
|
languageNodes.put("transaction_filter.buy_type.all", "All");
|
||||||
|
@ -345,6 +345,18 @@ public class Settings {
|
|||||||
"&cIf you overlap click types (ex. LEFT for both inspect and buy) things will go crazy."
|
"&cIf you overlap click types (ex. LEFT for both inspect and buy) things will go crazy."
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public static final ConfigSetting CLICKS_FILTER_CURRENCY = new ConfigSetting(config, "auction setting.clicks.filter.listing currency", "SHIFT_LEFT",
|
||||||
|
"Valid Click Types",
|
||||||
|
"LEFT",
|
||||||
|
"RIGHT",
|
||||||
|
"SHIFT_LEFT",
|
||||||
|
"SHIFT_RIGHT",
|
||||||
|
"MIDDLE",
|
||||||
|
"DROP",
|
||||||
|
"",
|
||||||
|
"&cIf you overlap click types (ex. LEFT for both inspect and buy) things will go crazy."
|
||||||
|
);
|
||||||
|
|
||||||
public static final ConfigSetting CLICKS_FILTER_SORT_SALE_TYPE = new ConfigSetting(config, "auction setting.clicks.filter.sort sale type", "RIGHT",
|
public static final ConfigSetting CLICKS_FILTER_SORT_SALE_TYPE = new ConfigSetting(config, "auction setting.clicks.filter.sort sale type", "RIGHT",
|
||||||
"Valid Click Types",
|
"Valid Click Types",
|
||||||
"LEFT",
|
"LEFT",
|
||||||
@ -660,10 +672,12 @@ public class Settings {
|
|||||||
"&eItem Category&f: &7%filter_category%",
|
"&eItem Category&f: &7%filter_category%",
|
||||||
"&eAuction Type&f: &7%filter_auction_type%",
|
"&eAuction Type&f: &7%filter_auction_type%",
|
||||||
"&eSort Order&f: &7%filter_sort_order%",
|
"&eSort Order&f: &7%filter_sort_order%",
|
||||||
|
"&eCurrency&f: &7%filter_currency%",
|
||||||
"",
|
"",
|
||||||
"&7Left-Click to change item category",
|
"&7Left-Click to change item category",
|
||||||
"&7Right-Click to change change auction type",
|
"&7Right-Click to change change auction type",
|
||||||
"&7Shift Right-Click to change sort order",
|
"&7Shift Right-Click to change sort order",
|
||||||
|
"&7Shift Left-Click to change currency",
|
||||||
"&7Press Drop to reset filters"
|
"&7Press Drop to reset filters"
|
||||||
));
|
));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user