Added Gem booster use.

This commit is contained in:
Jonathan Williams 2014-08-26 00:33:48 -07:00
parent 162a86d4b2
commit 137b8692e4
9 changed files with 127 additions and 57 deletions

View File

@ -37,7 +37,7 @@ public class CosmeticManager extends MiniPlugin
private boolean _showInterface = true;
private int _interfaceSlot = 4;
public CosmeticManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, GadgetManager gadgetManager, MountManager mountManager, PetManager petManager)
public CosmeticManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, GadgetManager gadgetManager, MountManager mountManager, PetManager petManager, boolean useBooster)
{
super("Cosmetic Manager", plugin);
@ -46,7 +46,7 @@ public class CosmeticManager extends MiniPlugin
_mountManager = mountManager;
_petManager = petManager;
_shop = new CosmeticShop(this, clientManager, donationManager, _moduleName);
_shop = new CosmeticShop(this, clientManager, donationManager, _moduleName, useBooster);
}
public void showInterface(boolean showInterface)

View File

@ -0,0 +1,44 @@
package mineplex.core.cosmetic.event;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class ActivateGemBoosterEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
private boolean _cancelled = false;
public ActivateGemBoosterEvent(Player player)
{
_player = player;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public Player getPlayer()
{
return _player;
}
public void setCancelled(boolean cancel)
{
_cancelled = cancel;
}
public boolean isCancelled()
{
return _cancelled;
}
}

View File

@ -13,7 +13,6 @@ import mineplex.core.cosmetic.ui.page.PetTagPage;
import mineplex.core.cosmetic.ui.page.TreasurePage;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.event.ItemGadgetOutOfAmmoEvent;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.updater.UpdateType;
@ -21,10 +20,13 @@ import mineplex.core.updater.event.UpdateEvent;
public class CosmeticShop extends ShopBase<CosmeticManager> implements PluginMessageListener
{
public CosmeticShop(CosmeticManager plugin, CoreClientManager clientManager, DonationManager donationManager, String name)
private boolean _useBooster;
public CosmeticShop(CosmeticManager plugin, CoreClientManager clientManager, DonationManager donationManager, String name, boolean useBooster)
{
super(plugin, clientManager, donationManager, name, CurrencyType.Gems, CurrencyType.Coins);
_useBooster = useBooster;
plugin.GetPlugin().getServer().getMessenger().registerIncomingPluginChannel(plugin.GetPlugin(), "MC|ItemName", this);
}
@ -56,6 +58,7 @@ public class CosmeticShop extends ShopBase<CosmeticManager> implements PluginMes
{
new GadgetPage(Plugin, this, ClientManager, DonationManager, "Gadgets", event.getPlayer()).purchaseGadget(event.getPlayer(), event.getGadget());
}
@EventHandler
public void updateTreasure(UpdateEvent event)
{
@ -67,4 +70,10 @@ public class CosmeticShop extends ShopBase<CosmeticManager> implements PluginMes
if (shop instanceof TreasurePage)
((TreasurePage) shop).update();
}
}}
}
public boolean getBoosterEnabled()
{
return _useBooster;
}
}

View File

@ -1,29 +1,26 @@
package mineplex.core.cosmetic.ui.page;
import org.bukkit.ChatColor;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.CurrencyType;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.event.ActivateGemBoosterEvent;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.cosmetic.ui.button.DeactivateGadgetButton;
import mineplex.core.cosmetic.ui.button.DeactivateMountButton;
import mineplex.core.cosmetic.ui.button.DeactivatePetButton;
import mineplex.core.cosmetic.ui.button.OpenGadgets;
import mineplex.core.cosmetic.ui.button.OpenMorphs;
import mineplex.core.cosmetic.ui.button.OpenMounts;
import mineplex.core.cosmetic.ui.button.OpenParticles;
import mineplex.core.cosmetic.ui.button.OpenPets;
import mineplex.core.cosmetic.ui.button.TreasureButton;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.inventory.GemBooster;
import mineplex.core.mount.Mount;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.item.SingleButton;
import mineplex.core.shop.page.ConfirmationPage;
@ -52,35 +49,48 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
else
{
*/
AddItem(13, new ShopItem(Material.CHEST, C.cGold + treasureChestCount + " Treasure Chests", 1, false));
AddItem(13, new ShopItem(Material.CHEST, C.cGold + treasureChestCount + " Treasure Chests (COMING SOON!)", 1, false));
//}
final GemBooster gemBoosterItem = new GemBooster(Plugin.getInventoryManager().Get(Player).getItemCount("Gem Booster"));
final GemBooster gemBoosterItem = new GemBooster(Shop.getBoosterEnabled(), Plugin.getInventoryManager().Get(Player).getItemCount("Gem Booster"));
if (DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Coins) >= gemBoosterItem.GetCost(CurrencyType.Coins))
{
AddButton(15, new ShopItem(
gemBoosterItem.GetDisplayMaterial(),
gemBoosterItem.GetDisplayName(),
gemBoosterItem.GetDescription(),
1,
false),
new SingleButton()
AddButton(15, new ShopItem(
gemBoosterItem.GetDisplayMaterial(),
gemBoosterItem.GetDisplayName(),
gemBoosterItem.GetDescription(),
1,
false),
new IButton()
{
@Override
public void ClickedLeft(Player player)
{
@Override
public void Clicked(Player player)
if (Shop.getBoosterEnabled())
{
Shop.OpenPageForPlayer(Player, new ConfirmationPage<CosmeticManager, CosmeticShop>(Plugin, Shop, ClientManager, DonationManager, new Runnable()
{
public void run()
{
Plugin.getInventoryManager().addItemToInventory(Player, "Utility", "Gem Booster", 20);
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, Player));
}
}, null, gemBoosterItem, CurrencyType.Coins, Player));
ActivateGemBoosterEvent boosterEvent = new ActivateGemBoosterEvent(player);
Bukkit.getServer().getPluginManager().callEvent(boosterEvent);
if (!boosterEvent.isCancelled())
Plugin.getInventoryManager().addItemToInventory(Player, "Utility", "Gem Booster", -1);
}
else
{
purchaseGemBooster(gemBoosterItem, player);
}
}
);
@Override
public void ClickedRight(Player player)
{
purchaseGemBooster(gemBoosterItem, player);
}
}
);
if (DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Coins) >= gemBoosterItem.GetCost(CurrencyType.Coins))
{
}
else
{
@ -186,6 +196,18 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
}
}
private void purchaseGemBooster(GemBooster gemBoosterItem, Player player)
{
Shop.OpenPageForPlayer(Player, new ConfirmationPage<CosmeticManager, CosmeticShop>(Plugin, Shop, ClientManager, DonationManager, new Runnable()
{
public void run()
{
Plugin.getInventoryManager().addItemToInventory(Player, "Utility", "Gem Booster", 20);
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, Player));
}
}, null, gemBoosterItem, CurrencyType.Coins, Player));
}
public void openParticles(Player player)
{
Shop.OpenPageForPlayer(player, new ParticlePage(Plugin, Shop, ClientManager, DonationManager, "Particles", player));

View File

@ -5,20 +5,25 @@ import org.bukkit.entity.Player;
import mineplex.core.common.CurrencyType;
import mineplex.core.common.util.C;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.shop.item.SalesPackageBase;
public class GemBooster extends SalesPackageBase
{
public GemBooster(int gemBoosters)
public GemBooster(boolean enabled, int gemBoosters)
{
super("20 Gem Booster Pack", Material.EMERALD, (byte)0, new String[]
{
C.cYellow + "1000 Coins",
" ",
(enabled ? C.cGreen + "Left-Click To Use:" : ""),
C.cWhite + "Use these before games start to",
C.cWhite + "boost the amount of Gems earned",
C.cWhite + "for all players in the game!",
" ",
C.cGreen + "Right-Click To Purchase:",
C.cWhite + "20 Gem Boosters for " + C.cYellow + "1000 Coins",
" ",
C.cWhite + "Your Gem Boosters: " + C.cGreen + gemBoosters
}, 1000, 20);

View File

@ -157,7 +157,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
_mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager);
_inventoryManager = new InventoryManager(plugin);
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin));
new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager);
new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, false);
_partyManager = partyManager;
_preferences = preferences;

View File

@ -116,7 +116,7 @@ public class Arcade extends JavaPlugin
PetManager petManager = new PetManager(this, _clientManager, _donationManager, creature, webServerAddress);
MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager);
GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager);
CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager);
CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, true);
cosmeticManager.setInterfaceSlot(7);
//Arcade Manager

View File

@ -26,7 +26,6 @@ import nautilus.game.arcade.game.games.halloween.Halloween;
import nautilus.game.arcade.game.games.hideseek.HideSeek;
import nautilus.game.arcade.game.games.micro.Micro;
import nautilus.game.arcade.game.games.milkcow.MilkCow;
import nautilus.game.arcade.game.games.minestrike.MineStrike;
import nautilus.game.arcade.game.games.mineware.MineWare;
import nautilus.game.arcade.game.games.quiver.Quiver;
import nautilus.game.arcade.game.games.quiver.QuiverTeams;

View File

@ -41,6 +41,7 @@ import org.bukkit.scoreboard.Scoreboard;
import mineplex.core.account.CoreClient;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilEnt;
@ -51,6 +52,7 @@ import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilText.TextAlign;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.cosmetic.event.ActivateGemBoosterEvent;
import mineplex.core.donation.Donor;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.packethandler.IPacketRunnable;
@ -1178,29 +1180,18 @@ public class GameLobbyManager implements IPacketRunnable, Listener
}
@EventHandler(priority = EventPriority.LOWEST)
public void GemBoosterInteract(PlayerInteractEvent event)
public void GemBoosterInteract(ActivateGemBoosterEvent event)
{
if (Manager.IsTournamentServer())
if (Manager.IsTournamentServer() || Manager.GetGame() == null || Manager.GetGame().GetState() != GameState.Recruit)
{
event.setCancelled(true);
event.getPlayer().sendMessage(F.main("Arcade", "You can't use Gem Boosters right now."));
return;
}
Player player = event.getPlayer();
if (player.getItemInHand() == null)
return;
if (player.getItemInHand().getType() != Material.EMERALD)
return;
if (Manager.GetGame() == null)
return;
if (Manager.GetGame().GetState() != GameState.Recruit)
return;
if (Manager.getInventoryManager().Get(player).getItemCount("Gem Booster") <= 0)
return;
Manager.GetGame().AddGemBooster(player);
Manager.GetGame().AddGemBooster(event.getPlayer());
}
@EventHandler(priority = EventPriority.LOWEST)