🔃 added an auto refresh sync option

Took 25 seconds
This commit is contained in:
Kiran Hart 2024-02-09 13:05:10 -05:00
parent bc2a8fa79c
commit d94d9a05ef
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3
2 changed files with 18 additions and 11 deletions

View File

@ -20,14 +20,12 @@ package ca.tweetzy.auctionhouse.guis;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.auction.ListingType;
import ca.tweetzy.auctionhouse.events.AuctionBidEvent;
import ca.tweetzy.auctionhouse.hooks.FloodGateHook;
import ca.tweetzy.auctionhouse.hooks.PlaceholderAPIHook;
import ca.tweetzy.auctionhouse.auction.AuctionPayment;
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
import ca.tweetzy.auctionhouse.auction.ListingType;
import ca.tweetzy.auctionhouse.auction.enums.*;
import ca.tweetzy.auctionhouse.events.AuctionBidEvent;
import ca.tweetzy.auctionhouse.guis.admin.GUIAdminItem;
import ca.tweetzy.auctionhouse.guis.confirmation.GUIConfirmBid;
import ca.tweetzy.auctionhouse.guis.confirmation.GUIConfirmPurchase;
@ -39,6 +37,8 @@ import ca.tweetzy.auctionhouse.guis.transaction.GUITransactionType;
import ca.tweetzy.auctionhouse.helpers.BundleUtil;
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
import ca.tweetzy.auctionhouse.helpers.input.TitleInput;
import ca.tweetzy.auctionhouse.hooks.FloodGateHook;
import ca.tweetzy.auctionhouse.hooks.PlaceholderAPIHook;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.compatibility.ServerVersion;
import ca.tweetzy.core.compatibility.XSound;
@ -173,9 +173,9 @@ public class GUIAuctionHouse extends AbstractPlaceholderGui {
if (this.auctionPlayer.getAuctionSortType() == AuctionSortType.PRICE) {
this.items = this.items.stream().sorted(Comparator.comparingDouble(AuctionedItem::getCurrentPrice).reversed()).collect(Collectors.toList());
}else if (this.auctionPlayer.getAuctionSortType() == AuctionSortType.RECENT) {
} else if (this.auctionPlayer.getAuctionSortType() == AuctionSortType.RECENT) {
this.items = this.items.stream().sorted(Comparator.comparingLong(AuctionedItem::getExpiresAt).reversed()).collect(Collectors.toList());
}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());
}
}
@ -195,17 +195,19 @@ public class GUIAuctionHouse extends AbstractPlaceholderGui {
// option for only whitelisted shit
if (Settings.FILTER_ONLY_USES_WHITELIST.getBoolean()) {
if (!Settings.FILTER_WHITELIST_USES_DURABILITY.getBoolean())
return AuctionHouse.getInstance().getFilterManager().getFilterWhitelist(category).stream().anyMatch(item -> item.isSimilar(auctionItem.getItem()));
return AuctionHouse.getInstance().getFilterManager().getFilterWhitelist(category).stream().anyMatch(item -> item != null && item.isSimilar(auctionItem.getItem()));
else
return AuctionHouse.getInstance().getFilterManager().getFilterWhitelist(category).stream().anyMatch(item -> item.getType() == auctionItem.getItem().getType() && item.getDurability() == auctionItem.getItem().getDurability());
return AuctionHouse.getInstance().getFilterManager().getFilterWhitelist(category).stream().anyMatch(item -> item != null && item.getType() == auctionItem.getItem().getType() && item.getDurability() == auctionItem.getItem().getDurability());
}
return auctionItem.getCategory() == category ||
AuctionHouse.getInstance().getFilterManager().getFilterWhitelist(category).stream().anyMatch(item -> item.isSimilar(auctionItem.getItem()));
AuctionHouse.getInstance().getFilterManager().getFilterWhitelist(category).stream().anyMatch(item -> item != null && item.isSimilar(auctionItem.getItem()));
}
private boolean checkSearchCriteria(String phrase, AuctionedItem item) {
ItemStack stack = item.getItem();
if (stack == null) return false;
return AuctionAPI.getInstance().matchSearch(phrase, AuctionAPI.getInstance().getItemName(stack)) ||
AuctionAPI.getInstance().matchSearch(phrase, item.getCategory().getTranslatedType()) ||
AuctionAPI.getInstance().matchSearch(phrase, stack.getType().name()) ||
@ -459,7 +461,7 @@ public class GUIAuctionHouse extends AbstractPlaceholderGui {
int slot = 0;
for (AuctionedItem auctionItem : data) {
setButton(slot++, auctionItem.isRequest() ? auctionItem.getDisplayRequestStack(AuctionStackType.MAIN_AUCTION_HOUSE) : auctionItem.getDisplayStack(AuctionStackType.MAIN_AUCTION_HOUSE), e -> {
setButton(slot++, auctionItem.isRequest() ? auctionItem.getDisplayRequestStack(AuctionStackType.MAIN_AUCTION_HOUSE) : auctionItem.getDisplayStack(AuctionStackType.MAIN_AUCTION_HOUSE), e -> {
// Non Type specific actions
if (e.clickType == ClickType.valueOf(Settings.CLICKS_INSPECT_CONTAINER.getString().toUpperCase())) {
handleContainerInspect(e);
@ -759,7 +761,11 @@ public class GUIAuctionHouse extends AbstractPlaceholderGui {
====================== AUTO REFRESH ======================
*/
private void makeMess() {
task = Bukkit.getServer().getScheduler().runTaskTimerAsynchronously(AuctionHouse.getInstance(), this::drawItems, 0L, (long) 20 * Settings.TICK_UPDATE_GUI_TIME.getInt());
if (Settings.AUTO_REFRESH_AUCTION_PAGE_SYNC.getBoolean()) {
task = Bukkit.getServer().getScheduler().runTaskTimer(AuctionHouse.getInstance(), this::drawItems, 0L, (long) 20 * Settings.TICK_UPDATE_GUI_TIME.getInt());
} else {
task = Bukkit.getServer().getScheduler().runTaskTimerAsynchronously(AuctionHouse.getInstance(), this::drawItems, 0L, (long) 20 * Settings.TICK_UPDATE_GUI_TIME.getInt());
}
}
private void cleanup() {

View File

@ -81,6 +81,7 @@ public class Settings {
public static final ConfigSetting OWNER_CAN_BID_OWN_ITEM = new ConfigSetting(config, "auction setting.purchase.owner can bid on own item", false, "Should the owner of an auction be able to bid on it?", "This probably should be set to false...");
public static final ConfigSetting OWNER_CAN_FULFILL_OWN_REQUEST = new ConfigSetting(config, "auction setting.purchase.owner can fulfill own request", false, "Should the owner of a request be able to fulfill it", "This probably should be set to false...");
public static final ConfigSetting AUTO_REFRESH_AUCTION_PAGES = new ConfigSetting(config, "auction setting.auto refresh auction pages", true, "Should auction pages auto refresh?");
public static final ConfigSetting AUTO_REFRESH_AUCTION_PAGE_SYNC = new ConfigSetting(config, "auction setting.auto refresh auction pages synchronously", false, "Should auction pages auto refresh use a synchronous?");
public static final ConfigSetting AUTO_REFRESH_DOES_SLOT_CLEAR = new ConfigSetting(config, "auction setting.auto refresh does slot clear", true, "If true, on every refresh, the slots will be cleared (replaced by default item) then the actual listings will be placed.");
public static final ConfigSetting USE_SHORT_NUMBERS_ON_ITEMS = new ConfigSetting(config, "auction setting.use short numbers", false, "Should numbers be shortened into a prefixed form?");
public static final ConfigSetting USE_SHORT_NUMBERS_ON_PLAYER_BALANCE = new ConfigSetting(config, "auction setting.use short numbers on balance", false, "Should numbers be shortened into a prefixed form for the player balance?");