Starting to add gui logic

This commit is contained in:
Shaun Bennett 2016-05-28 11:23:26 -07:00
parent aebcfc2727
commit a1437a3044
4 changed files with 52 additions and 6 deletions

View File

@ -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<String, List<Booster>> _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();

View File

@ -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<BoosterManager, BoosterShop>
@Override
protected void buildPage()
{
ArrayList<String> 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);
}
}

View File

@ -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,6 +198,11 @@ public class CosmeticManager extends MiniPlugin
return _treasureManager;
}
public BoosterManager getBoosterManager()
{
return _boosterManager;
}
public void disableTeamArmor()
{
for (Gadget gadget : getGadgetManager().getGadgets(GadgetType.Costume))

View File

@ -19,8 +19,6 @@ import java.util.ArrayList;
*/
public class BoosterPage extends ShopPageBase<CosmeticManager, CosmeticShop>
{
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<CosmeticManager, CosmeticShop>
ArrayList<String> 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);