mirror of
https://github.com/Crazy-Crew/CrazyAuctions.git
synced 2024-11-28 12:56:50 +01:00
add the ability to periodically update items in open auction menus
This commit is contained in:
parent
0394518e75
commit
3d9c011185
@ -59,16 +59,26 @@ public class CrazyAuctions extends Vital {
|
||||
this.userManager.updateAuctionsCache();
|
||||
|
||||
// we want to update this cache, after the cache above... because we will also calculate if items are expired!
|
||||
this.userManager.updateExpiredCache();
|
||||
|
||||
/*new FoliaRunnable(getServer().getGlobalRegionScheduler()) {
|
||||
new FoliaRunnable(getServer().getGlobalRegionScheduler()) {
|
||||
@Override
|
||||
public void run() {
|
||||
userManager.updateAuctionsCache();
|
||||
|
||||
//todo() update existing inventories.
|
||||
for (final Player player : getServer().getOnlinePlayers()) {
|
||||
final Inventory inventory = player.getInventory();
|
||||
|
||||
if (inventory instanceof AuctionsMenu menu) {
|
||||
menu.calculateItems();
|
||||
|
||||
continue;
|
||||
}
|
||||
}.runAtFixedRate(this, 20, 300 * 5);*/
|
||||
|
||||
if (inventory instanceof CurrentMenu menu) {
|
||||
menu.calculateItems();
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runAtFixedRate(this, 20, 300 * 5);
|
||||
|
||||
this.crazyManager = new CrazyManager();
|
||||
this.crazyManager.load();
|
||||
|
@ -82,9 +82,7 @@ public class AuctionsMenu extends Holder {
|
||||
));
|
||||
}
|
||||
|
||||
getItems(); // populate the inventory
|
||||
|
||||
this.maxPages = getMaxPage(this.items);
|
||||
calculateItems();
|
||||
|
||||
HolderManager.addShopType(this.player, this.shopType);
|
||||
|
||||
@ -363,7 +361,7 @@ public class AuctionsMenu extends Holder {
|
||||
GuiManager.openBuying(player, auction_id);
|
||||
}
|
||||
|
||||
private void getItems() {
|
||||
public void calculateItems() {
|
||||
this.userManager.getAuctions().forEach(((uuid, auctions) -> auctions.forEach(auction -> {
|
||||
final ItemBuilder itemBuilder = auction.getActiveItem(this.shopType);
|
||||
|
||||
@ -373,5 +371,7 @@ public class AuctionsMenu extends Holder {
|
||||
|
||||
this.items.add(auction);
|
||||
})));
|
||||
|
||||
this.maxPages = getMaxPage(this.items);
|
||||
}
|
||||
}
|
@ -45,9 +45,7 @@ public class CurrentMenu extends Holder {
|
||||
"WhatIsThis.CurrentItems"
|
||||
));
|
||||
|
||||
this.items = this.userManager.getAuctions().get(this.player.getUniqueId());
|
||||
|
||||
this.maxPages = getMaxPage(this.items);
|
||||
calculateItems();
|
||||
|
||||
for (final String key : this.options) {
|
||||
if (!this.config.contains("Settings.GUISettings.OtherSettings." + key)) {
|
||||
@ -164,4 +162,10 @@ public class CurrentMenu extends Holder {
|
||||
|
||||
GuiManager.openPlayersCurrentList(player, menu.getPage());
|
||||
}
|
||||
|
||||
public void calculateItems() {
|
||||
this.items = this.userManager.getAuctions().get(this.player.getUniqueId());
|
||||
|
||||
this.maxPages = getMaxPage(this.items);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user