Split up Cosmetic shop and Inventory

Added Ammo purchase for item gadgets.
This commit is contained in:
Jonathan Williams 2014-08-09 03:57:56 -05:00
parent 4e93707f0d
commit 8fe4e39207
48 changed files with 732 additions and 328 deletions

View File

@ -0,0 +1,130 @@
package mineplex.core.cosmetic;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.mount.MountManager;
import mineplex.core.pet.PetManager;
public class CosmeticManager extends MiniPlugin
{
private InventoryManager _inventoryManager;
private GadgetManager _gadgetManager;
private MountManager _mountManager;
private PetManager _petManager;
private CosmeticShop _shop;
boolean _showInterface = true;
public CosmeticManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, GadgetManager gadgetManager, MountManager mountManager, PetManager petManager)
{
super("Cosmetic Manager", plugin);
_inventoryManager = inventoryManager;
_gadgetManager = gadgetManager;
_mountManager = mountManager;
_petManager = petManager;
_shop = new CosmeticShop(this, clientManager, donationManager, _moduleName);
}
public void showInterface(boolean showInterface)
{
boolean changed = _showInterface == showInterface;
_showInterface = showInterface;
if (changed)
{
for (Player player : Bukkit.getOnlinePlayers())
{
if (_showInterface)
player.getInventory().setItem(4, ItemStackFactory.Instance.CreateStack(Material.CHEST, (byte)0, 1, ChatColor.RESET + C.cGreen + "Cosmetic Menu"));
else
player.getInventory().setItem(4, null);
}
}
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
if (!_showInterface)
return;
event.getPlayer().getInventory().setItem(4, ItemStackFactory.Instance.CreateStack(Material.CHEST, (byte)0, 1, ChatColor.RESET + C.cGreen + "Cosmetic Menu"));
}
@EventHandler
public void orderThatChest(final PlayerDropItemEvent event)
{
if (!_showInterface)
return;
if (event.getItemDrop().getItemStack().getType() == Material.CHEST)
{
Bukkit.getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
{
public void run()
{
if (event.getPlayer().isOnline())
{
event.getPlayer().getInventory().remove(Material.CHEST);
event.getPlayer().getInventory().setItem(4, ItemStackFactory.Instance.CreateStack(Material.CHEST, (byte)0, 1, ChatColor.RESET + C.cGreen + "Inventory Menu"));
event.getPlayer().updateInventory();
}
}
});
}
}
@EventHandler
public void openShop(PlayerInteractEvent event)
{
if (!_showInterface)
return;
if (event.hasItem() && event.getItem().getType() == Material.CHEST)
{
event.setCancelled(true);
_shop.attemptShopOpen(event.getPlayer());
}
}
public GadgetManager getGadgetManager()
{
return _gadgetManager;
}
public MountManager getMountManager()
{
return _mountManager;
}
public PetManager getPetManager()
{
return _petManager;
}
public InventoryManager getInventoryManager()
{
return _inventoryManager;
}
}

View File

@ -1,20 +1,21 @@
package mineplex.core.inventory.ui;
package mineplex.core.cosmetic.ui;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.CurrencyType;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.cosmetic.ui.page.PetTagPage;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.inventory.ui.page.Menu;
import mineplex.core.inventory.ui.page.PetTagPage;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
public class InventoryShop extends ShopBase<InventoryManager> implements PluginMessageListener
public class CosmeticShop extends ShopBase<CosmeticManager> implements PluginMessageListener
{
public InventoryShop(InventoryManager plugin, CoreClientManager clientManager, DonationManager donationManager, String name)
public CosmeticShop(CosmeticManager plugin, CoreClientManager clientManager, DonationManager donationManager, String name)
{
super(plugin, clientManager, donationManager, name, CurrencyType.Gems, CurrencyType.Coins);
@ -22,7 +23,7 @@ public class InventoryShop extends ShopBase<InventoryManager> implements PluginM
}
@Override
protected ShopPageBase<InventoryManager, ? extends ShopBase<InventoryManager>> BuildPagesFor(Player player)
protected ShopPageBase<CosmeticManager, ? extends ShopBase<CosmeticManager>> BuildPagesFor(Player player)
{
return new Menu(Plugin, this, ClientManager, DonationManager, player);
}

View File

@ -1,4 +1,4 @@
package mineplex.core.inventory.ui;
package mineplex.core.cosmetic.ui;
import java.util.Comparator;

View File

@ -1,9 +1,9 @@
package mineplex.core.inventory.ui.button;
package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;
import mineplex.core.cosmetic.ui.page.GadgetPage;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.inventory.ui.page.GadgetPage;
import mineplex.core.shop.item.IButton;
public class ActivateGadgetButton implements IButton
@ -16,7 +16,7 @@ public class ActivateGadgetButton implements IButton
_gadget = gadget;
_page = page;
}
@Override
public void ClickedLeft(Player player)
{
@ -26,6 +26,6 @@ public class ActivateGadgetButton implements IButton
@Override
public void ClickedRight(Player player)
{
_page.activateGadget(player, _gadget);
_page.handleRightClick(player, _gadget);
}
}

View File

@ -1,9 +1,9 @@
package mineplex.core.inventory.ui.button;
package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;
import mineplex.core.inventory.ui.page.Menu;
import mineplex.core.inventory.ui.page.MountPage;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.cosmetic.ui.page.MountPage;
import mineplex.core.mount.Mount;
import mineplex.core.shop.item.IButton;

View File

@ -1,8 +1,8 @@
package mineplex.core.inventory.ui.button;
package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;
import mineplex.core.inventory.ui.page.PetPage;
import mineplex.core.cosmetic.ui.page.PetPage;
import mineplex.core.pet.Pet;
import mineplex.core.shop.item.IButton;

View File

@ -1,4 +1,4 @@
package mineplex.core.inventory.ui.button;
package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;

View File

@ -0,0 +1,31 @@
package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;
import mineplex.core.cosmetic.ui.page.GadgetPage;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.shop.item.IButton;
public class DeactivateGadgetButton implements IButton
{
private Gadget _gadget;
private GadgetPage _page;
public DeactivateGadgetButton(Gadget gadget, GadgetPage page)
{
_gadget = gadget;
_page = page;
}
@Override
public void ClickedLeft(Player player)
{
_page.deactivateGadget(player, _gadget);
}
@Override
public void ClickedRight(Player player)
{
_page.handleRightClick(player, _gadget);
}
}

View File

@ -1,4 +1,4 @@
package mineplex.core.inventory.ui.button;
package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;

View File

@ -1,4 +1,4 @@
package mineplex.core.inventory.ui.button;
package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;

View File

@ -1,9 +1,9 @@
package mineplex.core.inventory.ui.button;
package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;
import mineplex.core.cosmetic.ui.page.GadgetPage;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.inventory.ui.page.GadgetPage;
import mineplex.core.shop.item.IButton;
public class GadgetButton implements IButton

View File

@ -1,9 +1,9 @@
package mineplex.core.inventory.ui.button;
package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;
import mineplex.core.shop.item.IButton;
import mineplex.core.inventory.ui.page.MountPage;
import mineplex.core.cosmetic.ui.page.MountPage;
import mineplex.core.mount.Mount;
public class MountButton implements IButton

View File

@ -1,6 +1,6 @@
package mineplex.core.inventory.ui.button;
package mineplex.core.cosmetic.ui.button;
import mineplex.core.inventory.ui.page.Menu;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.shop.item.IButton;
import org.bukkit.entity.Player;

View File

@ -1,6 +1,6 @@
package mineplex.core.inventory.ui.button;
package mineplex.core.cosmetic.ui.button;
import mineplex.core.inventory.ui.page.Menu;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.shop.item.IButton;
import org.bukkit.entity.Player;

View File

@ -1,6 +1,6 @@
package mineplex.core.inventory.ui.button;
package mineplex.core.cosmetic.ui.button;
import mineplex.core.inventory.ui.page.Menu;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.shop.item.IButton;
import org.bukkit.entity.Player;

View File

@ -1,6 +1,6 @@
package mineplex.core.inventory.ui.button;
package mineplex.core.cosmetic.ui.button;
import mineplex.core.inventory.ui.page.Menu;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.shop.item.IButton;
import org.bukkit.entity.Player;

View File

@ -1,6 +1,6 @@
package mineplex.core.inventory.ui.button;
package mineplex.core.cosmetic.ui.button;
import mineplex.core.inventory.ui.page.Menu;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.shop.item.IButton;
import org.bukkit.entity.Player;

View File

@ -1,9 +1,9 @@
package mineplex.core.inventory.ui.button;
package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;
import mineplex.core.pet.Pet;
import mineplex.core.inventory.ui.page.PetPage;
import mineplex.core.cosmetic.ui.page.PetPage;
import mineplex.core.shop.item.IButton;
public class PetButton implements IButton

View File

@ -1,8 +1,8 @@
package mineplex.core.inventory.ui.button;
package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;
import mineplex.core.inventory.ui.page.PetPage;
import mineplex.core.cosmetic.ui.page.PetPage;
import mineplex.core.shop.item.IButton;
public class RenamePetButton implements IButton

View File

@ -1,8 +1,8 @@
package mineplex.core.inventory.ui.button;
package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;
import mineplex.core.inventory.ui.page.PetTagPage;
import mineplex.core.cosmetic.ui.page.PetTagPage;
import mineplex.core.shop.item.IButton;
public class SelectTagButton implements IButton

View File

@ -1,4 +1,4 @@
package mineplex.core.inventory.ui.page;
package mineplex.core.cosmetic.ui.page;
import java.util.ArrayList;
import java.util.Arrays;
@ -10,23 +10,23 @@ import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.CurrencyType;
import mineplex.core.common.util.C;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.cosmetic.ui.button.ActivateGadgetButton;
import mineplex.core.cosmetic.ui.button.DeactivateGadgetButton;
import mineplex.core.cosmetic.ui.button.GadgetButton;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.inventory.ui.InventoryShop;
import mineplex.core.inventory.ui.button.ActivateGadgetButton;
import mineplex.core.inventory.ui.button.DeactivateGadgetButton;
import mineplex.core.inventory.ui.button.GadgetButton;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.item.SingleButton;
import mineplex.core.shop.page.ConfirmationPage;
import mineplex.core.shop.page.ShopPageBase;
public class GadgetPage extends ShopPageBase<InventoryManager, InventoryShop>
public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
{
public GadgetPage(InventoryManager plugin, InventoryShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
public GadgetPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
{
super(plugin, shop, clientManager, donationManager, name, player, 54);
@ -41,7 +41,7 @@ public class GadgetPage extends ShopPageBase<InventoryManager, InventoryShop>
{
addGadget(gadget, slot);
if (Plugin.getGadgetManager().getActive(Player, GadgetType.Item) == gadget)
if (Plugin.getInventoryManager().Get(Player).getItemCount(gadget.GetDisplayName()) > 0)
addGlow(slot);
slot++;
@ -64,25 +64,27 @@ public class GadgetPage extends ShopPageBase<InventoryManager, InventoryShop>
{
List<String> itemLore = new ArrayList<String>();
if (gadget.GetCost(CurrencyType.Coins) != -1)
if (gadget.GetCost(CurrencyType.Coins) >= 0)
{
itemLore.add(C.cYellow + gadget.GetCost(CurrencyType.Coins) + " Coins");
}
if (gadget instanceof ItemGadget)
else if (gadget.GetCost(CurrencyType.Coins) == -2)
{
ItemGadget itemGadget = (ItemGadget)gadget;
if (itemGadget.GetGemsPerUse() > 0)
{
itemLore.add(" ");
itemLore.add(C.cRed + C.Bold + "WARNING: ");
itemLore.add(C.cWhite + "Costs " + C.cGreen + itemGadget.GetGemsPerUse() + " Gems" + C.cWhite + " per Use");
}
itemLore.add(C.cGold + "Found in Treasure Chests.");
}
itemLore.add(C.cBlack);
itemLore.addAll(Arrays.asList(gadget.GetDescription()));
if (gadget instanceof ItemGadget)
{
itemLore.add(C.cBlack);
itemLore.add(C.cGreen + "Right-Click To Purchase:");
itemLore.add(C.cWhite + ((ItemGadget)gadget).getAmmo().GetDisplayName() + " for " + C.cYellow + ((ItemGadget)gadget).getAmmo().GetCost(CurrencyType.Coins) + " Coins");
itemLore.add(C.cBlack);
itemLore.add(C.cWhite + "Your Ammo : " + C.cGreen + Plugin.getInventoryManager().Get(Player).getItemCount(gadget.GetName()));
}
if (gadget.IsFree() || DonationManager.Get(Player.getName()).OwnsUnknownPackage(gadget.GetName()))
{
if (gadget.GetActive().contains(Player))
@ -105,27 +107,44 @@ public class GadgetPage extends ShopPageBase<InventoryManager, InventoryShop>
public void purchaseGadget(final Player player, final Gadget gadget)
{
Shop.OpenPageForPlayer(Player, new ConfirmationPage<InventoryManager, InventoryShop>(Plugin, Shop, ClientManager, DonationManager, new Runnable()
Shop.OpenPageForPlayer(Player, new ConfirmationPage<CosmeticManager, CosmeticShop>(Plugin, Shop, ClientManager, DonationManager, new Runnable()
{
public void run()
{
Plugin.addItemToInventory(Player, gadget.getGadgetType().name(), gadget.GetName(), 1);
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, player));
Plugin.getInventoryManager().addItemToInventory(Player, gadget.getGadgetType().name(), gadget.GetName(), (gadget instanceof ItemGadget ? ((ItemGadget)gadget).getAmmo().getQuantity() : gadget.getQuantity()));
}
}, null, gadget, CurrencyType.Coins, Player));
}, this, (gadget instanceof ItemGadget ? ((ItemGadget)gadget).getAmmo() : gadget), CurrencyType.Coins, Player));
}
public void activateGadget(Player player, Gadget gadget)
{
if (gadget instanceof ItemGadget)
{
if (Plugin.getInventoryManager().Get(player).getItemCount(gadget.GetName()) <= 0)
{
PlayDenySound(player);
return;
}
}
PlayAcceptSound(player);
gadget.Enable(player);
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, player));
}
public void handleRightClick(Player player, Gadget gadget)
{
if (gadget instanceof ItemGadget)
{
purchaseGadget(player, gadget);
}
}
public void deactivateGadget(Player player, Gadget gadget)
{
PlayAcceptSound(player);
gadget.Disable(player);
Refresh();
}
}

View File

@ -1,34 +1,35 @@
package mineplex.core.inventory.ui.page;
package mineplex.core.cosmetic.ui.page;
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.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.donation.DonationManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.inventory.GemBooster;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.inventory.ui.InventoryShop;
import mineplex.core.inventory.ui.button.DeactivateGadgetButton;
import mineplex.core.inventory.ui.button.DeactivateMountButton;
import mineplex.core.inventory.ui.button.DeactivatePetButton;
import mineplex.core.inventory.ui.button.OpenGadgets;
import mineplex.core.inventory.ui.button.OpenMorphs;
import mineplex.core.inventory.ui.button.OpenMounts;
import mineplex.core.inventory.ui.button.OpenParticles;
import mineplex.core.inventory.ui.button.OpenPets;
import mineplex.core.mount.Mount;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.item.SingleButton;
import mineplex.core.shop.page.ConfirmationPage;
import mineplex.core.shop.page.ShopPageBase;
public class Menu extends ShopPageBase<InventoryManager, InventoryShop>
public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
{
public Menu(InventoryManager plugin, InventoryShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player)
public Menu(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player)
{
super(plugin, shop, clientManager, donationManager, "Inventory", player);
@ -39,9 +40,9 @@ public class Menu extends ShopPageBase<InventoryManager, InventoryShop>
protected void BuildPage()
{
AddItem(11, new ShopItem(175, DonationManager.Get(Player.getName()).getCoins() + " Coins", 1, false));
AddItem(13, new ShopItem(Material.CHEST, Plugin.Get(Player).getItemCount("Treasure Chest") + " Chests", 1, false));
AddItem(13, new ShopItem(Material.CHEST, C.cGold + Plugin.getInventoryManager().Get(Player).getItemCount("Treasure Chest") + " Treasure Chests", 1, false));
final GemBooster gemBoosterItem = new GemBooster(Plugin.Get(Player).getItemCount("Gem Booster"));
final GemBooster gemBoosterItem = new GemBooster(Plugin.getInventoryManager().Get(Player).getItemCount("Gem Booster"));
if (DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Coins) >= gemBoosterItem.GetCost(CurrencyType.Coins))
{
@ -56,11 +57,11 @@ public class Menu extends ShopPageBase<InventoryManager, InventoryShop>
@Override
public void Clicked(Player player)
{
Shop.OpenPageForPlayer(Player, new ConfirmationPage<InventoryManager, InventoryShop>(Plugin, Shop, ClientManager, DonationManager, new Runnable()
Shop.OpenPageForPlayer(Player, new ConfirmationPage<CosmeticManager, CosmeticShop>(Plugin, Shop, ClientManager, DonationManager, new Runnable()
{
public void run()
{
Plugin.addItemToInventory(Player, "Utility", "Gem Booster", 20);
Plugin.getInventoryManager().addItemToInventory(Player, "Utility", "Gem Booster", 20);
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, Player));
}
}, null, gemBoosterItem, CurrencyType.Coins, Player));
@ -86,43 +87,89 @@ public class Menu extends ShopPageBase<InventoryManager, InventoryShop>
if (Plugin.getGadgetManager().getActive(Player, GadgetType.Particle) != null)
{
Gadget gadget = Plugin.getGadgetManager().getActive(Player, GadgetType.Particle);
final Gadget gadget = Plugin.getGadgetManager().getActive(Player, GadgetType.Particle);
AddButton(36,
new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), F.item(gadget.GetName()), new String[] {}, 1, false, false),
new DeactivateGadgetButton(gadget, this));
new SingleButton()
{
@Override
public void Clicked(Player player)
{
PlayAcceptSound(player);
gadget.Disable(player);
Refresh();
}
});
}
if (Plugin.getGadgetManager().getActive(Player, GadgetType.Item) != null)
{
Gadget gadget = Plugin.getGadgetManager().getActive(Player, GadgetType.Item);
final Gadget gadget = Plugin.getGadgetManager().getActive(Player, GadgetType.Item);
AddButton(38,
new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), F.item(gadget.GetName()), new String[] {}, 1, false, false),
new DeactivateGadgetButton(gadget, this));
new SingleButton()
{
@Override
public void Clicked(Player player)
{
PlayAcceptSound(player);
gadget.Disable(player);
Refresh();
}
});
}
if (Plugin.getPetManager().hasActivePet(Player.getName()))
{
AddButton(40, new ShopItem(Material.MONSTER_EGG, (byte)Plugin.getPetManager().getActivePet(Player.getName()).getType().getTypeId(), F.item(Plugin.getPetManager().getActivePet(Player.getName()).getCustomName()), new String[] {}, 1, false, false), new DeactivatePetButton(this, Plugin.getPetManager()));
AddButton(40, new ShopItem(Material.MONSTER_EGG, (byte)Plugin.getPetManager().getActivePet(Player.getName()).getType().getTypeId(), F.item(Plugin.getPetManager().getActivePet(Player.getName()).getCustomName()), new String[] {}, 1, false, false),
new SingleButton()
{
@Override
public void Clicked(Player player)
{
PlayAcceptSound(player);
Plugin.getPetManager().RemovePet(player, true);
Refresh();
}
});
}
if (Plugin.getMountManager().getActive(Player) != null)
{
Mount<?> mount = Plugin.getMountManager().getActive(Player);
final Mount<?> mount = Plugin.getMountManager().getActive(Player);
AddButton(42,
new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), F.item(mount.GetName()), new String[] {}, 1, false, false),
new DeactivateMountButton(mount, this));
new SingleButton()
{
@Override
public void Clicked(Player player)
{
PlayAcceptSound(player);
mount.Disable(player);
Refresh();
}
});
}
if (Plugin.getGadgetManager().getActive(Player, GadgetType.Morph) != null)
{
Gadget gadget = Plugin.getGadgetManager().getActive(Player, GadgetType.Morph);
final Gadget gadget = Plugin.getGadgetManager().getActive(Player, GadgetType.Morph);
AddButton(44,
new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), F.item(gadget.GetName()), new String[] {}, 1, false, false),
new DeactivateGadgetButton(gadget, this));
new SingleButton()
{
@Override
public void Clicked(Player player)
{
PlayAcceptSound(player);
gadget.Disable(player);
Refresh();
}
});
}
}

View File

@ -1,21 +1,22 @@
package mineplex.core.inventory.ui.page;
package mineplex.core.cosmetic.ui.page;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.inventory.ui.InventoryShop;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.item.SingleButton;
public class MorphPage extends GadgetPage
{
public MorphPage(InventoryManager plugin, InventoryShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
public MorphPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
{
super(plugin, shop, clientManager, donationManager, name, player);
}

View File

@ -1,4 +1,4 @@
package mineplex.core.inventory.ui.page;
package mineplex.core.cosmetic.ui.page;
import java.util.ArrayList;
import java.util.Arrays;
@ -10,21 +10,21 @@ import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.CurrencyType;
import mineplex.core.common.util.C;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.cosmetic.ui.button.ActivateMountButton;
import mineplex.core.cosmetic.ui.button.DeactivateMountButton;
import mineplex.core.cosmetic.ui.button.MountButton;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.inventory.ui.InventoryShop;
import mineplex.core.inventory.ui.button.ActivateMountButton;
import mineplex.core.inventory.ui.button.DeactivateMountButton;
import mineplex.core.inventory.ui.button.MountButton;
import mineplex.core.mount.Mount;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.item.SingleButton;
import mineplex.core.shop.page.ConfirmationPage;
import mineplex.core.shop.page.ShopPageBase;
public class MountPage extends ShopPageBase<InventoryManager, InventoryShop>
public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
{
public MountPage(InventoryManager plugin, InventoryShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
public MountPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
{
super(plugin, shop, clientManager, donationManager, name, player, 54);
@ -88,14 +88,13 @@ public class MountPage extends ShopPageBase<InventoryManager, InventoryShop>
public void purchaseMount(final Player player, final Mount<?> mount)
{
Shop.OpenPageForPlayer(Player, new ConfirmationPage<InventoryManager, InventoryShop>(Plugin, Shop, ClientManager, DonationManager, new Runnable()
Shop.OpenPageForPlayer(Player, new ConfirmationPage<CosmeticManager, CosmeticShop>(Plugin, Shop, ClientManager, DonationManager, new Runnable()
{
public void run()
{
Plugin.addItemToInventory(Player, "Mount", mount.GetName(), 1);
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, player));
Plugin.getInventoryManager().addItemToInventory(Player, "Mount", mount.GetName(), 1);
}
}, null, mount, CurrencyType.Coins, Player));
}, this, mount, CurrencyType.Coins, Player));
}
public void activateMount(Player player, Mount<?> _mount)

View File

@ -1,22 +1,23 @@
package mineplex.core.inventory.ui.page;
package mineplex.core.cosmetic.ui.page;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.inventory.ui.InventoryShop;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.item.SingleButton;
public class ParticlePage extends GadgetPage
{
public ParticlePage(InventoryManager plugin, InventoryShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
public ParticlePage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
{
super(plugin, shop, clientManager, donationManager, name, player);
}

View File

@ -1,4 +1,4 @@
package mineplex.core.inventory.ui.page;
package mineplex.core.cosmetic.ui.page;
import java.util.ArrayList;
import java.util.Collections;
@ -17,14 +17,15 @@ import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.CurrencyType;
import mineplex.core.common.util.C;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.cosmetic.ui.PetSorter;
import mineplex.core.cosmetic.ui.button.ActivatePetButton;
import mineplex.core.cosmetic.ui.button.DeactivatePetButton;
import mineplex.core.cosmetic.ui.button.PetButton;
import mineplex.core.cosmetic.ui.button.RenamePetButton;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.inventory.ui.InventoryShop;
import mineplex.core.inventory.ui.PetSorter;
import mineplex.core.inventory.ui.button.ActivatePetButton;
import mineplex.core.inventory.ui.button.DeactivatePetButton;
import mineplex.core.inventory.ui.button.PetButton;
import mineplex.core.inventory.ui.button.RenamePetButton;
import mineplex.core.pet.Pet;
import mineplex.core.pet.PetExtra;
import mineplex.core.shop.item.ShopItem;
@ -32,9 +33,9 @@ import mineplex.core.shop.item.SingleButton;
import mineplex.core.shop.page.AnvilContainer;
import mineplex.core.shop.page.ShopPageBase;
public class PetPage extends ShopPageBase<InventoryManager, InventoryShop>
public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
{
public PetPage(InventoryManager plugin, InventoryShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
public PetPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
{
super(plugin, shop, clientManager, donationManager, name, player, 54);

View File

@ -1,15 +1,16 @@
package mineplex.core.inventory.ui.page;
package mineplex.core.cosmetic.ui.page;
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.common.util.UtilPlayer;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.cosmetic.ui.button.CloseButton;
import mineplex.core.cosmetic.ui.button.SelectTagButton;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.inventory.ui.InventoryShop;
import mineplex.core.inventory.ui.button.CloseButton;
import mineplex.core.inventory.ui.button.SelectTagButton;
import mineplex.core.pet.Pet;
import mineplex.core.pet.PetExtra;
import mineplex.core.pet.repository.token.PetChangeToken;
@ -23,13 +24,13 @@ import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
public class PetTagPage extends ShopPageBase<InventoryManager, InventoryShop>
public class PetTagPage extends ShopPageBase<CosmeticManager, CosmeticShop>
{
private String _tagName = "Pet Tag";
private Pet _pet;
private boolean _petPurchase;
public PetTagPage(InventoryManager plugin, InventoryShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, Pet pet, boolean petPurchase)
public PetTagPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, Pet pet, boolean petPurchase)
{
super(plugin, shop, clientManager, donationManager, name, player, 3);
@ -73,7 +74,7 @@ public class PetTagPage extends ShopPageBase<InventoryManager, InventoryShop>
_pet.setDisplayName(C.cGreen + "Purchase " + _tagName);
Shop.OpenPageForPlayer(Player, new ConfirmationPage<InventoryManager, InventoryShop>(Plugin, Shop, ClientManager, DonationManager, new Runnable()
Shop.OpenPageForPlayer(Player, new ConfirmationPage<CosmeticManager, CosmeticShop>(Plugin, Shop, ClientManager, DonationManager, new Runnable()
{
public void run()
{
@ -98,7 +99,7 @@ public class PetTagPage extends ShopPageBase<InventoryManager, InventoryShop>
Plugin.getPetManager().Get(Player).GetPets().put(_pet.GetPetType(), token.PetName);
Plugin.addItemToInventory(Player, "Pet", _pet.GetPetType().toString(), 1);
Plugin.getInventoryManager().addItemToInventory(Player, "Pet", _pet.GetPetType().toString(), 1);
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, Player));
}
}, null, _petPurchase ? _pet : tag, CurrencyType.Coins, Player));

View File

@ -29,6 +29,7 @@ import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.gadget.types.MorphGadget.ArmorSlot;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.mount.MountManager;
import mineplex.core.pet.PetManager;
import mineplex.core.preferences.PreferencesManager;
@ -37,6 +38,7 @@ public class GadgetManager extends MiniPlugin
{
private CoreClientManager _clientManager;
private DonationManager _donationManager;
private InventoryManager _inventoryManager;
private PetManager _petManager;
private PreferencesManager _preferencesManager;
private DisguiseManager _disguiseManager;
@ -47,7 +49,7 @@ public class GadgetManager extends MiniPlugin
private NautHashMap<Player, Long> _lastMove = new NautHashMap<Player, Long>();
private NautHashMap<Player, NautHashMap<GadgetType, Gadget>> _playerActiveGadgetMap = new NautHashMap<Player, NautHashMap<GadgetType, Gadget>>();
public GadgetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager,
public GadgetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager,
MountManager mountManager, PetManager petManager, PreferencesManager preferencesManager,
DisguiseManager disguiseManager, BlockRestore blockRestore)
{
@ -55,6 +57,7 @@ public class GadgetManager extends MiniPlugin
_clientManager = clientManager;
_donationManager = donationManager;
_inventoryManager = inventoryManager;
_petManager = petManager;
_preferencesManager = preferencesManager;
_disguiseManager = disguiseManager;
@ -70,7 +73,8 @@ public class GadgetManager extends MiniPlugin
// Items
addGadget(new ItemPaintballGun(this));
addGadget(new ItemBatGun(this));
addGadget(new ItemGemBomb(this));
//addGadget(new ItemGemBomb(this));
addGadget(new ItemCoinBomb(this));
addGadget(new ItemFirework(this));
addGadget(new ItemTNT(this));
@ -217,6 +221,11 @@ public class GadgetManager extends MiniPlugin
{
return _disguiseManager;
}
public InventoryManager getInventoryManager()
{
return _inventoryManager;
}
public boolean collideEvent(Gadget gadget, Player other)
{

View File

@ -13,15 +13,8 @@ public class GadgetActivateEvent extends Event
private Player _player;
private Gadget _gadget;
private Mount _mount;
private boolean _cancelled = false;
public GadgetActivateEvent(Player player, Mount mount)
{
_player = player;
_mount = mount;
}
public GadgetActivateEvent(Player player, Gadget gadget)
{
@ -43,11 +36,6 @@ public class GadgetActivateEvent extends Event
{
return _gadget;
}
public Mount getMount()
{
return _mount;
}
public Player getPlayer()
{

View File

@ -0,0 +1,60 @@
package mineplex.core.gadget.event;
import mineplex.core.gadget.types.ItemGadget;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class ItemGadgetUseEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
private ItemGadget _gadget;
private int _count;
private boolean _cancelled = false;
public ItemGadgetUseEvent(Player player, ItemGadget gadget, int count)
{
_player = player;
_gadget = gadget;
_count = count;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public int getCount()
{
return _count;
}
public ItemGadget getGadget()
{
return _gadget;
}
public Player getPlayer()
{
return _player;
}
public void setCancelled(boolean cancel)
{
_cancelled = cancel;
}
public boolean isCancelled()
{
return _cancelled;
}
}

View File

@ -0,0 +1,24 @@
package mineplex.core.gadget.gadgets;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.common.CurrencyType;
import mineplex.core.shop.item.SalesPackageBase;
public class Ammo extends SalesPackageBase
{
public Ammo(String name, String displayName, Material material, byte displayData, String[] description, int coins, int quantity)
{
super(name, material, displayData, description, coins, quantity);
DisplayName = displayName;
KnownPackage = false;
OneTimePurchaseOnly = false;
}
@Override
public void Sold(Player player, CurrencyType currencyType)
{
}
}

View File

@ -42,7 +42,7 @@ public class ItemBatGun extends ItemGadget
},
-1,
Material.IRON_BARDING, (byte)0,
5000, 5);
5000, new Ammo("Bat Blaster", "50 Bats", Material.IRON_BARDING, (byte)0, new String[] { C.cWhite + "50 Bats for your Bat Blaster!" }, 500, 50));
}
@Override

View File

@ -0,0 +1,137 @@
package mineplex.core.gadget.gadgets;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class ItemCoinBomb extends ItemGadget
{
private HashMap<Item, Long> _active = new HashMap<Item, Long>();
private HashSet<Item> _coins = new HashSet<Item>();
public ItemCoinBomb(GadgetManager manager)
{
super(manager, "Coin Party Bomb", new String[]
{
C.cWhite + "It's party time! You will be",
C.cWhite + "everyones favourite player",
C.cWhite + "when you use one of these!",
},
-1,
Material.getMaterial(175), (byte)0,
30000, new Ammo("Coin Party Bomb", "1 Coin Party Bomb", Material.getMaterial(175), (byte)0, new String[] { C.cWhite + "1 Coin Party Bomb to PARTY!" }, 2000, 1));
}
@Override
public void ActivateCustom(Player player)
{
Item item = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), new ItemStack(Material.GOLD_BLOCK));
UtilAction.velocity(item, player.getLocation().getDirection(), 1, false, 0, 0.2, 1, false);
_active.put(item, System.currentTimeMillis());
//Inform
for (Player other : UtilServer.getPlayers())
UtilPlayer.message(other, C.cYellow + C.Bold + player.getName() + C.cWhite + C.Bold + " has thrown a " + C.cYellow + C.Bold + "Coin Party Bomb" + C.cWhite + C.Bold + "!");
}
@EventHandler
public void Update(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
Iterator<Item> itemIterator = _active.keySet().iterator();
while (itemIterator.hasNext())
{
Item item = itemIterator.next();
long time = _active.get(item);
if (UtilTime.elapsed(time, 3000))
{
UtilFirework.playFirework(item.getLocation(), FireworkEffect.builder().flicker(false).withColor(Color.YELLOW).with(Type.BURST).trail(false).build());
Item coin = item.getWorld().dropItem(item.getLocation().add(0, 1, 0), new ItemStack(Material.getMaterial(175)));
//Velocity
long passed = System.currentTimeMillis() - time;
Vector vel = new Vector(Math.sin(passed/300d), 0, Math.cos(passed/300d));
UtilAction.velocity(coin, vel, Math.abs(Math.sin(passed/3000d)), false, 0, 0.2 + Math.abs(Math.cos(passed/3000d))*0.8, 1, false);
coin.setPickupDelay(40);
_coins.add(coin);
}
if (UtilTime.elapsed(time, 23000))
{
item.remove();
itemIterator.remove();
}
}
}
@EventHandler
public void Pickup(PlayerPickupItemEvent event)
{
if (_active.keySet().contains(event.getItem()))
{
event.setCancelled(true);
}
else if (_coins.contains(event.getItem()))
{
event.setCancelled(true);
event.getItem().remove();
Manager.getDonationManager().RewardCoins(null, this.GetName() + " Pickup", event.getPlayer().getName(), 4);
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1f, 2f);
//UtilPlayer.message(event.getPlayer(), C.cGreen + C.Bold + "+4 Gems");
}
}
@EventHandler
public void Clean(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
Iterator<Item> coinIterator = _coins.iterator();
while (coinIterator.hasNext())
{
Item coin = coinIterator.next();
if (!coin.isValid() || coin.getTicksLived() > 1200)
{
coin.remove();
coinIterator.remove();
}
}
}
}

View File

@ -29,7 +29,7 @@ public class ItemFirework extends ItemGadget
},
-1,
Material.FIREWORK, (byte)0,
100, 15);
100, new Ammo("Fireworks", "50 Fireworks", Material.FIREWORK, (byte)0, new String[] { C.cWhite + "50 Fireworks for you to launch!" }, 500, 50));
}
@Override

View File

@ -16,6 +16,7 @@ import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.CurrencyType;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilFirework;
@ -42,7 +43,7 @@ public class ItemGemBomb extends ItemGadget
},
-1,
Material.EMERALD, (byte)0,
30000, 2000);
30000, new Ammo("Gem Party Bomb", "1 Gem Party Bomb", Material.EMERALD, (byte)0, new String[] { C.cWhite + "1 Gem Party Bomb to PARTY!" }, 2000, 1));
}
@Override

View File

@ -38,7 +38,7 @@ public class ItemPaintballGun extends ItemGadget
},
-1,
Material.GOLD_BARDING, (byte)0,
200, 2);
200, new Ammo("Paintball Gun", "100 Paintballs", Material.GOLD_BARDING, (byte)0, new String[] { C.cWhite + "100 Paintballs for you to shoot!" }, 500, 100));
}
@Override

View File

@ -29,7 +29,7 @@ public class ItemTNT extends ItemGadget
},
-1,
Material.TNT, (byte)0,
1000, 50);
1000, new Ammo("TNT", "20 TNT", Material.TNT, (byte)0, new String[] { C.cWhite + "20 TNT for you to explode!" }, 500, 20));
}
@Override

View File

@ -26,7 +26,12 @@ public abstract class Gadget extends SalesPackageBase implements Listener
public Gadget(GadgetManager manager, GadgetType gadgetType, String name, String[] desc, int cost, Material mat, byte data)
{
super(name, mat, data, desc, cost);
this(manager, gadgetType, name, desc, cost, mat, data, 1);
}
public Gadget(GadgetManager manager, GadgetType gadgetType, String name, String[] desc, int cost, Material mat, byte data, int quantity)
{
super(name, mat, data, desc, cost, quantity);
_gadgetType = gadgetType;
KnownPackage = false;

View File

@ -1,6 +1,9 @@
package mineplex.core.gadget.types;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@ -10,28 +13,29 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetActivateEvent;
import mineplex.core.gadget.gadgets.Ammo;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
public abstract class ItemGadget extends Gadget
{
{
private Ammo _ammo;
private long _recharge;
private int _gemsPerUse;
public ItemGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data,
long recharge, int gemsPerUse)
long recharge, Ammo ammo)
{
super(manager, GadgetType.Item, name, desc, cost, mat, data);
_ammo = ammo;
_recharge = recharge;
_gemsPerUse = gemsPerUse;
Free = true;
}
@ -63,6 +67,11 @@ public abstract class ItemGadget extends Gadget
_active.add(player);
List<String> itemLore = new ArrayList<String>();
itemLore.addAll(Arrays.asList(GetDescription()));
itemLore.add(C.cBlack);
itemLore.add(C.cWhite + "Your Ammo : " + Manager.getInventoryManager().Get(player).getItemCount(GetName()));
player.getInventory().setItem(3, ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(GetName())));
UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(GetName()) + "."));
@ -97,6 +106,11 @@ public abstract class ItemGadget extends Gadget
UtilPlayer.message(player, F.main("Gadget", "You unequipped " + F.elem(GetName()) + "."));
}
}
public Ammo getAmmo()
{
return _ammo;
}
public boolean IsItem(Player player)
{
@ -124,30 +138,19 @@ public abstract class ItemGadget extends Gadget
//Recharge
if (!Recharge.Instance.use(player, GetName(), _recharge, _recharge > 1000, false))
return;
//Use Gems
if (_gemsPerUse > 0)
return;
if (Manager.getInventoryManager().Get(player).getItemCount(GetName()) <= 0)
{
if (Manager.getDonationManager().Get(player.getName()).GetGems() >= _gemsPerUse)
{
Manager.getDonationManager().RewardGemsLater(GetName(), player.getName(), -_gemsPerUse);
}
else
{
UtilPlayer.message(player, F.main("Gadget", "You do not have enough Gems to use "+this.GetName()+"."));
Disable(player);
return;
}
UtilPlayer.message(player, F.main("Gadget", "You do not have any " + GetName() + " left."));
Disable(player);
return;
}
Manager.getInventoryManager().addItemToInventory(player, getGadgetType().name(), GetName(), -1);
ActivateCustom(event.getPlayer());
}
public abstract void ActivateCustom(Player player);
public int GetGemsPerUse()
{
return _gemsPerUse;
}
}

View File

@ -20,7 +20,7 @@ public class GemBooster extends SalesPackageBase
C.cWhite + "for all players in the game!",
" ",
C.cWhite + "Your Gem Boosters: " + C.cGreen + gemBoosters
}, 1000);
}, 1000, 20);
KnownPackage = false;
OneTimePurchaseOnly = false;

View File

@ -3,64 +3,29 @@ package mineplex.core.inventory;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.event.RetrieveClientInformationEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.inventory.data.Category;
import mineplex.core.inventory.data.InventoryRepository;
import mineplex.core.inventory.data.Item;
import mineplex.core.inventory.ui.InventoryShop;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.mount.MountManager;
import mineplex.core.pet.PetManager;
public class InventoryManager extends MiniClientPlugin<ClientInventory>
{
private static Object _inventoryLock = new Object();
private GadgetManager _gadgetManager;
private MountManager _mountManager;
private PetManager _petManager;
private InventoryShop _inventoryShop;
private InventoryRepository _repository;
private NautHashMap<String, Item> _items = new NautHashMap<String, Item>();
private NautHashMap<String, Category> _categories = new NautHashMap<String, Category>();
private boolean _userInterface = false;
public InventoryManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, GadgetManager gadgetManager, MountManager mountManager, PetManager petManager)
{
this(plugin, clientManager, donationManager, gadgetManager, mountManager, petManager, true);
}
public InventoryManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, GadgetManager gadgetManager, MountManager mountManager, PetManager petManager, boolean userInterface)
public InventoryManager(JavaPlugin plugin)
{
super("Inventory Manager", plugin);
_gadgetManager = gadgetManager;
_mountManager = mountManager;
_petManager = petManager;
_userInterface = userInterface;
_inventoryShop = new InventoryShop(this, clientManager, donationManager, "Inventory");
_repository = new InventoryRepository(plugin);
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(GetPlugin(), new Runnable()
@ -101,7 +66,7 @@ public class InventoryManager extends MiniClientPlugin<ClientInventory>
public void addItemToInventory(final Player player, final String category, final String item, final int count)
{
final String uuidString = player.getUniqueId().toString();
final String uuidString = player.getUniqueId().toString();
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
{
@ -112,6 +77,7 @@ public class InventoryManager extends MiniClientPlugin<ClientInventory>
if (!_categories.containsKey(category))
{
_repository.addCategory(category);
System.out.println("InventoryManager Adding Category : " + category);
}
}
@ -122,15 +88,17 @@ public class InventoryManager extends MiniClientPlugin<ClientInventory>
if (!_items.containsKey(item))
{
_repository.addItem(item, _categories.get(category).Id);
System.out.println("InventoryManager Adding Item : " + item);
}
}
updateItems();
Get(player).addItem(new ClientItem(_items.get(item), count));
synchronized (_inventoryLock)
{
_repository.incrementClientInventoryItem(uuidString, _items.get(item).Id, count);
Get(player).addItem(new ClientItem(_items.get(item), count));
_repository.incrementClientInventoryItem(uuidString, _items.get(item).Id, count);
}
}
});
@ -155,65 +123,4 @@ public class InventoryManager extends MiniClientPlugin<ClientInventory>
}
});
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
if (!_userInterface)
return;
event.getPlayer().getInventory().setItem(4, ItemStackFactory.Instance.CreateStack(Material.CHEST, (byte)0, 1, ChatColor.RESET + C.cGreen + "Inventory Menu"));
}
@EventHandler
public void orderThatChest(final PlayerDropItemEvent event)
{
if (!_userInterface)
return;
if (event.getItemDrop().getItemStack().getType() == Material.CHEST)
{
Bukkit.getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
{
public void run()
{
if (event.getPlayer().isOnline())
{
event.getPlayer().getInventory().remove(Material.CHEST);
event.getPlayer().getInventory().setItem(4, ItemStackFactory.Instance.CreateStack(Material.CHEST, (byte)0, 1, ChatColor.RESET + C.cGreen + "Inventory Menu"));
event.getPlayer().updateInventory();
}
}
});
}
}
@EventHandler
public void openShop(PlayerInteractEvent event)
{
if (!_userInterface)
return;
if (event.hasItem() && event.getItem().getType() == Material.CHEST)
{
event.setCancelled(true);
_inventoryShop.attemptShopOpen(event.getPlayer());
}
}
public GadgetManager getGadgetManager()
{
return _gadgetManager;
}
public MountManager getMountManager()
{
return _mountManager;
}
public PetManager getPetManager()
{
return _petManager;
}
}

View File

@ -1,36 +0,0 @@
package mineplex.core.inventory.ui.button;
import org.bukkit.entity.Player;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.inventory.ui.page.GadgetPage;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.page.ShopPageBase;
public class DeactivateGadgetButton implements IButton
{
private Gadget _gadget;
private ShopPageBase<?, ?> _page;
public DeactivateGadgetButton(Gadget gadget, ShopPageBase<?, ?> page)
{
_gadget = gadget;
_page = page;
}
@Override
public void ClickedLeft(Player player)
{
_page.PlayAcceptSound(player);
_gadget.Disable(player);
_page.Refresh();
}
@Override
public void ClickedRight(Player player)
{
_page.PlayAcceptSound(player);
_gadget.Disable(player);
_page.Refresh();
}
}

View File

@ -15,6 +15,7 @@ import mineplex.core.common.CurrencyType;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.gadget.event.GadgetActivateEvent;
import mineplex.core.mount.event.MountActivateEvent;
import mineplex.core.shop.item.SalesPackageBase;
public abstract class Mount<T> extends SalesPackageBase implements Listener
@ -39,7 +40,7 @@ public abstract class Mount<T> extends SalesPackageBase implements Listener
public final void Enable(Player player)
{
GadgetActivateEvent gadgetEvent = new GadgetActivateEvent(player, this);
MountActivateEvent gadgetEvent = new MountActivateEvent(player, this);
Bukkit.getServer().getPluginManager().callEvent(gadgetEvent);
if (gadgetEvent.isCancelled())

View File

@ -0,0 +1,54 @@
package mineplex.core.mount.event;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.mount.Mount;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class MountActivateEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
private Mount<?> _mount;
private boolean _cancelled = false;
public MountActivateEvent(Player player, Mount<?> mount)
{
_player = player;
_mount = mount;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public Mount getMount()
{
return _mount;
}
public Player getPlayer()
{
return _player;
}
public void setCancelled(boolean cancel)
{
_cancelled = cancel;
}
public boolean isCancelled()
{
return _cancelled;
}
}

View File

@ -15,9 +15,10 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack
private Material _displayMaterial;
private byte _displayData;
private String _name;
private String _displayName;
private String[] _description;
protected String Name;
protected String DisplayName;
protected String[] Description;
protected int Quantity;
protected int SalesPackageId;
protected boolean Free;
@ -32,20 +33,26 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack
public SalesPackageBase(String name, Material material, byte displayData, String[] description)
{
this(name, material, (byte)0, description, -1);
this(name, material, (byte)0, description, 0);
}
public SalesPackageBase(String name, Material material, byte displayData, String[] description, int coins)
{
this(name, material, (byte)0, description, 0, 1);
}
public SalesPackageBase(String name, Material material, byte displayData, String[] description, int coins, int quantity)
{
CurrencyCostMap = new NautHashMap<CurrencyType, Integer>();
_name = name;
_displayName = name;
_description = description;
Name = name;
DisplayName = name;
Description = description;
_displayMaterial = material;
_displayData = displayData;
CurrencyCostMap.put(CurrencyType.Coins, coins);
Quantity = quantity;
}
public abstract void Sold(Player player, CurrencyType currencyType);
@ -53,13 +60,13 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack
@Override
public String GetName()
{
return _name;
return Name;
}
@Override
public String[] GetDescription()
{
return _description;
return Description;
}
@Override
@ -103,6 +110,11 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack
CurrencyCostMap.put(CurrencyType.Gems, token.Gems);
}
}
public int getQuantity()
{
return Quantity;
}
public boolean IsKnown()
{
@ -116,11 +128,11 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack
public String GetDisplayName()
{
return _displayName;
return DisplayName;
}
public void setDisplayName(String name)
{
_displayName = name;
DisplayName = name;
}
}

View File

@ -54,6 +54,8 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.disguise.disguises.DisguiseSlime;
@ -145,8 +147,9 @@ public class HubManager extends MiniClientPlugin<HubClient>
_news = new NewsManager(this);
_mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore);
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _mountManager, petManager, preferences, disguiseManager, blockRestore);
_inventoryManager = new InventoryManager(plugin, clientManager, donationManager, _gadgetManager, _mountManager, petManager);
_inventoryManager = new InventoryManager(plugin);
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore);
new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager);
_partyManager = partyManager;
_preferences = preferences;

View File

@ -9,15 +9,11 @@ import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEntityEvent;
@ -32,8 +28,6 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
@ -42,6 +36,7 @@ import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.event.GadgetActivateEvent;
import mineplex.core.gadget.event.GadgetBlockEvent;
import mineplex.core.mount.event.MountActivateEvent;
import mineplex.core.recharge.Recharge;
import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType;
@ -130,6 +125,13 @@ public class ParkourManager extends MiniPlugin
event.setCancelled(true);
}
@EventHandler
public void disableMounts(MountActivateEvent event)
{
if (isParkourMode(event.getPlayer()))
event.setCancelled(true);
}
@EventHandler
public void playerEnterParkour(UpdateEvent event)
{

View File

@ -16,6 +16,7 @@ import mineplex.core.blood.Blood;
import mineplex.core.command.CommandCenter;
import mineplex.core.common.util.FileUtil;
import mineplex.core.common.util.UtilServer;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.creature.Creature;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager;
@ -105,7 +106,9 @@ public class Arcade extends JavaPlugin
PetManager petManager = new PetManager(this, _clientManager, _donationManager, creature, webServerAddress);
MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore);
InventoryManager inventoryManager = new InventoryManager(this, _clientManager, _donationManager, new GadgetManager(this, _clientManager, _donationManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore), mountManager, petManager);
InventoryManager inventoryManager = new InventoryManager(this);
GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore);
new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager);
//Arcade Manager
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, packetHandler, preferenceManager, inventoryManager, webServerAddress);