diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/SupportShop.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/SupportShop.java index b7a2ec820..c868a62a7 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/SupportShop.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/SupportShop.java @@ -1,48 +1,43 @@ package mineplex.staffServer.ui; import java.sql.SQLException; -import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.function.Consumer; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import mineplex.core.account.CoreClient; -import mineplex.core.common.util.F; import mineplex.core.common.util.UtilServer; +import mineplex.core.powerplayclub.PowerPlayData; import mineplex.core.shop.ShopBase; import mineplex.core.shop.page.ShopPageBase; +import mineplex.staffServer.LinkedTemporaryItem; import mineplex.staffServer.customerSupport.CustomerSupport; import mineplex.staffServer.repository.BonusEntry; public class SupportShop extends ShopBase { - private Map> _accountBonusLog; - private Map _activeBonusLogs; + private LinkedTemporaryItem> _bonusLog; + private LinkedTemporaryItem _powerPlayData; public SupportShop(CustomerSupport plugin) { super(plugin, plugin.getClientManager(), plugin.getDonationManager(), "Support"); - _accountBonusLog = new HashMap<>(); - _activeBonusLogs = new HashMap<>(); + _bonusLog = new LinkedTemporaryItem<>(); + _powerPlayData = new LinkedTemporaryItem<>(); } public void handleOpen(Player caller, CoreClient target) { - loadBonusLog(caller, target.getAccountId(), (success) -> - { - if (!success) - { - caller.sendMessage(F.main(getPlugin().getName(), "Unable to load rank bonuses. Please try again later.")); - return; - } - - openPageAsync(caller, new SupportHomePage(getPlugin(), this, caller, target)); - }); + // Who cares if they fail to load, the barrier + // button will just be there since the HomePage + // knows not to put it in. + loadBonusLog(caller, target.getAccountId(), (bS) -> + loadPowerPlay(caller, target.getAccountId(), (pS) -> + openPageAsync(caller, new SupportHomePage(getPlugin(), this, caller, target)))); } public void openPageAsync(Player player, SupportPage page) @@ -72,8 +67,7 @@ public class SupportShop extends ShopBase ); } - _accountBonusLog.put(accountId, bonusEntries); - _activeBonusLogs.put(caller, accountId); + _bonusLog.put(caller, accountId, bonusEntries); callback.accept(true); } catch (SQLException e) { @@ -83,20 +77,31 @@ public class SupportShop extends ShopBase }); } - public List getBonusLog(int accountId) + public void loadPowerPlay(Player caller, int accountId, Consumer callback) { - return _accountBonusLog.get(accountId); + getPlugin().getPowerPlayRepo().loadData(accountId).thenAccept((PowerPlayData data) -> + { + if (data == null) + { + callback.accept(false); + return; + } + + _powerPlayData.put(caller, accountId, data); + callback.accept(true); + }); } + public Map> getBonusLog() { return _bonusLog.getPrimaryMap(); } + + public Map getPowerPlayData() { return _powerPlayData.getPrimaryMap(); } + @Override protected void closeShopForPlayer(Player player) { super.closeShopForPlayer(player); - if (_activeBonusLogs.containsKey(player)) - { - _accountBonusLog.remove(_activeBonusLogs.remove(player)); - } + _bonusLog.remove(player); } @Override