diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java index 651ad81d1..1bc17aa76 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java @@ -9,6 +9,7 @@ import mineplex.core.boosters.tips.BoosterTipManager; import mineplex.core.common.util.Callback; import mineplex.core.common.util.UtilEvent; import mineplex.core.donation.DonationManager; +import mineplex.core.inventory.InventoryManager; import mineplex.core.serverConfig.ServerConfiguration; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -28,19 +29,23 @@ public class BoosterManager extends MiniPlugin private BoosterRepository _repository; private CoreClientManager _clientManager; private DonationManager _donationManager; + private InventoryManager _inventoryManager; + private BoosterTipManager _tipManager; private BoosterShop _shop; private long _cacheLastUpdated; private Map> _boosterCache; - public BoosterManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) + public BoosterManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager) { super("Booster Manager", plugin); _repository = new BoosterRepository(); _clientManager = clientManager; _donationManager = donationManager; + _inventoryManager = inventoryManager; + _tipManager = new BoosterTipManager(plugin, clientManager, donationManager); _shop = new BoosterShop(this, clientManager, donationManager); } @@ -153,6 +158,25 @@ public class BoosterManager extends MiniPlugin return _tipManager; } + /** + * Returns the number of unactivated game boosters a player owns + * @param player + * @return The amount of unactivated game boosters the player owns + */ + public int getAvailableBoosterCount(Player player) + { + return _inventoryManager.Get(player).getItemCount("Game Booster"); + } + + /** + * Can players activate boosters on this server? + * @return true if players are able to activate a booster on this server + */ + public boolean canActivateBoosters() + { + return true; + } + public static void main(String[] args) throws IOException, URISyntaxException, InterruptedException { BoosterRepository repository = new BoosterRepository(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/gui/BoosterPage.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/gui/BoosterPage.java index 6d98746ba..bbfefa532 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/gui/BoosterPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/gui/BoosterPage.java @@ -3,10 +3,15 @@ package mineplex.core.boosters.gui; import mineplex.core.account.CoreClientManager; import mineplex.core.boosters.BoosterCategory; import mineplex.core.boosters.BoosterManager; +import mineplex.core.common.util.C; import mineplex.core.donation.DonationManager; +import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageBase; +import org.bukkit.Material; import org.bukkit.entity.Player; +import java.util.ArrayList; + /** * @author Shaun Bennett */ @@ -22,6 +27,17 @@ public class BoosterPage extends ShopPageBase @Override protected void buildPage() { + ArrayList lore = new ArrayList<>(); + lore.add(" "); + lore.add(C.cWhite + "You Own: " + getPlugin().getAvailableBoosterCount(getPlayer())); + if (getPlugin().canActivateBoosters()) + { + lore.add(" "); + lore.add(C.cWhite + "Click to Activate"); + } + + ShopItem booster = new ShopItem(Material.SUGAR, "Game Booster", lore.toArray(new String[0]), 0, false, false); + setItem(4, booster); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java index 3afb1ae7e..d71a61cd7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java @@ -1,5 +1,6 @@ package mineplex.core.cosmetic; +import mineplex.core.boosters.BoosterManager; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -35,13 +36,14 @@ public class CosmeticManager extends MiniPlugin private MountManager _mountManager; private PetManager _petManager; private TreasureManager _treasureManager; + private BoosterManager _boosterManager; private CosmeticShop _shop; private boolean _showInterface = true; private int _interfaceSlot = 4; - public CosmeticManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, GadgetManager gadgetManager, MountManager mountManager, PetManager petManager, TreasureManager treasureManager) + public CosmeticManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, GadgetManager gadgetManager, MountManager mountManager, PetManager petManager, TreasureManager treasureManager, BoosterManager boosterManager) { super("Cosmetic Manager", plugin); @@ -50,6 +52,7 @@ public class CosmeticManager extends MiniPlugin _mountManager = mountManager; _petManager = petManager; _treasureManager = treasureManager; + _boosterManager = boosterManager; _shop = new CosmeticShop(this, clientManager, donationManager, _moduleName); } @@ -195,7 +198,12 @@ public class CosmeticManager extends MiniPlugin return _treasureManager; } - public void disableTeamArmor() + public BoosterManager getBoosterManager() + { + return _boosterManager; + } + + public void disableTeamArmor() { for (Gadget gadget : getGadgetManager().getGadgets(GadgetType.Costume)) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BoosterPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BoosterPage.java index 04642e583..fe2538d59 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BoosterPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BoosterPage.java @@ -19,8 +19,6 @@ import java.util.ArrayList; */ public class BoosterPage extends ShopPageBase { - private int _count = 0; - public BoosterPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) { super(plugin, shop, clientManager, donationManager, "Game Boosters", player, 9); @@ -34,7 +32,7 @@ public class BoosterPage extends ShopPageBase ArrayList lore = new ArrayList<>(); lore.add(" "); - lore.add("You Own: " + _count++); + lore.add("You Own: " + _plugin.getBoosterManager().getAvailableBoosterCount(getPlayer())); ShopItem booster = new ShopItem(Material.SUGAR, "Game Booster", lore.toArray(new String[0]), 0, false, false); setItem(4, booster);