diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/DullEnchantment.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/DullEnchantment.java new file mode 100644 index 000000000..c77e32753 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/DullEnchantment.java @@ -0,0 +1,50 @@ +package mineplex.core.common.util; + +import org.bukkit.enchantments.Enchantment; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.enchantments.EnchantmentWrapper; +import org.bukkit.inventory.ItemStack; + +public class DullEnchantment extends EnchantmentWrapper +{ + public DullEnchantment() + { + super(120); + } + + @Override + public boolean canEnchantItem(ItemStack item) + { + return true; + } + + @Override + public boolean conflictsWith(Enchantment other) + { + return false; + } + + @Override + public EnchantmentTarget getItemTarget() + { + return null; + } + + @Override + public int getMaxLevel() + { + return 10; + } + + @Override + public String getName() + { + return "Glow"; + } + + @Override + public int getStartLevel() + { + return 1; + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilInv.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilInv.java index 7285d4f34..bc55eebec 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilInv.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilInv.java @@ -1,8 +1,11 @@ package mineplex.core.common.util; +import java.lang.reflect.Field; import java.util.HashSet; import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.enchantments.EnchantmentWrapper; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryAction; @@ -13,6 +16,31 @@ import org.bukkit.inventory.PlayerInventory; public class UtilInv { + private static Field _enchantmentNew; + private static DullEnchantment _enchantment; + + static + { + try + { + _enchantmentNew = Enchantment.class.getDeclaredField("acceptingNew"); + _enchantmentNew.setAccessible(true); + _enchantmentNew.set(null, true); + + _enchantment = new DullEnchantment(); + EnchantmentWrapper.registerEnchantment(_enchantment); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public static void addDullEnchantment(ItemStack itemStack) + { + itemStack.addEnchantment(_enchantment, 1); + } + @SuppressWarnings("deprecation") public static boolean insert(Player player, ItemStack stack) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index 7d933b10a..98fea4f14 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -149,41 +149,36 @@ public class CoreClientManager extends MiniPlugin } } - private void LoadClient(CoreClient client, UUID uuid, String ipAddress) + private void LoadClient(final CoreClient client, final UUID uuid, String ipAddress) { TimingManager.start(client.GetPlayerName() + " LoadClient Total."); - - // Prep for mysql - + ClientToken token = null; Gson gson = new Gson(); - + + final RetrieveClientInformationEvent clientInformationEvent = new RetrieveClientInformationEvent(client.GetPlayerName(), uuid); + + Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable() + { + public void run() + { + _mysqlRepository.login(uuid.toString(), client.GetPlayerName()); + + Bukkit.getServer().getPluginManager().callEvent(clientInformationEvent); + } + }); + String response = _repository.GetClient(client.GetPlayerName(), uuid, ipAddress); token = gson.fromJson(response, ClientToken.class); client.SetAccountId(token.AccountId); client.SetRank(Rank.valueOf(token.Rank)); - - _mysqlRepository.login(uuid.toString(), client.GetPlayerName()); // JSON sql response Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response)); // Load client in miniplugins Bukkit.getServer().getPluginManager().callEvent(new AsyncClientLoadEvent(token, client)); - - RetrieveClientInformationEvent clientInformationEvent = new RetrieveClientInformationEvent(client.GetPlayerName(), uuid); - - try - { - // Mysql - Bukkit.getServer().getPluginManager().callEvent(clientInformationEvent); - } - catch (Exception exception) - { - Logger.Instance.log(exception); - System.out.println("Error running RetrieveClientInformationEvent" + exception.getMessage()); - } while (clientInformationEvent.processing()) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/Row.java b/Plugins/Mineplex.Core/src/mineplex/core/database/Row.java similarity index 86% rename from Plugins/Mineplex.Core/src/mineplex/core/stats/Row.java rename to Plugins/Mineplex.Core/src/mineplex/core/database/Row.java index 083f43413..208666a37 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/Row.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/database/Row.java @@ -1,4 +1,4 @@ -package mineplex.core.stats; +package mineplex.core.database; import mineplex.core.common.util.NautHashMap; import mineplex.core.database.column.Column; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/Table.java b/Plugins/Mineplex.Core/src/mineplex/core/database/Table.java index af2261434..57c362892 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/Table.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/database/Table.java @@ -12,7 +12,6 @@ import java.util.List; import mineplex.core.common.util.NautHashMap; import mineplex.core.database.column.Column; -import mineplex.core.stats.Row; public class Table { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index 3af28f13f..6609b2ed1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -73,7 +73,7 @@ public class DonationManager extends MiniPlugin } } - public void PurchaseUnknownSalesPackage(final Callback callback, final String name, final String packageName, final int gemCost, boolean oneTimePurchase) + public void PurchaseUnknownSalesPackage(final Callback callback, final String name, final String packageName, final boolean coinPurchase, final int cost, boolean oneTimePurchase) { Donor donor = Get(name); @@ -99,14 +99,14 @@ public class DonationManager extends MiniPlugin if (donor != null) { donor.AddUnknownSalesPackagesOwned(packageName); - donor.DeductCost(gemCost, CurrencyType.Gems); + donor.DeductCost(cost, coinPurchase ? CurrencyType.Coins : CurrencyType.Gems); } } if (callback != null) callback.run(response); } - }, name, packageName, gemCost); + }, name, packageName, coinPurchase, cost); } public void PurchaseKnownSalesPackage(final Callback callback, final String name, final int salesPackageId) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java index 40418b269..915d144e3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java @@ -9,6 +9,7 @@ import mineplex.core.donation.repository.token.DonorToken; public class Donor { private int _gems; + private int _coins; private boolean _donated; private List _salesPackagesOwned; private List _unknownSalesPackagesOwned; @@ -18,6 +19,7 @@ public class Donor public Donor(DonorToken token) { _gems = token.Gems; + _coins = token.Coins; _donated = token.Donated; _salesPackagesOwned = token.SalesPackages; @@ -72,6 +74,10 @@ public class Donor _gems -= cost; _update = true; break; + case Coins: + _coins -= cost; + _update = true; + break; default: break; } @@ -83,6 +89,8 @@ public class Donor { case Gems: return _gems; + case Coins: + return _coins; case Tokens: return 0; default: @@ -120,4 +128,9 @@ public class Donor return false; } + + public int getCoins() + { + return _coins; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java index c5e8b6b13..413e7b041 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java @@ -26,12 +26,13 @@ public class DonationRepository new AsyncJsonWebCall(_webAddress + "PlayerAccount/PurchaseKnownSalesPackage").Execute(TransactionResponse.class, callback, token); } - public void PurchaseUnknownSalesPackage(Callback callback, String name, String packageName, int gemCost) + public void PurchaseUnknownSalesPackage(Callback callback, String name, String packageName, boolean coinPurchase, int cost) { UnknownPurchaseToken token = new UnknownPurchaseToken(); token.AccountName = name; token.SalesPackageName = packageName; - token.Cost = gemCost; + token.CoinPurchase = coinPurchase; + token.Cost = cost; token.Premium = false; new AsyncJsonWebCall(_webAddress + "PlayerAccount/PurchaseUnknownSalesPackage").Execute(TransactionResponse.class, callback, token); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/token/DonorToken.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/token/DonorToken.java index bf533f531..15888736a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/token/DonorToken.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/token/DonorToken.java @@ -8,4 +8,5 @@ public class DonorToken public boolean Donated; public List SalesPackages; public List UnknownSalesPackages; + public int Coins; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/token/UnknownPurchaseToken.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/token/UnknownPurchaseToken.java index b38753f79..7aed7045e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/token/UnknownPurchaseToken.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/token/UnknownPurchaseToken.java @@ -6,4 +6,5 @@ public class UnknownPurchaseToken public String SalesPackageName; public int Cost; public boolean Premium; + public boolean CoinPurchase; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java new file mode 100644 index 000000000..dc0b02f80 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -0,0 +1,195 @@ +package mineplex.core.gadget; + +import java.util.HashSet; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.Rank; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.event.GadgetCollideEntityEvent; +import mineplex.core.gadget.gadgets.*; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.gadget.types.ItemGadget; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.gadget.types.MorphGadget.ArmorSlot; +import mineplex.core.mount.MountManager; +import mineplex.core.pet.PetManager; +import mineplex.core.preferences.PreferencesManager; + +public class GadgetManager extends MiniPlugin +{ + private CoreClientManager _clientManager; + private DonationManager _donationManager; + private PetManager _petManager; + private PreferencesManager _preferencesManager; + private DisguiseManager _disguiseManager; + private BlockRestore _blockRestore; + + private HashSet _gadgets; + + private NautHashMap> _playerActiveGadgetMap = new NautHashMap>(); + + public GadgetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, MountManager mountManager, PetManager petManager, PreferencesManager preferencesManager, DisguiseManager disguiseManager, BlockRestore blockRestore) + { + super("Gadget Manager", plugin); + + _clientManager = clientManager; + _donationManager = donationManager; + _petManager = petManager; + _preferencesManager = preferencesManager; + _disguiseManager = disguiseManager; + _blockRestore = blockRestore; + + CreateGadgets(); + } + + private void CreateGadgets() + { + _gadgets = new HashSet(); + + //Items + _gadgets.add(new ItemPaintballGun(this)); + _gadgets.add(new ItemBatGun(this)); + _gadgets.add(new ItemGemBomb(this)); + _gadgets.add(new ItemFirework(this)); + _gadgets.add(new ItemTNT(this)); + + //Morphs + _gadgets.add(new MorphBlaze(this)); + _gadgets.add(new MorphPumpkinKing(this)); + } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) + { + if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.MODERATOR)) + { + for (Gadget gadget : _gadgets) + { + _donationManager.Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(gadget.GetName()); + } + } + } + + public HashSet getGadgets() + { + return _gadgets; + } + + //Disallows two armor gadgets in same slot. + public void RemoveArmor(Player player, ArmorSlot slot) + { + for (Gadget gadget : _gadgets) + { + if (gadget instanceof MorphGadget) + { + MorphGadget armor = (MorphGadget)gadget; + + if (armor.GetSlot() == slot) + { + armor.RemoveArmor(player); + } + } + } + } + + public void RemoveItem(Player player) + { + for (Gadget gadget : _gadgets) + { + if (gadget instanceof ItemGadget) + { + ItemGadget item = (ItemGadget)gadget; + + item.RemoveItem(player); + } + } + } + + public void DisableAll() + { + for (Gadget gadget : _gadgets) + for (Player player : UtilServer.getPlayers()) + gadget.Disable(player); + } + + public PetManager getPetManager() + { + return _petManager; + } + + public List getParticles() + { + return null; + } + + public CoreClientManager getClientManager() + { + return _clientManager; + } + + public DonationManager getDonationManager() + { + return _donationManager; + } + + public PreferencesManager getPreferencesManager() + { + return _preferencesManager; + } + + public DisguiseManager getDisguiseManager() + { + return _disguiseManager; + } + + public boolean collideEvent(Gadget gadget, Player other) + { + GadgetCollideEntityEvent collideEvent = new GadgetCollideEntityEvent(gadget, other); + + Bukkit.getServer().getPluginManager().callEvent(collideEvent); + + return collideEvent.isCancelled(); + } + + public BlockRestore getBlockRestore() + { + return _blockRestore; + } + + public void setActive(Player player, Gadget gadget) + { + if (!_playerActiveGadgetMap.containsKey(player)) + _playerActiveGadgetMap.put(player, new NautHashMap()); + + _playerActiveGadgetMap.get(player).put(gadget.getGadgetType(), gadget); + } + + public Gadget getActive(Player player, GadgetType gadgetType) + { + if (!_playerActiveGadgetMap.containsKey(player)) + _playerActiveGadgetMap.put(player, new NautHashMap()); + + return _playerActiveGadgetMap.get(player).get(gadgetType); + } + + public void removeActive(Player player, Gadget gadget) + { + if (!_playerActiveGadgetMap.containsKey(player)) + _playerActiveGadgetMap.put(player, new NautHashMap()); + + _playerActiveGadgetMap.get(player).remove(gadget.getGadgetType()); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetActivateEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetActivateEvent.java new file mode 100644 index 000000000..f0ab6a766 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetActivateEvent.java @@ -0,0 +1,53 @@ +package mineplex.core.gadget.event; + +import mineplex.core.gadget.types.Gadget; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class GadgetActivateEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private Player _player; + private Gadget _gadget; + + private boolean _cancelled = false; + + public GadgetActivateEvent(Player player, Gadget gadget) + { + _player = player; + _gadget = gadget; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public Gadget getGadget() + { + return _gadget; + } + + public Player getPlayer() + { + return _player; + } + + public void setCancelled(boolean cancel) + { + _cancelled = cancel; + } + + public boolean isCancelled() + { + return _cancelled; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetBlockEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetBlockEvent.java new file mode 100644 index 000000000..e42fbd699 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetBlockEvent.java @@ -0,0 +1,55 @@ +package mineplex.core.gadget.event; + +import java.util.List; + +import mineplex.core.gadget.types.Gadget; + +import org.bukkit.block.Block; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class GadgetBlockEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private Gadget _gadget; + private List _blocks; + + private boolean _cancelled = false; + + public GadgetBlockEvent(Gadget gadget, List blocks) + { + _gadget = gadget; + _blocks = blocks; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public Gadget getGadget() + { + return _gadget; + } + + public List getBlocks() + { + return _blocks; + } + + public void setCancelled(boolean cancel) + { + _cancelled = cancel; + } + + public boolean isCancelled() + { + return _cancelled; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetCollideEntityEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetCollideEntityEvent.java new file mode 100644 index 000000000..a30648983 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetCollideEntityEvent.java @@ -0,0 +1,53 @@ +package mineplex.core.gadget.event; + +import mineplex.core.gadget.types.Gadget; + +import org.bukkit.entity.Entity; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class GadgetCollideEntityEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private Gadget _gadget; + private Entity _other; + + private boolean _cancelled = false; + + public GadgetCollideEntityEvent(Gadget gadget, Entity other) + { + _gadget = gadget; + _other = other; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public Gadget getGadget() + { + return _gadget; + } + + public Entity getOther() + { + return _other; + } + + public void setCancelled(boolean cancel) + { + _cancelled = cancel; + } + + public boolean isCancelled() + { + return _cancelled; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/ItemBatGun.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemBatGun.java similarity index 89% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/ItemBatGun.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemBatGun.java index a10fdecd8..99601e0ce 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/ItemBatGun.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemBatGun.java @@ -1,4 +1,4 @@ -package mineplex.hub.gadget.gadgets; +package mineplex.core.gadget.gadgets; import java.util.ArrayList; import java.util.HashMap; @@ -21,11 +21,11 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ItemGadget; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.hub.gadget.GadgetManager; -import mineplex.hub.gadget.types.ItemGadget; public class ItemBatGun extends ItemGadget { @@ -42,19 +42,13 @@ public class ItemBatGun extends ItemGadget }, -1, Material.IRON_BARDING, (byte)0, - 5000, 5, false); + 5000, 5); } - + @Override - public void EnableCustom(Player player) + public void DisableCustom(Player player) { - this.ApplyItem(player); - } - - @Override - public void Disable(Player player) - { - this.RemoveItem(player); + super.DisableCustom(player); Clear(player); } @@ -107,7 +101,7 @@ public class ItemBatGun extends ItemGadget if (other.equals(cur)) continue; - if (!Manager.Manager.CanBump(other)) + if (!Manager.getPreferencesManager().Get(other).HubGames || !Manager.getPreferencesManager().Get(other).ShowPlayers) continue; if (!Recharge.Instance.usable(other, "Hit by Bat")) @@ -115,6 +109,9 @@ public class ItemBatGun extends ItemGadget if (UtilEnt.hitBox(bat.getLocation(), other, 2, null)) { + if (Manager.collideEvent(this, other)) + continue; + //Damage Event UtilAction.velocity(other, UtilAlg.getTrajectory(cur, other), 0.4, false, 0, 0.2, 10, true); @@ -126,9 +123,6 @@ public class ItemBatGun extends ItemGadget //Recharge on hit Recharge.Instance.useForce(other, "Hit by Bat", 200); - - //No Portal - Manager.Manager.SetPortalDelay(other); } } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/ItemFirework.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemFirework.java similarity index 86% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/ItemFirework.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemFirework.java index 203432bad..16f9f1262 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/ItemFirework.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemFirework.java @@ -1,4 +1,4 @@ -package mineplex.hub.gadget.gadgets; +package mineplex.core.gadget.gadgets; import org.bukkit.Color; import org.bukkit.FireworkEffect; @@ -14,8 +14,8 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilPlayer; -import mineplex.hub.gadget.GadgetManager; -import mineplex.hub.gadget.types.ItemGadget; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ItemGadget; public class ItemFirework extends ItemGadget { @@ -29,19 +29,7 @@ public class ItemFirework extends ItemGadget }, -1, Material.FIREWORK, (byte)0, - 100, 15, false); - } - - @Override - public void EnableCustom(Player player) - { - this.ApplyItem(player); - } - - @Override - public void Disable(Player player) - { - this.RemoveItem(player); + 100, 15); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/ItemGemBomb.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemGemBomb.java similarity index 89% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/ItemGemBomb.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemGemBomb.java index b9bee2699..b9e47c42a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/ItemGemBomb.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemGemBomb.java @@ -1,4 +1,4 @@ -package mineplex.hub.gadget.gadgets; +package mineplex.core.gadget.gadgets; import java.util.HashMap; import java.util.HashSet; @@ -22,10 +22,10 @@ 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; -import mineplex.hub.gadget.GadgetManager; -import mineplex.hub.gadget.types.ItemGadget; public class ItemGemBomb extends ItemGadget { @@ -42,19 +42,7 @@ public class ItemGemBomb extends ItemGadget }, -1, Material.EMERALD, (byte)0, - 30000, 2000, false); - } - - @Override - public void EnableCustom(Player player) - { - this.ApplyItem(player); - } - - @Override - public void Disable(Player player) - { - this.RemoveItem(player); + 30000, 2000); } @Override @@ -119,7 +107,7 @@ public class ItemGemBomb extends ItemGadget event.setCancelled(true); event.getItem().remove(); - Manager.Manager.GetDonation().RewardGems(null, this.GetName() + " Pickup", event.getPlayer().getName(), 4); + Manager.getDonationManager().RewardGems(null, this.GetName() + " Pickup", event.getPlayer().getName(), 4); event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1f, 2f); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/ItemPaintballGun.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintballGun.java similarity index 80% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/ItemPaintballGun.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintballGun.java index 2db9c5b74..25608e748 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/ItemPaintballGun.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintballGun.java @@ -1,7 +1,9 @@ -package mineplex.hub.gadget.gadgets; +package mineplex.core.gadget.gadgets; +import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import org.bukkit.Effect; import org.bukkit.Location; @@ -18,11 +20,11 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilBlock; -import mineplex.core.recharge.Recharge; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetBlockEvent; +import mineplex.core.gadget.types.ItemGadget; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.hub.gadget.GadgetManager; -import mineplex.hub.gadget.types.ItemGadget; public class ItemPaintballGun extends ItemGadget { @@ -36,19 +38,7 @@ public class ItemPaintballGun extends ItemGadget }, -1, Material.GOLD_BARDING, (byte)0, - 200, 2, false); - } - - @Override - public void EnableCustom(Player player) - { - this.ApplyItem(player); - } - - @Override - public void Disable(Player player) - { - this.RemoveItem(player); + 200, 2); } @Override @@ -65,9 +55,6 @@ public class ItemPaintballGun extends ItemGadget @EventHandler public void Paint(ProjectileHitEvent event) { - if (Manager.Manager.GetParkour().InParkour(event.getEntity())) - return; - if (!_balls.remove(event.getEntity())) return; @@ -90,15 +77,23 @@ public class ItemPaintballGun extends ItemGadget return; } - for (Block block : UtilBlock.getInRadius(loc, 1.5d).keySet()) + List blocks = new ArrayList(); + blocks.addAll(UtilBlock.getInRadius(loc, 1.5d).keySet()); + + GadgetBlockEvent gadgetEvent = new GadgetBlockEvent(this, blocks); + + if (gadgetEvent.isCancelled()) + return; + + for (Block block : gadgetEvent.getBlocks()) { if (!UtilBlock.solid(block)) continue; if (block.getType() == Material.CARPET) - Manager.Manager.GetBlockRestore().Add(block, 171, color, 4000); + Manager.getBlockRestore().Add(block, 171, color, 4000); else - Manager.Manager.GetBlockRestore().Add(block, 35, color, 4000); + Manager.getBlockRestore().Add(block, 35, color, 4000); } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/ItemTNT.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemTNT.java similarity index 81% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/ItemTNT.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemTNT.java index 84cc8add1..7e5fd579b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/ItemTNT.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemTNT.java @@ -1,29 +1,20 @@ -package mineplex.hub.gadget.gadgets; +package mineplex.core.gadget.gadgets; import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityExplodeEvent; -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.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.hub.gadget.GadgetManager; -import mineplex.hub.gadget.types.ItemGadget; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ItemGadget; public class ItemTNT extends ItemGadget { @@ -38,19 +29,7 @@ public class ItemTNT extends ItemGadget }, -1, Material.TNT, (byte)0, - 1000, 50, false); - } - - @Override - public void EnableCustom(Player player) - { - this.ApplyItem(player); - } - - @Override - public void Disable(Player player) - { - this.RemoveItem(player); + 1000, 50); } @Override @@ -72,7 +51,7 @@ public class ItemTNT extends ItemGadget HashMap players = UtilPlayer.getInRadius(event.getLocation(), 10); for (Player player : players.keySet()) { - if (!Manager.Manager.CanBump(player)) + if (!Manager.collideEvent(this, player)) continue; double mult = players.get(player); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/MorphBlaze.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlaze.java similarity index 75% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/MorphBlaze.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlaze.java index 7b6e4127a..dae404824 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/MorphBlaze.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlaze.java @@ -1,6 +1,5 @@ -package mineplex.hub.gadget.gadgets; +package mineplex.core.gadget.gadgets; -import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -12,11 +11,10 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.disguise.disguises.DisguiseBlaze; -import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.MorphGadget; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.hub.gadget.GadgetManager; -import mineplex.hub.gadget.types.MorphGadget; public class MorphBlaze extends MorphGadget { @@ -42,14 +40,14 @@ public class MorphBlaze extends MorphGadget DisguiseBlaze disguise = new DisguiseBlaze(player); disguise.SetName(player.getName()); disguise.SetCustomNameVisible(true); - Manager.Manager.GetDisguise().disguise(disguise); + Manager.getDisguiseManager().disguise(disguise); } @Override - public void Disable(Player player) + public void DisableCustom(Player player) { this.RemoveArmor(player); - Manager.Manager.GetDisguise().undisguise(player); + Manager.getDisguiseManager().undisguise(player); } @EventHandler @@ -74,9 +72,9 @@ public class MorphBlaze extends MorphGadget @EventHandler public void HeroOwner(PlayerJoinEvent event) { - if (Manager.Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.HERO)) + if (Manager.getClientManager().Get(event.getPlayer()).GetRank().Has(Rank.HERO)) { - Manager.Manager.GetDonation().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName()); + Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName()); } } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/MorphPumpkinKing.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPumpkinKing.java similarity index 75% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/MorphPumpkinKing.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPumpkinKing.java index b10492439..ed4dae2ef 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/MorphPumpkinKing.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPumpkinKing.java @@ -1,5 +1,6 @@ -package mineplex.hub.gadget.gadgets; +package mineplex.core.gadget.gadgets; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton.SkeletonType; @@ -7,8 +8,8 @@ import org.bukkit.entity.Skeleton.SkeletonType; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.disguises.DisguiseSkeleton; -import mineplex.hub.gadget.GadgetManager; -import mineplex.hub.gadget.types.MorphGadget; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.MorphGadget; public class MorphPumpkinKing extends MorphGadget { @@ -37,9 +38,9 @@ public class MorphPumpkinKing extends MorphGadget disguise.SetName(player.getName()); disguise.SetCustomNameVisible(true); disguise.SetSkeletonType(SkeletonType.WITHER); - Manager.Manager.GetDisguise().disguise(disguise); + Manager.getDisguiseManager().disguise(disguise); - Manager.Manager.GetPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.Manager.GetPlugin(), new Runnable() + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable() { public void run() { @@ -53,10 +54,10 @@ public class MorphPumpkinKing extends MorphGadget } @Override - public void Disable(Player player) + public void DisableCustom(Player player) { this.RemoveArmor(player); - Manager.Manager.GetDisguise().undisguise(player); + Manager.getDisguiseManager().undisguise(player); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/MorphSnowman.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphSnowman.java similarity index 53% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/MorphSnowman.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphSnowman.java index fc1915dac..1228b5d67 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/MorphSnowman.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphSnowman.java @@ -1,12 +1,12 @@ -package mineplex.hub.gadget.gadgets; +package mineplex.core.gadget.gadgets; import org.bukkit.Material; import org.bukkit.entity.Player; import mineplex.core.common.util.C; import mineplex.core.disguise.disguises.DisguiseSnowman; -import mineplex.hub.gadget.GadgetManager; -import mineplex.hub.gadget.types.MorphGadget; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.MorphGadget; public class MorphSnowman extends MorphGadget { @@ -33,32 +33,13 @@ public class MorphSnowman extends MorphGadget DisguiseSnowman disguise = new DisguiseSnowman(player); disguise.SetName(player.getName()); disguise.SetCustomNameVisible(true); - Manager.Manager.GetDisguise().disguise(disguise); + Manager.getDisguiseManager().disguise(disguise); } @Override - public void Disable(Player player) + public void DisableCustom(Player player) { this.RemoveArmor(player); - Manager.Manager.GetDisguise().undisguise(player); + Manager.getDisguiseManager().undisguise(player); } - /* - @EventHandler - public void SnowForm(EntityChangeBlockEvent event) - { - System.out.println("Snowman Helmet - Entity Block Change: " + event.getTo()); - - if (event.getTo() == Material.SNOW) - event.setCancelled(true); - } - - @EventHandler - public void SnowForm(EntityBlockFormEvent event) - { - System.out.println("Snowman Helmet - Entity Block Form: " + event.getNewState().getType()); - - if (event.getNewState().getType() == Material.SNOW) - event.setCancelled(true); - } - */ } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/Gadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java similarity index 65% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/Gadget.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java index bc6fdcf32..302f21b23 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/Gadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java @@ -1,12 +1,10 @@ -package mineplex.hub.gadget.types; +package mineplex.core.gadget.types; import java.util.HashSet; import mineplex.core.common.CurrencyType; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; +import mineplex.core.gadget.GadgetManager; import mineplex.core.shop.item.SalesPackageBase; -import mineplex.hub.gadget.GadgetManager; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -18,12 +16,15 @@ public abstract class Gadget extends SalesPackageBase implements Listener { public GadgetManager Manager; + private GadgetType _gadgetType; + protected HashSet _active = new HashSet(); - public Gadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data) + public Gadget(GadgetManager manager, GadgetType gadgetType, String name, String[] desc, int cost, Material mat, byte data) { super(name, mat, data, desc, cost); + _gadgetType = gadgetType; KnownPackage = false; Manager = manager; @@ -31,6 +32,11 @@ public abstract class Gadget extends SalesPackageBase implements Listener Manager.GetPlugin().getServer().getPluginManager().registerEvents(this, Manager.GetPlugin()); } + public GadgetType getGadgetType() + { + return _gadgetType; + } + public HashSet GetActive() { return _active; @@ -47,18 +53,20 @@ public abstract class Gadget extends SalesPackageBase implements Listener Disable(event.getPlayer()); } - public final void Enable(Player player) + public void Enable(Player player) { - if (!Manager.Manager.IsGadgetEnabled()) - { - UtilPlayer.message(player, F.main("Gadget", "Gadgets are currently disabled.")); - return; - } - + Manager.setActive(player, this); EnableCustom(player); } + + public void Disable(Player player) + { + Manager.removeActive(player, this); + DisableCustom(player); + } + public abstract void EnableCustom(Player player); - public abstract void Disable(Player player); + public abstract void DisableCustom(Player player); @Override public void Sold(Player player, CurrencyType currencyType) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java new file mode 100644 index 000000000..a339fd7da --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java @@ -0,0 +1,7 @@ +package mineplex.core.gadget.types; + +public enum GadgetType +{ + Item, + Morph, +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ItemGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ItemGadget.java similarity index 78% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ItemGadget.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ItemGadget.java index 059360092..07a4315b5 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ItemGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ItemGadget.java @@ -1,4 +1,4 @@ -package mineplex.hub.gadget.types; +package mineplex.core.gadget.types; import java.util.HashSet; @@ -10,32 +10,42 @@ 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.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; -import mineplex.hub.gadget.GadgetManager; public abstract class ItemGadget extends Gadget { private long _recharge; private int _gemsPerUse; - private boolean _nearParkour; public ItemGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, - long recharge, int gemsPerUse, boolean canUseNearParkour) + long recharge, int gemsPerUse) { - super(manager, name, desc, cost, mat, data); + super(manager, GadgetType.Item, name, desc, cost, mat, data); _recharge = recharge; _gemsPerUse = gemsPerUse; - _nearParkour = canUseNearParkour; Free = true; } + + @Override + public void EnableCustom(Player player) + { + ApplyItem(player); + } + + @Override + public void DisableCustom(Player player) + { + RemoveItem(player); + } public HashSet GetActive() { @@ -51,8 +61,6 @@ public abstract class ItemGadget extends Gadget { Manager.RemoveItem(player); - player.getInventory().setItem(3, ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(GetName()))); - _active.add(player); UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(GetName()) + ".")); @@ -82,7 +90,6 @@ public abstract class ItemGadget extends Gadget { if (_active.remove(player)) { - player.getInventory().setItem(3, null); UtilPlayer.message(player, F.main("Gadget", "You unequipped " + F.elem(GetName()) + ".")); } } @@ -111,12 +118,11 @@ public abstract class ItemGadget extends Gadget event.setCancelled(true); - //Parkour Deny - if (!_nearParkour && Manager.Manager.GetParkour().InParkour(player)) - { - UtilPlayer.message(player, F.main("Parkour", "You cannot use " + this.GetName() + " near Parkour Challenges.")); + GadgetActivateEvent gadgetEvent = new GadgetActivateEvent(player, this); + Bukkit.getServer().getPluginManager().callEvent(gadgetEvent); + + if (gadgetEvent.isCancelled()) return; - } //Recharge if (!Recharge.Instance.use(player, GetName(), _recharge, _recharge > 1000, false)) @@ -125,9 +131,9 @@ public abstract class ItemGadget extends Gadget //Use Gems if (_gemsPerUse > 0) { - if (Manager.Manager.GetDonation().Get(player.getName()).GetGems() >= _gemsPerUse) + if (Manager.getDonationManager().Get(player.getName()).GetGems() >= _gemsPerUse) { - Manager.Manager.GetDonation().RewardGemsLater(GetName(), player.getName(), -_gemsPerUse); + Manager.getDonationManager().RewardGemsLater(GetName(), player.getName(), -_gemsPerUse); } else { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/MorphGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java similarity index 93% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/MorphGadget.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java index 271992c73..03ae9e927 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/MorphGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java @@ -1,12 +1,12 @@ -package mineplex.hub.gadget.types; +package mineplex.core.gadget.types; import org.bukkit.Material; import org.bukkit.entity.Player; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.gadget.GadgetManager; import mineplex.core.itemstack.ItemStackFactory; -import mineplex.hub.gadget.GadgetManager; public abstract class MorphGadget extends Gadget { @@ -22,7 +22,7 @@ public abstract class MorphGadget extends Gadget public MorphGadget(GadgetManager manager, String name, String[] desc, int cost, ArmorSlot slot, Material mat, byte data) { - super(manager, name, desc, cost, mat, data); + super(manager, GadgetType.Morph, name, desc, cost, mat, data); _slot = slot; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/ClientInventory.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ClientInventory.java new file mode 100644 index 000000000..8f8ff2ecc --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ClientInventory.java @@ -0,0 +1,14 @@ +package mineplex.core.inventory; + +import java.util.ArrayList; +import java.util.List; + +public class ClientInventory +{ + public List Items = new ArrayList(); + + public int getChestCount() + { + return 0; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/ClientItem.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ClientItem.java new file mode 100644 index 000000000..1faa80d4f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ClientItem.java @@ -0,0 +1,9 @@ +package mineplex.core.inventory; + +import mineplex.core.inventory.data.Item; + +public class ClientItem +{ + public Item Item; + public int Count; +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java new file mode 100644 index 000000000..3d8875619 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java @@ -0,0 +1,118 @@ +package mineplex.core.inventory; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +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.donation.DonationManager; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.inventory.data.InventoryRepository; +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 +{ + private GadgetManager _gadgetManager; + private MountManager _mountManager; + private PetManager _petManager; + + private InventoryShop _inventoryShop; + + private InventoryRepository _repository; + + public InventoryManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, GadgetManager gadgetManager, MountManager mountManager, PetManager petManager) + { + super("Inventory Manager", plugin); + + _gadgetManager = gadgetManager; + _mountManager = mountManager; + _petManager = petManager; + + _inventoryShop = new InventoryShop(this, clientManager, donationManager, _moduleName); + + _repository = new InventoryRepository(plugin); + } + + @Override + protected ClientInventory AddPlayer(String player) + { + return new ClientInventory(); + } + + @Override + protected void loadClientInformation(final RetrieveClientInformationEvent event) + { + event.incrementProcessingCount(); + Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable() + { + public void run() + { + Set(event.getPlayerName(), _repository.loadClientInformation(event.getUniqueId().toString())); + event.decreaseProcessingCount(); + } + }); + } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) + { + 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 (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 (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; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/Category.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/Category.java new file mode 100644 index 000000000..bbd1354f3 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/Category.java @@ -0,0 +1,13 @@ +package mineplex.core.inventory.data; + +public class Category +{ + public int Id; + public String Name; + + public Category(int id, String name) + { + Id = id; + Name = name; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/InventoryRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/InventoryRepository.java new file mode 100644 index 000000000..64b290d74 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/InventoryRepository.java @@ -0,0 +1,162 @@ +package mineplex.core.inventory.data; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.common.util.NautHashMap; +import mineplex.core.database.RepositoryBase; +import mineplex.core.database.ResultSetCallable; +import mineplex.core.database.column.ColumnInt; +import mineplex.core.database.column.ColumnVarChar; +import mineplex.core.inventory.ClientInventory; +import mineplex.core.inventory.ClientItem; + +public class InventoryRepository extends RepositoryBase +{ + private static String CREATE_INVENTORY_TABLE = "CREATE TABLE IF NOT EXISTS items (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(100), categoryId INT, rarity INT, PRIMARY KEY (id), FOREIGN KEY (categoryId) REFERENCES itemCategories(id), INDEX uniqueNameCategoryIndex (name, categoryId));"; + private static String CREATE_INVENTORY_CATEGORY_TABLE = "CREATE TABLE IF NOT EXISTS itemCategories (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(100), PRIMARY KEY (id), INDEX nameIndex (name));"; + private static String CREATE_INVENTORY_RELATION_TABLE = "CREATE TABLE IF NOT EXISTS accountInventory (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, itemId INT NOT NULL, count INT NOT NULL, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (itemId) REFERENCES items(id), UNIQUE INDEX accountItemIndex (accountId, itemId));"; + + private static String INSERT_ITEM = "INSERT INTO items (name, categoryId, rarity) VALUES (?, ?, ?);"; + private static String RETRIEVE_ITEMS = "SELECT items.id, items.name, itemCategories.id, itemCategories.name, rarity FROM items INNER JOIN itemCategories ON itemCategories.id = items.categoryId;"; + + private static String INSERT_CATEGORY = "INSERT INTO category (name) VALUES (?);"; + private static String RETRIEVE_CATEGORIES = "SELECT id, name FROM itemCategories;"; + + private static String INSERT_CLIENT_INVENTORY = "INSERT INTO accountInventory (accountId, itemId, count) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.uuid = ? ON DUPLICATE KEY UPDATE count=VALUES(count);"; + private static String RETRIEVE_CLIENT_INVENTORY = "SELECT items.id, items.name, ic.id, ic.name as category, count FROM accountInventory AS ai INNER JOIN items ON items.id = ai.itemId INNER JOIN itemCategories AS ic ON ic.id = items.categoryId INNER JOIN accounts ON accounts.id = ai.accountId WHERE accounts.uuid = ?;"; + + public InventoryRepository(JavaPlugin plugin) + { + super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh"); + } + + @Override + protected void initialize() + { + executeUpdate(CREATE_INVENTORY_CATEGORY_TABLE); + executeUpdate(CREATE_INVENTORY_TABLE); + executeUpdate(CREATE_INVENTORY_RELATION_TABLE); + } + + @Override + protected void update() + { + } + + public List retrieveCategories() + { + final List categories = new ArrayList(); + + executeQuery(RETRIEVE_CATEGORIES, new ResultSetCallable() + { + public void processResultSet(ResultSet resultSet) throws SQLException + { + while (resultSet.next()) + { + categories.add(new Category(resultSet.getInt(1), resultSet.getString(2))); + } + } + }); + + return categories; + } + + public void addItem(Item item) + { + executeUpdate(INSERT_ITEM, new ColumnVarChar("name", 100, item.Name), new ColumnInt("categoryId", item.Category.Id), new ColumnInt("rarity", item.Rarity)); + } + + public void addCategory(Category category) + { + executeUpdate(INSERT_CATEGORY, new ColumnVarChar("name", 100, category.Name)); + } + + public List retrieveItems() + { + final List items = new ArrayList(); + + executeQuery(RETRIEVE_ITEMS, new ResultSetCallable() + { + public void processResultSet(ResultSet resultSet) throws SQLException + { + while (resultSet.next()) + { + items.add(new Item(resultSet.getInt(1), resultSet.getString(2), new Category(resultSet.getInt(3), resultSet.getString(4)), resultSet.getInt(5))); + } + } + }); + + return items; + } + + public void updateClientInventories(NautHashMap> clientInventories) + { + PreparedStatement preparedStatement = null; + + try + { + preparedStatement = getConnection().prepareStatement(INSERT_CLIENT_INVENTORY); + + for (String uuid : clientInventories.keySet()) + { + for (ClientItem item : clientInventories.get(uuid)) + { + preparedStatement.setInt(1, item.Item.Id); + preparedStatement.setInt(2, item.Count); + preparedStatement.setString(3, uuid); + + preparedStatement.addBatch(); + } + } + + preparedStatement.executeBatch(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + finally + { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + } + } + + public ClientInventory loadClientInformation(String uuid) + { + final ClientInventory clientInventory = new ClientInventory(); + + executeQuery(RETRIEVE_CLIENT_INVENTORY, new ResultSetCallable() + { + public void processResultSet(ResultSet resultSet) throws SQLException + { + while (resultSet.next()) + { + ClientItem item = new ClientItem(); + + item.Item = new Item(resultSet.getInt(1), resultSet.getString(2), new Category(resultSet.getInt(3), resultSet.getString(4))); + item.Count = resultSet.getInt(4); + + clientInventory.Items.add(item); + } + } + }, new ColumnVarChar("uuid", 100, uuid)); + + return clientInventory; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/Item.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/Item.java new file mode 100644 index 000000000..71256be94 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/Item.java @@ -0,0 +1,22 @@ +package mineplex.core.inventory.data; + +public class Item +{ + public int Id = -1; + public String Name; + public Category Category; + public int Rarity = 0; + + public Item(int id, String name, Category category, int rarity) + { + Id = id; + Name = name; + Category = category; + Rarity = rarity; + } + + public Item(int id, String name, Category category) + { + this(id, name, category, 0); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetShop.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/InventoryShop.java similarity index 50% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetShop.java rename to Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/InventoryShop.java index 356971e70..80e625f9d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetShop.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/InventoryShop.java @@ -1,4 +1,4 @@ -package mineplex.hub.gadget.ui; +package mineplex.core.inventory.ui; import org.bukkit.entity.Player; import org.bukkit.plugin.messaging.PluginMessageListener; @@ -6,28 +6,25 @@ import org.bukkit.plugin.messaging.PluginMessageListener; import mineplex.core.account.CoreClientManager; import mineplex.core.common.CurrencyType; 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; -import mineplex.hub.gadget.GadgetManager; -import mineplex.hub.mount.MountManager; -public class GadgetShop extends ShopBase implements PluginMessageListener +public class InventoryShop extends ShopBase implements PluginMessageListener { - private MountManager _mountManager; - - public GadgetShop(GadgetManager plugin, MountManager mountManager, CoreClientManager manager, DonationManager donationManager) - { - super(plugin, manager, donationManager, "Gadget Shop", CurrencyType.Gems); - - _mountManager = mountManager; - - plugin.GetPlugin().getServer().getMessenger().registerIncomingPluginChannel(plugin.GetPlugin(), "MC|ItemName", this); - } + public InventoryShop(InventoryManager plugin, CoreClientManager clientManager, DonationManager donationManager, String name) + { + super(plugin, clientManager, donationManager, name, CurrencyType.Gems, CurrencyType.Coins); + + plugin.GetPlugin().getServer().getMessenger().registerIncomingPluginChannel(plugin.GetPlugin(), "MC|ItemName", this); + } @Override - protected ShopPageBase> BuildPagesFor(Player player) + protected ShopPageBase> BuildPagesFor(Player player) { - return new GadgetPage(Plugin, this, _mountManager, ClientManager, DonationManager, " Gadgets", player); + return new Menu(Plugin, this, ClientManager, DonationManager, player); } @Override @@ -46,4 +43,4 @@ public class GadgetShop extends ShopBase implements PluginMessage } } } -} \ No newline at end of file +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetSorter.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/PetSorter.java similarity index 76% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetSorter.java rename to Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/PetSorter.java index 83c5e39f3..3c513166a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetSorter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/PetSorter.java @@ -1,8 +1,8 @@ -package mineplex.hub.gadget.ui; +package mineplex.core.inventory.ui; import java.util.Comparator; -import mineplex.hub.pet.Pet; +import mineplex.core.pet.Pet; public class PetSorter implements Comparator { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivateGadgetButton.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/ActivateGadgetButton.java similarity index 65% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivateGadgetButton.java rename to Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/ActivateGadgetButton.java index de8aa99a7..4172a9491 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivateGadgetButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/ActivateGadgetButton.java @@ -1,9 +1,10 @@ -package mineplex.hub.gadget.ui; +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.hub.gadget.types.Gadget; public class ActivateGadgetButton implements IButton { @@ -19,12 +20,12 @@ public class ActivateGadgetButton implements IButton @Override public void ClickedLeft(Player player) { - _page.ActivateGadget(player, _gadget); + _page.activateGadget(player, _gadget); } @Override public void ClickedRight(Player player) { - _page.ActivateGadget(player, _gadget); + _page.activateGadget(player, _gadget); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/ActivateMountButton.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/ActivateMountButton.java new file mode 100644 index 000000000..020186168 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/ActivateMountButton.java @@ -0,0 +1,32 @@ +package mineplex.core.inventory.ui.button; + +import org.bukkit.entity.Player; + +import mineplex.core.inventory.ui.page.Menu; +import mineplex.core.inventory.ui.page.MountPage; +import mineplex.core.mount.Mount; +import mineplex.core.shop.item.IButton; + +public class ActivateMountButton implements IButton +{ + private Mount _mount; + private MountPage _page; + + public ActivateMountButton(Mount mount, MountPage page) + { + _mount = mount; + _page = page; + } + + @Override + public void ClickedLeft(Player player) + { + _page.activateMount(player, _mount); + } + + @Override + public void ClickedRight(Player player) + { + _page.activateMount(player, _mount); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivatePetButton.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/ActivatePetButton.java similarity index 53% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivatePetButton.java rename to Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/ActivatePetButton.java index d96b6f529..f82ed0345 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivatePetButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/ActivatePetButton.java @@ -1,16 +1,17 @@ -package mineplex.hub.gadget.ui; +package mineplex.core.inventory.ui.button; import org.bukkit.entity.Player; -import mineplex.hub.pet.Pet; +import mineplex.core.inventory.ui.page.PetPage; +import mineplex.core.pet.Pet; import mineplex.core.shop.item.IButton; public class ActivatePetButton implements IButton { private Pet _pet; - private GadgetPage _page; + private PetPage _page; - public ActivatePetButton(Pet pet, GadgetPage page) + public ActivatePetButton(Pet pet, PetPage page) { _pet = pet; _page = page; @@ -19,12 +20,12 @@ public class ActivatePetButton implements IButton @Override public void ClickedLeft(Player player) { - _page.ActivatePet(player, _pet); + _page.activatePet(player, _pet); } @Override public void ClickedRight(Player player) { - _page.ActivatePet(player, _pet); + _page.activatePet(player, _pet); } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/CloseButton.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/CloseButton.java similarity index 87% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/CloseButton.java rename to Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/CloseButton.java index 02c9c7d7e..c3412c29d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/CloseButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/CloseButton.java @@ -1,4 +1,4 @@ -package mineplex.hub.gadget.ui; +package mineplex.core.inventory.ui.button; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/DeactivateGadgetButton.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/DeactivateGadgetButton.java new file mode 100644 index 000000000..6c4c7a40d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/DeactivateGadgetButton.java @@ -0,0 +1,36 @@ +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(); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/DeactivateMountButton.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/DeactivateMountButton.java new file mode 100644 index 000000000..fa1c3be59 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/DeactivateMountButton.java @@ -0,0 +1,35 @@ +package mineplex.core.inventory.ui.button; + +import org.bukkit.entity.Player; + +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.core.mount.Mount; + +public class DeactivateMountButton implements IButton +{ + private Mount _mount; + private ShopPageBase _page; + + public DeactivateMountButton(Mount mount, ShopPageBase page) + { + _mount = mount; + _page = page; + } + + @Override + public void ClickedLeft(Player player) + { + _page.PlayAcceptSound(player); + _mount.Disable(player); + _page.Refresh(); + } + + @Override + public void ClickedRight(Player player) + { + _page.PlayAcceptSound(player); + _mount.Disable(player); + _page.Refresh(); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/DeactivatePetButton.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/DeactivatePetButton.java new file mode 100644 index 000000000..a532ab651 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/DeactivatePetButton.java @@ -0,0 +1,35 @@ +package mineplex.core.inventory.ui.button; + +import org.bukkit.entity.Player; + +import mineplex.core.pet.PetManager; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.page.ShopPageBase; + +public class DeactivatePetButton implements IButton +{ + private ShopPageBase _page; + private PetManager _petManager; + + public DeactivatePetButton(ShopPageBase page, PetManager petManager) + { + _page = page; + _petManager = petManager; + } + + @Override + public void ClickedLeft(Player player) + { + _page.PlayAcceptSound(player); + _petManager.RemovePet(player, true); + _page.Refresh(); + } + + @Override + public void ClickedRight(Player player) + { + _page.PlayAcceptSound(player); + _petManager.RemovePet(player, true); + _page.Refresh(); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetButton.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/GadgetButton.java similarity index 64% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetButton.java rename to Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/GadgetButton.java index 55f742434..d486d8e9a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/GadgetButton.java @@ -1,9 +1,10 @@ -package mineplex.hub.gadget.ui; +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.hub.gadget.types.Gadget; public class GadgetButton implements IButton { @@ -19,12 +20,12 @@ public class GadgetButton implements IButton @Override public void ClickedLeft(Player player) { - _page.PurchaseGadget(player, _gadget); + _page.purchaseGadget(player, _gadget); } @Override public void ClickedRight(Player player) { - _page.PurchaseGadget(player, _gadget); + _page.purchaseGadget(player, _gadget); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/MountButton.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/MountButton.java new file mode 100644 index 000000000..5b217090b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/MountButton.java @@ -0,0 +1,31 @@ +package mineplex.core.inventory.ui.button; + +import org.bukkit.entity.Player; + +import mineplex.core.shop.item.IButton; +import mineplex.core.inventory.ui.page.MountPage; +import mineplex.core.mount.Mount; + +public class MountButton implements IButton +{ + private Mount _mount; + private MountPage _page; + + public MountButton(Mount mount, MountPage page) + { + _mount = mount; + _page = page; + } + + @Override + public void ClickedLeft(Player player) + { + _page.purchaseMount(player, _mount); + } + + @Override + public void ClickedRight(Player player) + { + _page.purchaseMount(player, _mount); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/OpenGadgets.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/OpenGadgets.java new file mode 100644 index 000000000..9df12ce3d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/OpenGadgets.java @@ -0,0 +1,28 @@ +package mineplex.core.inventory.ui.button; + +import mineplex.core.inventory.ui.page.Menu; +import mineplex.core.shop.item.IButton; + +import org.bukkit.entity.Player; + +public class OpenGadgets implements IButton +{ + private Menu _page; + + public OpenGadgets(Menu page) + { + _page = page; + } + + @Override + public void ClickedLeft(Player player) + { + _page.openGadgets(player); + } + + @Override + public void ClickedRight(Player player) + { + _page.openGadgets(player); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/OpenMorphs.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/OpenMorphs.java new file mode 100644 index 000000000..872012954 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/OpenMorphs.java @@ -0,0 +1,28 @@ +package mineplex.core.inventory.ui.button; + +import mineplex.core.inventory.ui.page.Menu; +import mineplex.core.shop.item.IButton; + +import org.bukkit.entity.Player; + +public class OpenMorphs implements IButton +{ + private Menu _page; + + public OpenMorphs(Menu page) + { + _page = page; + } + + @Override + public void ClickedLeft(Player player) + { + _page.openMorphs(player); + } + + @Override + public void ClickedRight(Player player) + { + _page.openMorphs(player); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/OpenMounts.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/OpenMounts.java new file mode 100644 index 000000000..c00facc80 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/OpenMounts.java @@ -0,0 +1,28 @@ +package mineplex.core.inventory.ui.button; + +import mineplex.core.inventory.ui.page.Menu; +import mineplex.core.shop.item.IButton; + +import org.bukkit.entity.Player; + +public class OpenMounts implements IButton +{ + private Menu _page; + + public OpenMounts(Menu page) + { + _page = page; + } + + @Override + public void ClickedLeft(Player player) + { + _page.openMounts(player); + } + + @Override + public void ClickedRight(Player player) + { + _page.openMounts(player); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/OpenParticles.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/OpenParticles.java new file mode 100644 index 000000000..061881eea --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/OpenParticles.java @@ -0,0 +1,28 @@ +package mineplex.core.inventory.ui.button; + +import mineplex.core.inventory.ui.page.Menu; +import mineplex.core.shop.item.IButton; + +import org.bukkit.entity.Player; + +public class OpenParticles implements IButton +{ + private Menu _page; + + public OpenParticles(Menu page) + { + _page = page; + } + + @Override + public void ClickedLeft(Player player) + { + _page.openParticles(player); + } + + @Override + public void ClickedRight(Player player) + { + _page.openParticles(player); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/OpenPets.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/OpenPets.java new file mode 100644 index 000000000..da7848e1a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/OpenPets.java @@ -0,0 +1,28 @@ +package mineplex.core.inventory.ui.button; + +import mineplex.core.inventory.ui.page.Menu; +import mineplex.core.shop.item.IButton; + +import org.bukkit.entity.Player; + +public class OpenPets implements IButton +{ + private Menu _page; + + public OpenPets(Menu page) + { + _page = page; + } + + @Override + public void ClickedLeft(Player player) + { + _page.openPets(player); + } + + @Override + public void ClickedRight(Player player) + { + _page.openPets(player); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetButton.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/PetButton.java similarity index 53% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetButton.java rename to Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/PetButton.java index f23ee1fd4..db243bc9b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/PetButton.java @@ -1,16 +1,17 @@ -package mineplex.hub.gadget.ui; +package mineplex.core.inventory.ui.button; import org.bukkit.entity.Player; -import mineplex.hub.pet.Pet; +import mineplex.core.pet.Pet; +import mineplex.core.inventory.ui.page.PetPage; import mineplex.core.shop.item.IButton; public class PetButton implements IButton { private Pet _pet; - private GadgetPage _page; + private PetPage _page; - public PetButton(Pet pet, GadgetPage page) + public PetButton(Pet pet, PetPage page) { _pet = pet; _page = page; @@ -19,12 +20,12 @@ public class PetButton implements IButton @Override public void ClickedLeft(Player player) { - _page.PurchasePet(player, _pet); + _page.purchasePet(player, _pet); } @Override public void ClickedRight(Player player) { - _page.PurchasePet(player, _pet); + _page.purchasePet(player, _pet); } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/RenamePetButton.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/RenamePetButton.java similarity index 68% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/RenamePetButton.java rename to Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/RenamePetButton.java index 2a0cb1a0e..69af998d9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/RenamePetButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/RenamePetButton.java @@ -1,14 +1,15 @@ -package mineplex.hub.gadget.ui; +package mineplex.core.inventory.ui.button; import org.bukkit.entity.Player; +import mineplex.core.inventory.ui.page.PetPage; import mineplex.core.shop.item.IButton; public class RenamePetButton implements IButton { - private GadgetPage _page; + private PetPage _page; - public RenamePetButton(GadgetPage page) + public RenamePetButton(PetPage page) { _page = page; } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/SelectTagButton.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/SelectTagButton.java similarity index 80% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/SelectTagButton.java rename to Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/SelectTagButton.java index acf422328..c7bd04277 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/SelectTagButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/button/SelectTagButton.java @@ -1,9 +1,9 @@ -package mineplex.hub.gadget.ui; +package mineplex.core.inventory.ui.button; import org.bukkit.entity.Player; +import mineplex.core.inventory.ui.page.PetTagPage; import mineplex.core.shop.item.IButton; -import mineplex.hub.gadget.ui.PetTagPage; public class SelectTagButton implements IButton { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/page/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/page/GadgetPage.java new file mode 100644 index 000000000..a0deeea86 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/page/GadgetPage.java @@ -0,0 +1,117 @@ +package mineplex.core.inventory.ui.page; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +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.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.page.ConfirmationPage; +import mineplex.core.shop.page.ShopPageBase; + +public class GadgetPage extends ShopPageBase +{ + public GadgetPage(InventoryManager plugin, InventoryShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) + { + super(plugin, shop, clientManager, donationManager, name, player, 54); + + BuildPage(); + } + + protected void BuildPage() + { + int slot = 0; + + for (Gadget gadget : Plugin.getGadgetManager().getGadgets()) + { + addGadget(gadget, slot); + + if (Plugin.getGadgetManager().getActive(Player, GadgetType.Item) == gadget) + addGlow(slot); + + slot++; + } + } + + protected void addGadget(Gadget gadget, int slot) + { + List itemLore = new ArrayList(); + + if (gadget.GetCost(CurrencyType.Coins) != -1) + { + itemLore.add(C.cYellow + gadget.GetCost(CurrencyType.Coins) + " Coins"); + } + if (gadget instanceof ItemGadget) + { + 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.cBlack); + itemLore.addAll(Arrays.asList(gadget.GetDescription())); + + if (gadget.IsFree() || DonationManager.Get(Player.getName()).OwnsUnknownPackage(gadget.GetName())) + { + if (gadget.GetActive().contains(Player)) + { + AddButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), "Deactivate " + gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new DeactivateGadgetButton(gadget, this)); + } + else + { + AddButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), "Activate " + gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new ActivateGadgetButton(gadget, this)); + } + } + else + { + if (gadget.GetCost(CurrencyType.Coins) != -1 && DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Coins) >= gadget.GetCost(CurrencyType.Coins)) + AddButton(slot, new ShopItem(Material.INK_SACK, (byte)8, "Purchase " + gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new GadgetButton(gadget, this)); + else + setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, "Purchase " + gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); + } + } + + public void purchaseGadget(final Player player, final Gadget gadget) + { + Shop.OpenPageForPlayer(Player, new ConfirmationPage(Plugin, Shop, ClientManager, DonationManager, new Runnable() + { + public void run() + { + Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, player)); + } + }, null, gadget, CurrencyType.Coins, Player)); + } + + public void activateGadget(Player player, Gadget gadget) + { + PlayAcceptSound(player); + gadget.Enable(player); + + Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, player)); + } + + public void deactivateGadget(Player player, Gadget gadget) + { + PlayAcceptSound(player); + gadget.Disable(player); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/page/Menu.java new file mode 100644 index 000000000..88d56939a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/page/Menu.java @@ -0,0 +1,107 @@ +package mineplex.core.inventory.ui.page; + +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.F; +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.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.OpenPets; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.mount.Mount; +import mineplex.core.pet.Pet; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.page.ShopPageBase; + +public class Menu extends ShopPageBase +{ + public Menu(InventoryManager plugin, InventoryShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) + { + super(plugin, shop, clientManager, donationManager, "Inventory", player); + + BuildPage(); + } + + @Override + 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).getChestCount() + " Chests", 1, false)); + AddItem(15, new ShopItem(Material.EMERALD, DonationManager.Get(Player.getName()).GetGems() + " Gems", 1, false)); + + AddItem(27, new ShopItem(Material.NETHER_STAR, "Particle Effects", 1, false)); + AddButton(29, new ShopItem(Material.BOW, "Gadgets", 1, false), new OpenGadgets(this)); + AddButton(31, new ShopItem(Material.LEASH, "Pets", 1, false), new OpenPets(this)); + AddButton(33, new ShopItem(Material.IRON_BARDING, "Mounts", 1, false), new OpenMounts(this)); + AddButton(35, new ShopItem(Material.LEATHER, "Morphs", 1, false), new OpenMorphs(this)); + + // Active ones. + //AddItem(36, new ShopItem(Material.NETHER_STAR, "Particle Effects", 1, false)); + if (Plugin.getGadgetManager().getActive(Player, GadgetType.Item) != null) + { + 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)); + } + + if (Plugin.getPetManager().hasActivePet(Player.getName())) + { + AddButton(40, new ShopItem(Material.MONSTER_EGG, (byte)Plugin.getPetManager().getActivePet(Player.getName()).getType().getTypeId(), "Deactivate " + Plugin.getPetManager().getActivePet(Player.getName()).getCustomName(), new String[] {}, 1, false, false), new DeactivatePetButton(this, Plugin.getPetManager())); + } + + if (Plugin.getMountManager().getActive(Player) != null) + { + 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)); + } + + if (Plugin.getGadgetManager().getActive(Player, GadgetType.Morph) != null) + { + 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)); + } + } + + public void openParticles(Player player) + { + Shop.OpenPageForPlayer(player, new ParticlePage(Plugin, Shop, ClientManager, DonationManager, "Particles", player)); + } + + public void openGadgets(Player player) + { + Shop.OpenPageForPlayer(player, new GadgetPage(Plugin, Shop, ClientManager, DonationManager, "Gadgets", player)); + } + + public void openMorphs(Player player) + { + Shop.OpenPageForPlayer(player, new MorphPage(Plugin, Shop, ClientManager, DonationManager, "Morphs", player)); + } + + public void openMounts(Player player) + { + Shop.OpenPageForPlayer(player, new MountPage(Plugin, Shop, ClientManager, DonationManager, "Mounts", player)); + } + + public void openPets(Player player) + { + Shop.OpenPageForPlayer(player, new PetPage(Plugin, Shop, ClientManager, DonationManager, "Pets", player)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/page/MorphPage.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/page/MorphPage.java new file mode 100644 index 000000000..b0c97a5d9 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/page/MorphPage.java @@ -0,0 +1,38 @@ +package mineplex.core.inventory.ui.page; + +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +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; + +public class MorphPage extends GadgetPage +{ + public MorphPage(InventoryManager plugin, InventoryShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) + { + super(plugin, shop, clientManager, donationManager, name, player); + } + + @Override + protected void BuildPage() + { + int slot = 0; + + for (Gadget gadget : Plugin.getGadgetManager().getGadgets()) + { + if (gadget instanceof MorphGadget) + { + addGadget(gadget, slot); + + if (Plugin.getGadgetManager().getActive(Player, GadgetType.Morph) == gadget) + addGlow(slot); + + slot++; + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/page/MountPage.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/page/MountPage.java new file mode 100644 index 000000000..e3e1e96b7 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/page/MountPage.java @@ -0,0 +1,92 @@ +package mineplex.core.inventory.ui.page; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.CurrencyType; +import mineplex.core.common.util.C; +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.page.ConfirmationPage; +import mineplex.core.shop.page.ShopPageBase; + +public class MountPage extends ShopPageBase +{ + public MountPage(InventoryManager plugin, InventoryShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) + { + super(plugin, shop, clientManager, donationManager, name, player, 54); + + BuildPage(); + } + + protected void BuildPage() + { + int slot = 0; + + for (Mount mount : Plugin.getMountManager().getMounts()) + { + addMount(mount, slot); + slot++; + } + } + + protected void addMount(Mount mount, int slot) + { + List itemLore = new ArrayList(); + + if (mount.GetCost(CurrencyType.Gems) != -1) + { + itemLore.add(C.cYellow + mount.GetCost(CurrencyType.Gems) + " Gems"); + } + + itemLore.add(C.cBlack); + itemLore.addAll(Arrays.asList(mount.GetDescription())); + + if (DonationManager.Get(Player.getName()).OwnsUnknownPackage(mount.GetName())) + { + if (mount.GetActive().containsKey(Player)) + { + AddButton(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), "Deactivate " + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new DeactivateMountButton(mount, this)); + } + else + { + AddButton(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), "Activate " + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new ActivateMountButton(mount, this)); + } + } + else + { + if (mount.GetCost(CurrencyType.Gems) != -1 && DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Gems) >= mount.GetCost(CurrencyType.Gems)) + AddButton(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), "Purchase " + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new MountButton(mount, this)); + else + setItem(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), "Purchase " + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); + } + } + + public void purchaseMount(final Player player, final Mount _mount) + { + Shop.OpenPageForPlayer(Player, new ConfirmationPage(Plugin, Shop, ClientManager, DonationManager, new Runnable() + { + public void run() + { + Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, player)); + } + }, null, _mount, CurrencyType.Gems, Player)); + } + + public void activateMount(Player player, Mount _mount) + { + PlayAcceptSound(player); + _mount.Enable(player); + Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, player)); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/page/ParticlePage.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/page/ParticlePage.java new file mode 100644 index 000000000..e7922dbe1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/page/ParticlePage.java @@ -0,0 +1,35 @@ +package mineplex.core.inventory.ui.page; + +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +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; + +public class ParticlePage extends GadgetPage +{ + public ParticlePage(InventoryManager plugin, InventoryShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) + { + super(plugin, shop, clientManager, donationManager, name, player); + } + + @Override + protected void BuildPage() + { + int slot = 0; + + for (Gadget gadget : Plugin.getGadgetManager().getParticles()) + { + addGadget(gadget, slot); + + if (Plugin.getGadgetManager().getActive(Player, GadgetType.Morph) == gadget) + addGlow(slot); + + slot++; + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/page/PetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/page/PetPage.java new file mode 100644 index 000000000..ea96cfe4c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/page/PetPage.java @@ -0,0 +1,142 @@ +package mineplex.core.inventory.ui.page; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import net.minecraft.server.v1_7_R3.EntityPlayer; +import net.minecraft.server.v1_7_R3.Items; +import net.minecraft.server.v1_7_R3.PacketPlayOutOpenWindow; +import net.minecraft.server.v1_7_R3.PacketPlayOutSetSlot; + +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer; +import org.bukkit.entity.Creature; +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.CurrencyType; +import mineplex.core.common.util.C; +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; +import mineplex.core.shop.page.AnvilContainer; +import mineplex.core.shop.page.ShopPageBase; + +public class PetPage extends ShopPageBase +{ + public PetPage(InventoryManager plugin, InventoryShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) + { + super(plugin, shop, clientManager, donationManager, name, player, 54); + + BuildPage(); + } + + protected void BuildPage() + { + int slot = 38; + + List pets = new ArrayList(Plugin.getPetManager().GetFactory().GetPets()); + + Collections.sort(pets, new PetSorter()); + + for (Pet pet : pets) + { + List itemLore = new ArrayList(); + + itemLore.add(C.cYellow + pet.GetCost(CurrencyType.Gems) + " Coins"); + itemLore.add(C.cBlack); + + if (DonationManager.Get(Player.getName()).OwnsUnknownPackage(pet.GetPetName())) + { + if (Plugin.getPetManager().hasActivePet(Player.getName()) && Plugin.getPetManager().getActivePet(Player.getName()).getType() == pet.GetPetType()) + { + AddButton(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), "Deactivate " + Plugin.getPetManager().Get(Player).GetPets().get(pet.GetPetType()), new String[] {}, 1, false, false), new DeactivatePetButton(this, Plugin.getPetManager())); + + addGlow(slot); + } + else + { + AddButton(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), "Activate " + Plugin.getPetManager().Get(Player).GetPets().get(pet.GetPetType()), new String[] {}, 1, false, false), new ActivatePetButton(pet, this)); + } + } + else + { + if (DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Coins) >= pet.GetCost(CurrencyType.Coins)) + AddButton(slot, new ShopItem(Material.INK_SACK, (byte)8, "Purchase " + pet.GetPetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new PetButton(pet, this)); + else + setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, "Purchase " + pet.GetPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); + } + + slot++; + } + + slot = 36; + for (PetExtra petExtra : Plugin.getPetManager().GetFactory().GetPetExtras()) + { + List itemLore = new ArrayList(); + + if (!Plugin.getPetManager().hasActivePet(Player.getName())) + { + itemLore.add(C.cWhite + "You must have an active pet to use this!"); + getInventory().setItem(slot, new ShopItem(petExtra.GetMaterial(), (byte)0, C.cRed + petExtra.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).getHandle()); + } + else + { + AddButton(slot, new ShopItem(petExtra.GetMaterial(), (byte)0, "Rename " + Plugin.getPetManager().getActivePet(Player.getName()).getCustomName() + " for " + C.cYellow + petExtra.GetCost(CurrencyType.Coins) + C.cGreen + " Coins", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this)); + } + + slot++; + } + } + + public void purchasePet(final Player player, final Pet pet) + { + renamePet(player, pet, true); + } + + public void renameCurrentPet(Player player) + { + PlayAcceptSound(player); + Creature currentPet = Plugin.getPetManager().getActivePet(player.getName()); + renamePet(player, new Pet(currentPet.getCustomName(), currentPet.getType(), 1), false); + } + + public void renamePet(Player player, Pet pet, boolean petPurchase) + { + PlayAcceptSound(player); + + PetTagPage petTagPage = new PetTagPage(Plugin, Shop, ClientManager, DonationManager, "Repairing", Player, pet, petPurchase); + EntityPlayer entityPlayer = ((CraftPlayer)Player).getHandle(); + int containerCounter = entityPlayer.nextContainerCounter(); + entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(containerCounter, 8, "Repairing", 9, true)); + entityPlayer.activeContainer = new AnvilContainer(entityPlayer.inventory, petTagPage.getInventory()); + entityPlayer.activeContainer.windowId = containerCounter; + entityPlayer.activeContainer.addSlotListener(entityPlayer); + entityPlayer.playerConnection.sendPacket(new PacketPlayOutSetSlot(containerCounter, 0, new net.minecraft.server.v1_7_R3.ItemStack(Items.NAME_TAG))); + + Shop.SetCurrentPageForPlayer(Player, petTagPage); + } + + public void activatePet(Player player, Pet pet) + { + PlayAcceptSound(player); + Plugin.getPetManager().AddPetOwner(player, pet.GetPetType(), player.getLocation()); + Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, player)); + } + + public void deactivatePet(Player player) + { + PlayAcceptSound(player); + Plugin.getPetManager().RemovePet(player, true); + Refresh(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetTagPage.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/page/PetTagPage.java similarity index 74% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetTagPage.java rename to Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/page/PetTagPage.java index 6d528a962..2181f8ac5 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetTagPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/ui/page/PetTagPage.java @@ -1,4 +1,4 @@ -package mineplex.hub.gadget.ui; +package mineplex.core.inventory.ui.page; import mineplex.core.account.CoreClientManager; import mineplex.core.common.CurrencyType; @@ -6,11 +6,14 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.donation.DonationManager; -import mineplex.hub.gadget.GadgetManager; -import mineplex.hub.pet.Pet; -import mineplex.hub.pet.PetExtra; -import mineplex.hub.pet.repository.token.PetChangeToken; -import mineplex.hub.pet.repository.token.PetToken; +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; +import mineplex.core.pet.repository.token.PetToken; import mineplex.core.shop.page.ConfirmationPage; import mineplex.core.shop.page.ShopPageBase; import net.minecraft.server.v1_7_R3.ItemStack; @@ -20,13 +23,13 @@ import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; -public class PetTagPage extends ShopPageBase +public class PetTagPage extends ShopPageBase { private String _tagName = "Pet Tag"; private Pet _pet; private boolean _petPurchase; - public PetTagPage(GadgetManager plugin, GadgetShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, Pet pet, boolean petPurchase) + public PetTagPage(InventoryManager plugin, InventoryShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, Pet pet, boolean petPurchase) { super(plugin, shop, clientManager, donationManager, name, player, 3); @@ -70,7 +73,7 @@ public class PetTagPage extends ShopPageBase _pet.setDisplayName(C.cGreen + "Purchase " + _tagName); - Shop.OpenPageForPlayer(Player, new ConfirmationPage(Plugin, Shop, ClientManager, DonationManager, new Runnable() + Shop.OpenPageForPlayer(Player, new ConfirmationPage(Plugin, Shop, ClientManager, DonationManager, new Runnable() { public void run() { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/DragonData.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonData.java similarity index 98% rename from Plugins/Mineplex.Hub/src/mineplex/hub/mount/DragonData.java rename to Plugins/Mineplex.Core/src/mineplex/core/mount/DragonData.java index 191372874..5343de813 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/DragonData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonData.java @@ -1,4 +1,4 @@ -package mineplex.hub.mount; +package mineplex.core.mount; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/DragonMount.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonMount.java similarity index 97% rename from Plugins/Mineplex.Hub/src/mineplex/hub/mount/DragonMount.java rename to Plugins/Mineplex.Core/src/mineplex/core/mount/DragonMount.java index 957c987f7..137d0f9b8 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/DragonMount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonMount.java @@ -1,4 +1,4 @@ -package mineplex.hub.mount; +package mineplex.core.mount; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/HorseMount.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java similarity index 91% rename from Plugins/Mineplex.Hub/src/mineplex/hub/mount/HorseMount.java rename to Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java index 595a6fead..144ef45d2 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/HorseMount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java @@ -1,4 +1,4 @@ -package mineplex.hub.mount; +package mineplex.core.mount; import java.util.Iterator; @@ -65,14 +65,6 @@ public class HorseMount extends Mount continue; } - //Parkour - if (Manager.Manager.GetParkour().InParkour(horse)) - { - horse.remove(); - activeIterator.remove(); - continue; - } - //Move EntityCreature ec = ((CraftCreature)horse).getHandle(); Navigation nav = ec.getNavigation(); @@ -97,13 +89,6 @@ public class HorseMount extends Mount player.leaveVehicle(); player.eject(); - //Parkour - if (Manager.Manager.GetParkour().InParkour(player)) - { - UtilPlayer.message(player, F.main("Mount", "You cannot use Mounts near Parkour.")); - return; - } - //Remove other mounts Manager.DeregisterAll(player); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/Mount.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java similarity index 86% rename from Plugins/Mineplex.Hub/src/mineplex/hub/mount/Mount.java rename to Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java index ddc04afc1..36598771b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/Mount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java @@ -1,4 +1,4 @@ -package mineplex.hub.mount; +package mineplex.core.mount; import java.util.HashMap; import java.util.HashSet; @@ -11,8 +11,6 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.common.CurrencyType; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.shop.item.SalesPackageBase; public abstract class Mount extends SalesPackageBase implements Listener @@ -37,12 +35,7 @@ public abstract class Mount extends SalesPackageBase implements Listener public final void Enable(Player player) { - if (!Manager.Manager.IsGadgetEnabled()) - { - UtilPlayer.message(player, F.main("Gadget", "Gadgets are currently disabled.")); - return; - } - + Manager.setActive(player, this); EnableCustom(player); } public abstract void EnableCustom(Player player); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/MountManager.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java similarity index 56% rename from Plugins/Mineplex.Hub/src/mineplex/hub/mount/MountManager.java rename to Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java index 7f353058d..5ea5416c4 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/MountManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java @@ -1,4 +1,4 @@ -package mineplex.hub.mount; +package mineplex.core.mount; import java.util.HashSet; @@ -8,27 +8,34 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; -import mineplex.core.common.Rank; +import mineplex.core.account.CoreClientManager; +import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.hub.HubManager; -import mineplex.hub.mount.types.*; +import mineplex.core.donation.DonationManager; +import mineplex.core.mount.types.*; public class MountManager extends MiniPlugin { - public HubManager Manager; + private CoreClientManager _clientManager; + private DonationManager _donationManager; + private BlockRestore _blockRestore; private HashSet> _types; + private NautHashMap> _playerActiveMountMap = new NautHashMap>(); - public MountManager(HubManager manager) + public MountManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, BlockRestore blockRestore) { - super("Mount Manager", manager.GetPlugin()); + super("Mount Manager", plugin); - Manager = manager; + _clientManager = clientManager; + _donationManager = donationManager; + _blockRestore = blockRestore; CreateGadgets(); } @@ -48,18 +55,6 @@ public class MountManager extends MiniPlugin return _types; } - @EventHandler - public void onPlayerJoin(PlayerJoinEvent event) - { - if (Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.MODERATOR)) - { - for (Mount mount : _types) - { - Manager.GetDonation().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(mount.GetName()); - } - } - } - //Disallows two mounts active public void DeregisterAll(Player player) { @@ -96,4 +91,34 @@ public class MountManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) mount.Disable(player); } + + public void setActive(Player player, Mount mount) + { + _playerActiveMountMap.put(player, mount); + } + + public Mount getActive(Player player) + { + return _playerActiveMountMap.get(player); + } + + public void removeActive(Player player) + { + _playerActiveMountMap.remove(player); + } + + public CoreClientManager getClientManager() + { + return _clientManager; + } + + public DonationManager getDonationManager() + { + return _donationManager; + } + + public BlockRestore getBlockRestore() + { + return _blockRestore; + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Dragon.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/Dragon.java similarity index 83% rename from Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Dragon.java rename to Plugins/Mineplex.Core/src/mineplex/core/mount/types/Dragon.java index 160e55cb9..2007313c0 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Dragon.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/Dragon.java @@ -1,10 +1,8 @@ -package mineplex.hub.mount.types; +package mineplex.core.mount.types; import java.util.HashSet; -import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.entity.Horse; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityTargetEvent; @@ -15,16 +13,14 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.mount.DragonData; +import mineplex.core.mount.DragonMount; +import mineplex.core.mount.MountManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.hub.mount.DragonData; -import mineplex.hub.mount.DragonMount; -import mineplex.hub.mount.MountManager; public class Dragon extends DragonMount { - public Dragon(MountManager manager) { super(manager, "Ethereal Dragon", new String[] @@ -107,9 +103,9 @@ public class Dragon extends DragonMount @EventHandler public void HeroOwner(PlayerJoinEvent event) { - if (Manager.Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.HERO)) + if (Manager.getClientManager().Get(event.getPlayer()).GetRank().Has(Rank.HERO)) { - Manager.Manager.GetDonation().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName()); + Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName()); } } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Frost.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/Frost.java similarity index 87% rename from Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Frost.java rename to Plugins/Mineplex.Core/src/mineplex/core/mount/types/Frost.java index 6ef51f117..deb78c378 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Frost.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/Frost.java @@ -1,4 +1,4 @@ -package mineplex.hub.mount.types; +package mineplex.core.mount.types; import java.util.HashMap; import java.util.Iterator; @@ -10,18 +10,16 @@ import org.bukkit.entity.Horse; import org.bukkit.entity.Horse.Color; import org.bukkit.entity.Horse.Style; import org.bukkit.entity.Horse.Variant; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.mount.HorseMount; +import mineplex.core.mount.MountManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.hub.mount.HorseMount; -import mineplex.hub.mount.MountManager; public class Frost extends HorseMount { @@ -79,7 +77,7 @@ public class Frost extends HorseMount if (addSnow) - Manager.Manager.GetBlockRestore().Snow(block, (byte)1, (byte)1, (long)(duration * (1 + blocks.get(block))), 250, 0); + Manager.getBlockRestore().Snow(block, (byte)1, (byte)1, (long)(duration * (1 + blocks.get(block))), 250, 0); } } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Mule.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/Mule.java similarity index 80% rename from Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Mule.java rename to Plugins/Mineplex.Core/src/mineplex/core/mount/types/Mule.java index 7ed45129c..7da67db0a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Mule.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/Mule.java @@ -1,4 +1,4 @@ -package mineplex.hub.mount.types; +package mineplex.core.mount.types; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -6,8 +6,8 @@ import org.bukkit.entity.Horse.Color; import org.bukkit.entity.Horse.Style; import org.bukkit.entity.Horse.Variant; -import mineplex.hub.mount.HorseMount; -import mineplex.hub.mount.MountManager; +import mineplex.core.mount.HorseMount; +import mineplex.core.mount.MountManager; public class Mule extends HorseMount { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Undead.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/Undead.java similarity index 92% rename from Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Undead.java rename to Plugins/Mineplex.Core/src/mineplex/core/mount/types/Undead.java index e3f60d117..971d2a5f8 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Undead.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/Undead.java @@ -1,4 +1,4 @@ -package mineplex.hub.mount.types; +package mineplex.core.mount.types; import org.bukkit.Material; import org.bukkit.entity.Horse; @@ -12,10 +12,10 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.mount.HorseMount; +import mineplex.core.mount.MountManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.hub.mount.HorseMount; -import mineplex.hub.mount.MountManager; public class Undead extends HorseMount { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/Pet.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/Pet.java similarity index 91% rename from Plugins/Mineplex.Hub/src/mineplex/hub/pet/Pet.java rename to Plugins/Mineplex.Core/src/mineplex/core/pet/Pet.java index 7f0448362..f29805f4b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/Pet.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/Pet.java @@ -1,9 +1,9 @@ -package mineplex.hub.pet; +package mineplex.core.pet; import mineplex.core.common.CurrencyType; +import mineplex.core.pet.repository.token.PetSalesToken; import mineplex.core.shop.item.SalesPackageBase; import mineplex.core.shop.item.ShopItem; -import mineplex.hub.pet.repository.token.PetSalesToken; import org.bukkit.Material; import org.bukkit.entity.EntityType; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetClient.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java similarity index 86% rename from Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetClient.java rename to Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java index 6d38a8892..5aa25843a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetClient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java @@ -1,10 +1,10 @@ -package mineplex.hub.pet; +package mineplex.core.pet; import org.bukkit.entity.EntityType; import mineplex.core.common.util.NautHashMap; -import mineplex.hub.pet.repository.token.ClientPetToken; -import mineplex.hub.pet.repository.token.PetToken; +import mineplex.core.pet.repository.token.ClientPetToken; +import mineplex.core.pet.repository.token.PetToken; public class PetClient { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetExtra.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java similarity index 90% rename from Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetExtra.java rename to Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java index e95fa98b8..416c54c1a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetExtra.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java @@ -1,9 +1,9 @@ -package mineplex.hub.pet; +package mineplex.core.pet; import mineplex.core.common.CurrencyType; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.pet.repository.token.PetExtraToken; import mineplex.core.shop.item.SalesPackageBase; -import mineplex.hub.pet.repository.token.PetExtraToken; import org.bukkit.ChatColor; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetFactory.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetFactory.java similarity index 92% rename from Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetFactory.java rename to Plugins/Mineplex.Core/src/mineplex/core/pet/PetFactory.java index b3dd0abd2..416629ba0 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetFactory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetFactory.java @@ -1,13 +1,13 @@ -package mineplex.hub.pet; +package mineplex.core.pet; import java.util.ArrayList; import java.util.Collection; import java.util.List; import mineplex.core.common.util.NautHashMap; -import mineplex.hub.pet.repository.PetRepository; -import mineplex.hub.pet.repository.token.PetExtraToken; -import mineplex.hub.pet.repository.token.PetSalesToken; +import mineplex.core.pet.repository.PetRepository; +import mineplex.core.pet.repository.token.PetExtraToken; +import mineplex.core.pet.repository.token.PetSalesToken; import org.bukkit.Material; import org.bukkit.entity.EntityType; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java similarity index 98% rename from Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetManager.java rename to Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java index 9b304b007..1c80f961b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java @@ -1,10 +1,12 @@ -package mineplex.hub.pet; +package mineplex.core.pet; import java.lang.reflect.Field; import java.util.Iterator; import java.util.Map.Entry; import mineplex.core.MiniClientPlugin; +import mineplex.core.pet.repository.PetRepository; +import mineplex.core.pet.repository.token.ClientPetTokenWrapper; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; import mineplex.core.account.CoreClientManager; @@ -15,8 +17,6 @@ import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilInv; import mineplex.core.donation.DonationManager; import mineplex.core.itemstack.ItemStackFactory; -import mineplex.hub.pet.repository.PetRepository; -import mineplex.hub.pet.repository.token.ClientPetTokenWrapper; import net.minecraft.server.v1_7_R3.EntityCreature; import net.minecraft.server.v1_7_R3.EntityHuman; import net.minecraft.server.v1_7_R3.EntityInsentient; @@ -31,6 +31,7 @@ import net.minecraft.server.v1_7_R3.PathfinderGoalSelector; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/event/PetSpawnEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/event/PetSpawnEvent.java similarity index 97% rename from Plugins/Mineplex.Hub/src/mineplex/hub/pet/event/PetSpawnEvent.java rename to Plugins/Mineplex.Core/src/mineplex/core/pet/event/PetSpawnEvent.java index bca89bf8e..cbd0d2c32 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/event/PetSpawnEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/event/PetSpawnEvent.java @@ -1,4 +1,4 @@ -package mineplex.hub.pet.event; +package mineplex.core.pet.event; import org.bukkit.Location; import org.bukkit.entity.EntityType; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/PetRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java similarity index 86% rename from Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/PetRepository.java rename to Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java index b3687a30a..344f4f165 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/PetRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java @@ -1,14 +1,14 @@ -package mineplex.hub.pet.repository; +package mineplex.core.pet.repository; import java.util.List; import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken; +import mineplex.core.pet.repository.token.PetChangeToken; +import mineplex.core.pet.repository.token.PetExtraToken; +import mineplex.core.pet.repository.token.PetSalesToken; import mineplex.core.server.remotecall.AsyncJsonWebCall; import mineplex.core.server.remotecall.JsonWebCall; -import mineplex.hub.pet.repository.token.PetChangeToken; -import mineplex.hub.pet.repository.token.PetExtraToken; -import mineplex.hub.pet.repository.token.PetSalesToken; public class PetRepository { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/token/ClientPetToken.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/ClientPetToken.java similarity index 72% rename from Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/token/ClientPetToken.java rename to Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/ClientPetToken.java index 2c25b9d83..5f45ac822 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/token/ClientPetToken.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/ClientPetToken.java @@ -1,4 +1,4 @@ -package mineplex.hub.pet.repository.token; +package mineplex.core.pet.repository.token; import java.util.List; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/token/ClientPetTokenWrapper.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/ClientPetTokenWrapper.java similarity index 68% rename from Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/token/ClientPetTokenWrapper.java rename to Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/ClientPetTokenWrapper.java index 2e9dbb215..3c8a0b274 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/token/ClientPetTokenWrapper.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/ClientPetTokenWrapper.java @@ -1,4 +1,4 @@ -package mineplex.hub.pet.repository.token; +package mineplex.core.pet.repository.token; public class ClientPetTokenWrapper { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/token/PetChangeToken.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/PetChangeToken.java similarity index 69% rename from Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/token/PetChangeToken.java rename to Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/PetChangeToken.java index cf6a199b8..e42a5e61e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/token/PetChangeToken.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/PetChangeToken.java @@ -1,4 +1,4 @@ -package mineplex.hub.pet.repository.token; +package mineplex.core.pet.repository.token; public class PetChangeToken { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/token/PetExtraToken.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/PetExtraToken.java similarity index 64% rename from Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/token/PetExtraToken.java rename to Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/PetExtraToken.java index 99e1c50a3..c40324f0a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/token/PetExtraToken.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/PetExtraToken.java @@ -1,4 +1,4 @@ -package mineplex.hub.pet.repository.token; +package mineplex.core.pet.repository.token; public class PetExtraToken { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/token/PetSalesToken.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/PetSalesToken.java similarity index 64% rename from Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/token/PetSalesToken.java rename to Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/PetSalesToken.java index 3b4d26b71..e427ac8ed 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/token/PetSalesToken.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/PetSalesToken.java @@ -1,4 +1,4 @@ -package mineplex.hub.pet.repository.token; +package mineplex.core.pet.repository.token; public class PetSalesToken { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/token/PetToken.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/PetToken.java similarity index 63% rename from Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/token/PetToken.java rename to Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/PetToken.java index d58fc6ca3..fecdcde0f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/token/PetToken.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/PetToken.java @@ -1,4 +1,4 @@ -package mineplex.hub.pet.repository.token; +package mineplex.core.pet.repository.token; public class PetToken { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/item/ShopItem.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/ShopItem.java index 7ad208fb7..6c1627c38 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/item/ShopItem.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/ShopItem.java @@ -1,5 +1,6 @@ package mineplex.core.shop.item; +import mineplex.core.common.util.UtilInv; import net.minecraft.server.v1_7_R3.NBTTagList; import net.minecraft.server.v1_7_R3.NBTTagString; @@ -36,25 +37,50 @@ public class ShopItem extends CraftItemStack { this(type, name, null, deliveryAmount, locked); } + + public ShopItem(int type, String name, int deliveryAmount, boolean locked) + { + this(type, name, null, deliveryAmount, locked); + } public ShopItem(Material type, String name, String[] lore, int deliveryAmount, boolean locked) { this(type, name, lore, deliveryAmount, locked, false); } + + public ShopItem(int type, String name, String[] lore, int deliveryAmount, boolean locked) + { + this(type, name, lore, deliveryAmount, locked, false); + } public ShopItem(Material type, String name, String[] lore, int deliveryAmount, boolean locked, boolean displayItem) { this(type, (byte)0, name, null, lore, deliveryAmount, locked, displayItem); } + + public ShopItem(int type, String name, String[] lore, int deliveryAmount, boolean locked, boolean displayItem) + { + this(type, (byte)0, name, null, lore, deliveryAmount, locked, displayItem); + } public ShopItem(Material type, byte data, String name, String[] lore, int deliveryAmount, boolean locked, boolean displayItem) { this(type, data, name, null, lore, deliveryAmount, locked, displayItem); } + + public ShopItem(int type, byte data, String name, String[] lore, int deliveryAmount, boolean locked, boolean displayItem) + { + this(type, data, name, null, lore, deliveryAmount, locked, displayItem); + } public ShopItem(Material type, byte data, String name, String deliveryName, String[] lore, int deliveryAmount, boolean locked, boolean displayItem) { - super(type.getId(), Math.max(deliveryAmount, 1), data, null); + this(type.getId(), data, name, deliveryName, lore, deliveryAmount, locked, displayItem); + } + + public ShopItem(int type, byte data, String name, String deliveryName, String[] lore, int deliveryAmount, boolean locked, boolean displayItem) + { + super(type, Math.max(deliveryAmount, 1), data, null); _name = name; _deliveryName = deliveryName; @@ -65,10 +91,6 @@ public class ShopItem extends CraftItemStack UpdateVisual(false); - // Fix for temp save junk(fixes problem when disconnecting and trying to return) - //if (getHandle().tag != null) - // getHandle().tag.setName("tag"); - getHandle().tag.setByte("Count", (byte)Math.max(deliveryAmount, 1)); getHandle().tag.set("AttributeModifiers", new NBTTagList()); } @@ -138,6 +160,11 @@ public class ShopItem extends CraftItemStack { return _displayItem; } + + public void addGlow() + { + UtilInv.addDullEnchantment(this); + } public void SetLocked(boolean owns) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java index 2969ca631..335c26931 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java @@ -4,8 +4,6 @@ import mineplex.core.MiniPlugin; import mineplex.core.server.util.TransactionResponse; import mineplex.core.shop.ShopBase; import mineplex.core.shop.item.IButton; -import mineplex.core.shop.item.ISalesPackage; -import mineplex.core.shop.item.ItemPackage; import mineplex.core.shop.item.SalesPackageBase; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageBase; @@ -155,7 +153,7 @@ public class ConfirmationPage { private static Object _statSync = new Object(); - private NautHashMap> _statUploadQueue = new NautHashMap>(); + private StatsRepository _repository; + + private NautHashMap _stats = new NautHashMap(); + private NautHashMap> _statUploadQueue = new NautHashMap>(); private Runnable _saveRunnable; - private NautHashMap _tables = new NautHashMap(); - - private NautHashMap> _playerStatList = new NautHashMap>(); - public StatsManager(JavaPlugin plugin) { super("StatsManager", plugin); - + + _repository = new StatsRepository(plugin); + if (_saveRunnable == null) { _saveRunnable = new Runnable() @@ -47,199 +37,73 @@ public class StatsManager extends MiniPlugin } }; - plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, _saveRunnable, 200L, 200L); + plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, _saveRunnable, 100L, 100L); } } - public StatsManager addTable(String tableName, String...columns) + public void incrementStat(Player player, final String statName, int value) { - if (!_tables.containsKey(tableName)) - { - // Change - ColumnVarChar playerColumn = new ColumnVarChar("playerName", 16); - List> columnList = new ArrayList>(); - columnList.add(playerColumn); - - for (String column : columns) - { - columnList.add(new ColumnInt(column)); - } - - Table statTable = new Table(tableName, columnList, columnList, playerColumn); - statTable.initialize(); + Get(player).addStat(statName, Get(player).getStat(statName) + value); + + String uuidString = player.getUniqueId().toString(); - // Can't Arrays.asList here because of weird java generics - _tables.put(tableName, statTable); - } - - if (!_playerStatList.containsKey(tableName)) - { - _playerStatList.put(tableName, new NautHashMap()); - } - - return this; - } - - public void addStat(Player player, String table, String statName, int value) - { - // getName -> getUniqueId - addStat(player.getName(), table, statName, value); - } - - // playerName -> uuid - public void addStat(String playerName, String table, String statName, int value) - { - if (!_playerStatList.containsKey(table)) - { - System.out.println("Error adding stats for " + playerName + " on table " + table + " (" + statName + ", " + value + ") : TABLE DOES NOT EXIST!"); - return; - } - - if (!_playerStatList.get(table).containsKey(playerName)) - { - - Row row = _tables.get(table).createRow(); - - // bad playername! - ((ColumnVarChar)row.Columns.get("playerName")).Value = playerName; - - _playerStatList.get(table).put(playerName, row); - } - - _playerStatList.get(table).get(playerName).Columns.put(statName, new ColumnInt(statName, value)); - synchronized (_statSync) - { - if (!_statUploadQueue.containsKey(table)) + { + if (!_statUploadQueue.containsKey(uuidString)) { - _statUploadQueue.put(table, new NautHashMap()); + _statUploadQueue.put(uuidString, new NautHashMap()); } - _statUploadQueue.get(table).put(playerName, _playerStatList.get(table).get(playerName)); - } - } - - @EventHandler - public void clearPlayerStatsOnLeave(PlayerQuitEvent event) - { - for (String table : _playerStatList.keySet()) - _playerStatList.get(table).remove(event.getPlayer().getName()); - } - - @EventHandler - public void loadPlayerStats(final RetrieveClientInformationEvent event) - { - event.incrementProcessingCount(); - Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable() - { - public void run() + if (!_statUploadQueue.get(uuidString).containsKey(statName)) { - event.decreaseProcessingCount(); + _statUploadQueue.get(uuidString).put(statName, 0); } - }); - /* HA YOU THOUGHT I WAS GOING TO RUN DIDN'T YOU? */ - - if (true) - return; - - ResultSet resultSet = null; - PreparedStatement preparedStatement = null; - - for (Entry tableEntry : _tables.entrySet()) - { - Table table = tableEntry.getValue(); - String tableName = tableEntry.getKey(); - try + _statUploadQueue.get(uuidString).put(statName, _statUploadQueue.get(uuidString).get(statName) + value); + } + + // Verify stat is in our local cache, if not add it remotely. + if (!_stats.containsKey(statName)) + { + Bukkit.getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable() { - // playerName -> column name of UUID or uuid or UniqueID, whichever you choose - // and event.getPlayerName() is still in this event, but so is getUniqueId - List> columnList = new ArrayList>(); - columnList.add(new ColumnVarChar("playerUuid", 256, event.getUniqueId().toString())); - List rows = table.retrieve(columnList); - - // Same here. - Row row = table.createRow(); - ((ColumnVarChar)row.Columns.get("playerName")).Value = event.getPlayerName(); - - if (rows.size() > 0) + public void run() { - for (Column column : rows.get(0).Columns.values()) + synchronized (_statSync) { - row.Columns.put(column.Name, column); + _repository.addStat(statName); + _repository.retrieveStats(); } } - - _playerStatList.get(tableName).put(event.getPlayerName(), row); - } - catch (Exception exception) - { - exception.printStackTrace(); - } - finally - { - if (preparedStatement != null) - { - try - { - preparedStatement.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - - if (resultSet != null) - { - try - { - resultSet.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - } + }); } } - + protected void saveStats() { PreparedStatement preparedStatement = null; try { - NautHashMap> uploadQueue = new NautHashMap>(); + NautHashMap> uploadQueue = new NautHashMap>(); synchronized (_statSync) { for (String key : _statUploadQueue.keySet()) { - uploadQueue.put(key, new NautHashMap()); + uploadQueue.put(key, new NautHashMap()); - for (String stat : _statUploadQueue.get(key).keySet()) + for (String statName : _statUploadQueue.get(key).keySet()) { - uploadQueue.get(key).put(stat, _statUploadQueue.get(key).get(stat)); + int statId = _stats.get(statName); + uploadQueue.get(key).put(statId, _statUploadQueue.get(key).get(statName)); } } _statUploadQueue.clear(); } - for (String tableName : uploadQueue.keySet()) - { - for (Iterator> iterator = uploadQueue.get(tableName).entrySet().iterator(); iterator.hasNext();) - { - Entry entry = iterator.next(); - - if (!_tables.get(tableName).update(new ArrayList>(entry.getValue().Columns.values()), new ColumnVarChar("playerName", 16, entry.getKey()))) - _tables.get(tableName).insert(new ArrayList>(entry.getValue().Columns.values())); - - iterator.remove(); - } - } + _repository.saveStats(uploadQueue); } catch (Exception exception) { @@ -261,25 +125,23 @@ public class StatsManager extends MiniPlugin } } - public int getStat(Player player, String table, String stat) + @Override + protected PlayerStats AddPlayer(String player) { - return getStat(player.getName(), table, stat); + return new PlayerStats(); } - - public int getStat(String player, String table, String stat) + + @Override + protected void loadClientInformation(final RetrieveClientInformationEvent event) { - if (!_playerStatList.containsKey(table)) + event.incrementProcessingCount(); + Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable() { - System.out.println("STATS ERROR: Table doesn't exist (" + table + ")"); - return 0; - } - - if (!_playerStatList.get(table).containsKey(player)) - { - System.out.println("STATS ERROR: Player doesn't exist (" + player + ")"); - return 0; - } - - return ((ColumnInt)_playerStatList.get(table).get(player).Columns.get(stat)).Value; + public void run() + { + Set(event.getPlayerName(), _repository.loadClientInformation(event.getUniqueId().toString())); + event.decreaseProcessingCount(); + } + }); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java new file mode 100644 index 000000000..274c08232 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java @@ -0,0 +1,131 @@ +package mineplex.core.stats; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.common.util.NautHashMap; +import mineplex.core.database.RepositoryBase; +import mineplex.core.database.ResultSetCallable; +import mineplex.core.database.column.ColumnVarChar; + +public class StatsRepository extends RepositoryBase +{ + private static String CREATE_STAT_TABLE = "CREATE TABLE IF NOT EXISTS stats (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(100), PRIMARY KEY (id), INDEX nameIndex (name));"; + private static String CREATE_STAT_RELATION_TABLE = "CREATE TABLE IF NOT EXISTS accountStats (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id), UNIQUE INDEX accountStatIndex (accountId, statId));"; + + private static String RETRIEVE_PLAYER_STATS = "SELECT stats.name, value FROM accountStats INNER JOIN stats ON stats.id = accountStats.statId INNER JOIN accounts ON accountStats.accountId = accounts.id WHERE accounts.uuid = ?;"; + private static String INSERT_PLAYER_STAT = "INSERT INTO accountStats (accountId, statId, value) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.uuid = ? ON DUPLICATE KEY UPDATE value=VALUES(value);"; + + private static String RETRIEVE_STATS = "SELECT id, name FROM stats;"; + private static String INSERT_STAT = "INSERT INTO stats (name) VALUES (?);"; + + public StatsRepository(JavaPlugin plugin) + { + super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh"); + } + + @Override + protected void initialize() + { + executeUpdate(CREATE_STAT_TABLE); + executeUpdate(CREATE_STAT_RELATION_TABLE); + } + + @Override + protected void update() + { + } + + public List retrieveStats() + { + final List stats = new ArrayList(); + + executeQuery(RETRIEVE_STATS, new ResultSetCallable() + { + public void processResultSet(ResultSet resultSet) throws SQLException + { + while (resultSet.next()) + { + Stat stat = new Stat(); + + stat.Id = resultSet.getInt(1); + stat.Name = resultSet.getString(2); + + stats.add(stat); + } + } + }); + + return stats; + } + + public void addStat(String name) + { + executeUpdate(INSERT_STAT, new ColumnVarChar("name", 100, name)); + } + + public void saveStats(NautHashMap> uploadQueue) + { + PreparedStatement preparedStatement = null; + + try + { + preparedStatement = getConnection().prepareStatement(INSERT_PLAYER_STAT); + + for (String uuid : uploadQueue.keySet()) + { + for (Integer statId : uploadQueue.get(uuid).keySet()) + { + preparedStatement.setInt(1, statId); + preparedStatement.setInt(2, uploadQueue.get(uuid).get(statId)); + preparedStatement.setString(3, uuid); + + preparedStatement.addBatch(); + } + } + + preparedStatement.executeBatch(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + finally + { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + } + } + + public PlayerStats loadClientInformation(String uuid) + { + final PlayerStats playerStats = new PlayerStats(); + + executeQuery(RETRIEVE_PLAYER_STATS, new ResultSetCallable() + { + public void processResultSet(ResultSet resultSet) throws SQLException + { + while (resultSet.next()) + { + playerStats.addStat(resultSet.getString(1), resultSet.getInt(2)); + } + } + }, new ColumnVarChar("uuid", 100, uuid)); + + return playerStats; + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index e65d5966a..8dd6b4ba8 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -20,6 +20,7 @@ import mineplex.core.monitor.LagMeter; import mineplex.core.movement.Movement; import mineplex.core.npc.NpcManager; import mineplex.core.packethandler.PacketHandler; +import mineplex.core.pet.PetManager; import mineplex.core.playerTracker.PlayerTracker; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; @@ -34,7 +35,6 @@ import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; import mineplex.hub.modules.StackerManager; import mineplex.hub.party.PartyManager; -import mineplex.hub.pet.PetManager; import mineplex.hub.queue.QueueManager; import mineplex.hub.server.ServerManager; import mineplex.minecraft.game.classcombat.Class.ClassManager; @@ -68,7 +68,7 @@ public class Hub extends JavaPlugin implements IRelation Logger.initialize(this); //Static Modules - CommandCenter.Initialize(this); + CommandCenter.Initialize(this); CoreClientManager clientManager = new CoreClientManager(this, webServerAddress); CommandCenter.Instance.setClientManager(clientManager); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 8fba3e4c4..d2dd6b1fe 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -12,8 +12,11 @@ import org.bukkit.entity.Egg; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.Snowball; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; @@ -41,6 +44,8 @@ import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; @@ -52,8 +57,13 @@ import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.disguise.disguises.DisguiseSlime; import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetCollideEntityEvent; +import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.logger.Logger; +import mineplex.core.mount.MountManager; +import mineplex.core.pet.PetManager; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.stats.StatsManager; @@ -61,18 +71,15 @@ import mineplex.core.task.TaskManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.commands.ForcefieldRadius; -import mineplex.hub.commands.GadgetToggle; import mineplex.hub.commands.NewsCommand; -import mineplex.hub.gadget.GadgetManager; import mineplex.hub.modules.*; -import mineplex.hub.mount.MountManager; import mineplex.hub.party.Party; import mineplex.hub.party.PartyManager; -import mineplex.hub.pet.PetManager; import mineplex.hub.tutorial.TutorialManager; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent; import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class HubManager extends MiniClientPlugin { @@ -94,6 +101,7 @@ public class HubManager extends MiniClientPlugin private TextManager _textCreator; private ParkourManager _parkour; private PreferencesManager _preferences; + private InventoryManager _inventoryManager; private NewsManager _news; private Location _spawn; @@ -135,8 +143,9 @@ public class HubManager extends MiniClientPlugin _news = new NewsManager(this); - _mountManager = new MountManager(this); - _gadgetManager = new GadgetManager(this, _mountManager, petManager); + _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); _partyManager = partyManager; _preferences = preferences; @@ -284,7 +293,6 @@ public class HubManager extends MiniClientPlugin @Override public void AddCommands() { - AddCommand(new GadgetToggle(this)); AddCommand(new NewsCommand(this)); } @@ -310,6 +318,50 @@ public class HubManager extends MiniClientPlugin return true; } + + @EventHandler + public void SnowballPickup(BlockDamageEvent event) + { + if (!Mode.equals("Christmas")) + return; + + if (event.getBlock().getType() != Material.SNOW) + return; + + Player player = event.getPlayer(); + + _gadgetManager.RemoveItem(player); + + player.getInventory().setItem(3, new ItemStack(Material.SNOW_BALL, 16)); + } + + @EventHandler + public void SnowballHit(CustomDamageEvent event) + { + if (!Mode.equals("Christmas")) + return; + + Projectile proj = event.GetProjectile(); + if (proj == null) return; + + if (!(proj instanceof Snowball)) + return; + + event.SetCancelled("Snowball Cancel"); + + if (BumpDisabled(event.GetDamageeEntity())) + return; + + if (BumpDisabled(event.GetDamagerEntity(true))) + return; + + UtilAction.velocity(event.GetDamageeEntity(), UtilAlg.getTrajectory2d(event.GetDamagerEntity(true), event.GetDamageeEntity()), + 0.4, false, 0, 0.2, 1, false); + + //No Portal + SetPortalDelay(event.GetDamageeEntity()); + } + @EventHandler public void redirectStopCommand(PlayerCommandPreprocessEvent event) { @@ -811,6 +863,13 @@ public class HubManager extends MiniClientPlugin { return _visibilityManager; } + + @EventHandler(priority = EventPriority.MONITOR) + public void gadgetCollide(GadgetCollideEntityEvent event) + { + if (!event.isCancelled()) + SetPortalDelay(event.getOther()); + } public void SetPortalDelay(Entity ent) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GadgetToggle.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GadgetToggle.java deleted file mode 100644 index 32220b46a..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GadgetToggle.java +++ /dev/null @@ -1,33 +0,0 @@ -package mineplex.hub.commands; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.hub.HubManager; - -public class GadgetToggle extends CommandBase -{ - public GadgetToggle(HubManager plugin) - { - super(plugin, Rank.ADMIN, new String[] {"gadget"}); - } - - @Override - public void Execute(Player caller, String[] args) - { - Plugin.SetGadgetEnabled(!Plugin.IsGadgetEnabled()); - - //Disable - if (!Plugin.IsGadgetEnabled()) - { - Plugin.GetGadget().DisableAll(); - Plugin.GetMount().DisableAll(); - } - - UtilPlayer.message(caller, C.Bold + "Gadgets: " + F.tf(Plugin.IsGadgetEnabled())); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java deleted file mode 100644 index 07d32ff02..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java +++ /dev/null @@ -1,215 +0,0 @@ -package mineplex.hub.gadget; - -import java.util.HashSet; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.entity.Snowball; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.BlockDamageEvent; -import org.bukkit.event.player.PlayerDropItemEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.MiniPlugin; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.hub.HubManager; -import mineplex.hub.gadget.gadgets.*; -import mineplex.hub.gadget.types.MorphGadget; -import mineplex.hub.gadget.types.MorphGadget.ArmorSlot; -import mineplex.hub.gadget.types.Gadget; -import mineplex.hub.gadget.types.ItemGadget; -import mineplex.hub.gadget.ui.GadgetShop; -import mineplex.hub.mount.MountManager; -import mineplex.hub.pet.PetManager; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; - -public class GadgetManager extends MiniPlugin -{ - public HubManager Manager; - private GadgetShop _gadgetShop; - private PetManager _petManager; - - private HashSet _gadgets; - - public GadgetManager(HubManager manager, MountManager mountManager, PetManager petManager) - { - super("Gadget Manager", manager.GetPlugin()); - - Manager = manager; - _petManager = petManager; - - CreateGadgets(); - - _gadgetShop = new GadgetShop(this, mountManager, Manager.GetClients(), Manager.GetDonation()); - } - - private void CreateGadgets() - { - _gadgets = new HashSet(); - - //Items - _gadgets.add(new ItemPaintballGun(this)); - _gadgets.add(new ItemBatGun(this)); - _gadgets.add(new ItemGemBomb(this)); - _gadgets.add(new ItemFirework(this)); - _gadgets.add(new ItemTNT(this)); - - //Morphs - _gadgets.add(new MorphBlaze(this)); - _gadgets.add(new MorphPumpkinKing(this)); - } - - @EventHandler - public void onPlayerJoin(PlayerJoinEvent event) - { - event.getPlayer().getInventory().setItem(4, ItemStackFactory.Instance.CreateStack(Material.CHEST, (byte)0, 1, ChatColor.RESET + C.cGreen + "Gadget Menu")); - - if (Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.MODERATOR)) - { - for (Gadget gadget : _gadgets) - { - Manager.GetDonation().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(gadget.GetName()); - } - } - } - - @EventHandler - public void orderThatChest(final PlayerDropItemEvent event) - { - 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 + "Gadget Menu")); - event.getPlayer().updateInventory(); - } - } - }); - } - } - - @EventHandler - public void openShop(PlayerInteractEvent event) - { - if (event.hasItem() && event.getItem().getType() == Material.CHEST) - { - event.setCancelled(true); - - if (!Manager.IsGadgetEnabled()) - { - UtilPlayer.message(event.getPlayer(), F.main("Gadget", "Gadgets are currently disabled.")); - return; - } - - _gadgetShop.attemptShopOpen(event.getPlayer()); - - } - } - - public HashSet getGadgets() - { - return _gadgets; - } - - //Disallows two armor gadgets in same slot. - public void RemoveArmor(Player player, ArmorSlot slot) - { - for (Gadget gadget : _gadgets) - { - if (gadget instanceof MorphGadget) - { - MorphGadget armor = (MorphGadget)gadget; - - if (armor.GetSlot() == slot) - { - armor.RemoveArmor(player); - } - } - } - } - - public void RemoveItem(Player player) - { - for (Gadget gadget : _gadgets) - { - if (gadget instanceof ItemGadget) - { - ItemGadget item = (ItemGadget)gadget; - - item.RemoveItem(player); - } - } - } - - @EventHandler - public void SnowballPickup(BlockDamageEvent event) - { - if (!Manager.Mode.equals("Christmas")) - return; - - if (event.getBlock().getType() != Material.SNOW) - return; - - Player player = event.getPlayer(); - - RemoveItem(player); - - player.getInventory().setItem(3, new ItemStack(Material.SNOW_BALL, 16)); - } - - @EventHandler - public void SnowballHit(CustomDamageEvent event) - { - if (!Manager.Mode.equals("Christmas")) - return; - - Projectile proj = event.GetProjectile(); - if (proj == null) return; - - if (!(proj instanceof Snowball)) - return; - - event.SetCancelled("Snowball Cancel"); - - if (Manager.BumpDisabled(event.GetDamageeEntity())) - return; - - if (Manager.BumpDisabled(event.GetDamagerEntity(true))) - return; - - UtilAction.velocity(event.GetDamageeEntity(), UtilAlg.getTrajectory2d(event.GetDamagerEntity(true), event.GetDamageeEntity()), - 0.4, false, 0, 0.2, 1, false); - - //No Portal - Manager.SetPortalDelay(event.GetDamageeEntity()); - } - - public void DisableAll() - { - for (Gadget gadget : _gadgets) - for (Player player : UtilServer.getPlayers()) - gadget.Disable(player); - } - - public PetManager getPetManager() - { - return _petManager; - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivateMountButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivateMountButton.java deleted file mode 100644 index f5045f925..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivateMountButton.java +++ /dev/null @@ -1,31 +0,0 @@ -package mineplex.hub.gadget.ui; - -import org.bukkit.entity.Player; - -import mineplex.core.shop.item.IButton; -import mineplex.hub.mount.HorseMount; -import mineplex.hub.mount.Mount; - -public class ActivateMountButton implements IButton -{ - private Mount _mount; - private GadgetPage _page; - - public ActivateMountButton(Mount mount, GadgetPage page) - { - _mount = mount; - _page = page; - } - - @Override - public void ClickedLeft(Player player) - { - _page.ActivateMount(player, _mount); - } - - @Override - public void ClickedRight(Player player) - { - _page.ActivateMount(player, _mount); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivateGadgetButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivateGadgetButton.java deleted file mode 100644 index c60c23c6e..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivateGadgetButton.java +++ /dev/null @@ -1,30 +0,0 @@ -package mineplex.hub.gadget.ui; - -import org.bukkit.entity.Player; - -import mineplex.core.shop.item.IButton; -import mineplex.hub.gadget.types.Gadget; - -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.DeactivateGadget(player, _gadget); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivateMountButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivateMountButton.java deleted file mode 100644 index ff5a8dc15..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivateMountButton.java +++ /dev/null @@ -1,31 +0,0 @@ -package mineplex.hub.gadget.ui; - -import org.bukkit.entity.Player; - -import mineplex.core.shop.item.IButton; -import mineplex.hub.mount.HorseMount; -import mineplex.hub.mount.Mount; - -public class DeactivateMountButton implements IButton -{ - private Mount _mount; - private GadgetPage _page; - - public DeactivateMountButton(Mount mount, GadgetPage page) - { - _mount = mount; - _page = page; - } - - @Override - public void ClickedLeft(Player player) - { - _page.DeactivateMount(player, _mount); - } - - @Override - public void ClickedRight(Player player) - { - _page.DeactivateMount(player, _mount); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivatePetButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivatePetButton.java deleted file mode 100644 index e239db948..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivatePetButton.java +++ /dev/null @@ -1,30 +0,0 @@ -package mineplex.hub.gadget.ui; - -import org.bukkit.entity.Player; - -import mineplex.hub.pet.Pet; -import mineplex.core.shop.item.IButton; - -public class DeactivatePetButton implements IButton -{ - private Pet _pet; - private GadgetPage _page; - - public DeactivatePetButton(Pet pet, GadgetPage page) - { - _pet = pet; - _page = page; - } - - @Override - public void ClickedLeft(Player player) - { - _page.DeactivatePet(player); - } - - @Override - public void ClickedRight(Player player) - { - _page.DeactivatePet(player); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetPage.java deleted file mode 100644 index cb46e8528..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetPage.java +++ /dev/null @@ -1,315 +0,0 @@ -package mineplex.hub.gadget.ui; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import net.minecraft.server.v1_7_R3.EntityPlayer; -import net.minecraft.server.v1_7_R3.Items; -import net.minecraft.server.v1_7_R3.PacketPlayOutOpenWindow; -import net.minecraft.server.v1_7_R3.PacketPlayOutSetSlot; - -import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer; -import org.bukkit.entity.Creature; -import org.bukkit.entity.Player; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; -import mineplex.core.common.util.C; -import mineplex.core.donation.DonationManager; -import mineplex.core.shop.item.ShopItem; -import mineplex.core.shop.page.AnvilContainer; -import mineplex.core.shop.page.ConfirmationPage; -import mineplex.core.shop.page.ShopPageBase; -import mineplex.hub.gadget.GadgetManager; -import mineplex.hub.gadget.types.MorphGadget; -import mineplex.hub.gadget.types.Gadget; -import mineplex.hub.gadget.types.ItemGadget; -import mineplex.hub.mount.Mount; -import mineplex.hub.mount.MountManager; -import mineplex.hub.pet.Pet; -import mineplex.hub.pet.PetExtra; -import mineplex.hub.gadget.ui.DeactivatePetButton; -import mineplex.hub.gadget.ui.PetButton; -import mineplex.hub.gadget.ui.PetSorter; -import mineplex.hub.gadget.ui.RenamePetButton; - -public class GadgetPage extends ShopPageBase -{ - private MountManager _mountPlugin; - - public GadgetPage(GadgetManager plugin, GadgetShop shop, MountManager mountPlugin, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) - { - super(plugin, shop, clientManager, donationManager, name, player, 54); - - _mountPlugin = mountPlugin; - - BuildPage(); - } - - protected void BuildPage() - { - int activeSlot = 2; - int headSlot = 11; - int mountSlot = 20; - - setItem(0, new ShopItem(Material.IRON_SWORD, (byte)0, "Gadgets", new String[] {}, 1, false, false)); - setItem(9, new ShopItem(Material.SKULL_ITEM, (byte)0, "Hub Morphs", new String[] {}, 1, false, false)); - setItem(18, new ShopItem(Material.DIAMOND_BARDING, (byte)0, "Hub Mounts", new String[] {}, 1, false, false)); - - for (Gadget gadget : Plugin.getGadgets()) - { - int slot = 0; - - if (gadget instanceof MorphGadget) - { - switch (((MorphGadget)gadget).GetSlot()) - { - case Helmet: - slot = headSlot; - headSlot++; - break; - default: - break; - } - } - else if (gadget instanceof ItemGadget) - { - slot = activeSlot; - activeSlot++; - } - - addGadget(gadget, slot); - } - - for (Mount mount : _mountPlugin.getMounts()) - { - int slot = mountSlot; - mountSlot++; - - addMount(mount, slot); - } - - int slot = 38; - - List pets = new ArrayList(Plugin.getPetManager().GetFactory().GetPets()); - - Collections.sort(pets, new PetSorter()); - - for (Pet pet : pets) - { - List itemLore = new ArrayList(); - - itemLore.add(C.cYellow + pet.GetCost(CurrencyType.Gems) + " Gems"); - itemLore.add(C.cBlack); - - if (DonationManager.Get(Player.getName()).OwnsUnknownPackage(pet.GetPetName())) - { - if (Plugin.getPetManager().hasActivePet(Player.getName()) && Plugin.getPetManager().getActivePet(Player.getName()).getType() == pet.GetPetType()) - { - AddButton(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), "Deactivate " + Plugin.getPetManager().Get(Player).GetPets().get(pet.GetPetType()), new String[] {}, 1, false, false), new DeactivatePetButton(pet, this)); - } - else - { - AddButton(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), "Activate " + Plugin.getPetManager().Get(Player).GetPets().get(pet.GetPetType()), new String[] {}, 1, false, false), new ActivatePetButton(pet, this)); - } - } - else - { - if (DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Gems) >= pet.GetCost(CurrencyType.Gems)) - AddButton(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), "Purchase " + pet.GetPetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new PetButton(pet, this)); - else - setItem(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), "Purchase " + pet.GetPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); - } - - slot++; - } - - slot = 36; - for (PetExtra petExtra : Plugin.getPetManager().GetFactory().GetPetExtras()) - { - List itemLore = new ArrayList(); - - if (!Plugin.getPetManager().hasActivePet(Player.getName())) - { - itemLore.add(C.cWhite + "You must have an active pet to use this!"); - getInventory().setItem(slot, new ShopItem(petExtra.GetMaterial(), (byte)0, C.cRed + petExtra.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).getHandle()); - } - else - { - AddButton(slot, new ShopItem(petExtra.GetMaterial(), (byte)0, "Rename " + Plugin.getPetManager().getActivePet(Player.getName()).getCustomName() + " for " + C.cYellow + petExtra.GetCost(CurrencyType.Gems) + C.cGreen + " Gems", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this)); - } - - slot++; - } - } - - protected void addGadget(Gadget gadget, int slot) - { - List itemLore = new ArrayList(); - - if (gadget.GetCost(CurrencyType.Gems) != -1) - { - itemLore.add(C.cYellow + gadget.GetCost(CurrencyType.Gems) + " Gems"); - } - if (gadget instanceof ItemGadget) - { - 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.cBlack); - itemLore.addAll(Arrays.asList(gadget.GetDescription())); - - if (gadget.IsFree() || DonationManager.Get(Player.getName()).OwnsUnknownPackage(gadget.GetName())) - { - if (gadget.GetActive().contains(Player)) - { - AddButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), "Deactivate " + gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new DeactivateGadgetButton(gadget, this)); - } - else - { - AddButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), "Activate " + gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new ActivateGadgetButton(gadget, this)); - } - } - else - { - if (gadget.GetCost(CurrencyType.Gems) != -1 && DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Gems) >= gadget.GetCost(CurrencyType.Gems)) - AddButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), "Purchase " + gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new GadgetButton(gadget, this)); - else - setItem(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), "Purchase " + gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); - } - } - - protected void addMount(Mount mount, int slot) - { - List itemLore = new ArrayList(); - - if (mount.GetCost(CurrencyType.Gems) != -1) - { - itemLore.add(C.cYellow + mount.GetCost(CurrencyType.Gems) + " Gems"); - } - - itemLore.add(C.cBlack); - itemLore.addAll(Arrays.asList(mount.GetDescription())); - - if (DonationManager.Get(Player.getName()).OwnsUnknownPackage(mount.GetName())) - { - if (mount.GetActive().containsKey(Player)) - { - AddButton(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), "Deactivate " + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new DeactivateMountButton(mount, this)); - } - else - { - AddButton(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), "Activate " + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new ActivateMountButton(mount, this)); - } - } - else - { - if (mount.GetCost(CurrencyType.Gems) != -1 && DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Gems) >= mount.GetCost(CurrencyType.Gems)) - AddButton(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), "Purchase " + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new MountButton(mount, this)); - else - setItem(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), "Purchase " + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); - } - } - - public void PurchaseGadget(final Player player, final Gadget gadget) - { - Shop.OpenPageForPlayer(Player, new ConfirmationPage(Plugin, Shop, ClientManager, DonationManager, new Runnable() - { - public void run() - { - Player.closeInventory(); - } - }, null, gadget, CurrencyType.Gems, Player)); - } - - public void ActivateGadget(Player player, Gadget gadget) - { - PlayAcceptSound(player); - gadget.Enable(player); - Player.closeInventory(); - } - - public void DeactivateGadget(Player player, Gadget gadget) - { - PlayAcceptSound(player); - gadget.Disable(player); - Player.closeInventory(); - } - - public void PurchaseMount(final Player player, final Mount _mount) - { - Shop.OpenPageForPlayer(Player, new ConfirmationPage(Plugin, Shop, ClientManager, DonationManager, new Runnable() - { - public void run() - { - Player.closeInventory(); - } - }, null, _mount, CurrencyType.Gems, Player)); - } - - public void ActivateMount(Player player, Mount _mount) - { - PlayAcceptSound(player); - _mount.Enable(player); - Player.closeInventory(); - } - - public void DeactivateMount(Player player, Mount _mount) - { - PlayAcceptSound(player); - _mount.Disable(player); - Player.closeInventory(); - } - - public void PurchasePet(final Player player, final Pet pet) - { - renamePet(player, pet, true); - } - - public void renameCurrentPet(Player player) - { - PlayAcceptSound(player); - Creature currentPet = Plugin.getPetManager().getActivePet(player.getName()); - renamePet(player, new Pet(currentPet.getCustomName(), currentPet.getType(), 1), false); - } - - public void renamePet(Player player, Pet pet, boolean petPurchase) - { - PlayAcceptSound(player); - - PetTagPage petTagPage = new PetTagPage(Plugin, Shop, ClientManager, DonationManager, "Repairing", Player, pet, petPurchase); - EntityPlayer entityPlayer = ((CraftPlayer)Player).getHandle(); - int containerCounter = entityPlayer.nextContainerCounter(); - entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(containerCounter, 8, "Repairing", 9, true)); - entityPlayer.activeContainer = new AnvilContainer(entityPlayer.inventory, petTagPage.getInventory()); - entityPlayer.activeContainer.windowId = containerCounter; - entityPlayer.activeContainer.addSlotListener(entityPlayer); - entityPlayer.playerConnection.sendPacket(new PacketPlayOutSetSlot(containerCounter, 0, new net.minecraft.server.v1_7_R3.ItemStack(Items.NAME_TAG))); - - Shop.SetCurrentPageForPlayer(Player, petTagPage); - } - - public void ActivatePet(Player player, Pet pet) - { - PlayAcceptSound(player); - Plugin.getPetManager().AddPetOwner(player, pet.GetPetType(), player.getLocation()); - Player.closeInventory(); - } - - public void DeactivatePet(Player player) - { - PlayAcceptSound(player); - Plugin.getPetManager().RemovePet(player, true); - Player.closeInventory(); - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/MountButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/MountButton.java deleted file mode 100644 index 7483a08ef..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/MountButton.java +++ /dev/null @@ -1,31 +0,0 @@ -package mineplex.hub.gadget.ui; - -import org.bukkit.entity.Player; - -import mineplex.core.shop.item.IButton; -import mineplex.hub.mount.HorseMount; -import mineplex.hub.mount.Mount; - -public class MountButton implements IButton -{ - private Mount _mount; - private GadgetPage _page; - - public MountButton(Mount mount, GadgetPage page) - { - _mount = mount; - _page = page; - } - - @Override - public void ClickedLeft(Player player) - { - _page.PurchaseMount(player, _mount); - } - - @Override - public void ClickedRight(Player player) - { - _page.PurchaseMount(player, _mount); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java index 6d67b4986..c121ae83a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java @@ -17,12 +17,12 @@ import mineplex.core.common.util.UtilDisplay; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; +import mineplex.core.mount.Mount; +import mineplex.core.mount.types.Dragon; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.HubManager; import mineplex.hub.HubRepository; -import mineplex.hub.mount.Mount; -import mineplex.hub.mount.types.Dragon; public class NewsManager extends MiniPlugin { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java index e3bdabf2d..ff0e12b32 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java @@ -335,7 +335,7 @@ public class Christmas extends SoloGame { for (Player player : GetPlayers(false)) { - Manager.GetDonation().PurchaseUnknownSalesPackage(null, player.getName(), "Snowmans Head", 0, true); + Manager.GetDonation().PurchaseUnknownSalesPackage(null, player.getName(), "Snowmans Head", false, 0, true); Manager.GetGame().AddGems(player, 30, "Slaying the Pumpkin King", false); Manager.GetGame().AddGems(player, 10, "Participation", false); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java index 7f1175710..c9faebf76 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java @@ -316,7 +316,7 @@ public class Halloween extends SoloGame { for (Player player : GetPlayers(false)) { - Manager.GetDonation().PurchaseUnknownSalesPackage(null, player.getName(), "Pumpkin Kings Head", 0, true); + Manager.GetDonation().PurchaseUnknownSalesPackage(null, player.getName(), "Pumpkin Kings Head", false, 0, true); Manager.GetGame().AddGems(player, 30, "Killing the Pumpkin King", false); Manager.GetGame().AddGems(player, 10, "Participation", false); } diff --git a/Website/LOC.Core/Model/Account/Account.cs b/Website/LOC.Core/Model/Account/Account.cs index 4f99c5a1a..8662a770e 100644 --- a/Website/LOC.Core/Model/Account/Account.cs +++ b/Website/LOC.Core/Model/Account/Account.cs @@ -33,6 +33,7 @@ public bool FilterChat { get; set; } public int Gems { get; set; } + public int Coins { get; set; } public bool Donated { get; set; } public DateTime LastVote { get; set; } diff --git a/Website/LOC.Core/Model/Sales/AccountTransaction.cs b/Website/LOC.Core/Model/Sales/AccountTransaction.cs index 88683e320..bf036eab2 100644 --- a/Website/LOC.Core/Model/Sales/AccountTransaction.cs +++ b/Website/LOC.Core/Model/Sales/AccountTransaction.cs @@ -9,5 +9,7 @@ public string SalesPackageName { get; set; } public int Gems { get; set; } + + public int Coins { get; set; } } } diff --git a/Website/LOC.Core/Tokens/Client/ClientToken.cs b/Website/LOC.Core/Tokens/Client/ClientToken.cs index 2fd313543..00070d053 100644 --- a/Website/LOC.Core/Tokens/Client/ClientToken.cs +++ b/Website/LOC.Core/Tokens/Client/ClientToken.cs @@ -38,6 +38,7 @@ DonorToken = new DonorToken { Gems = account.Gems, + Coins = account.Coins, Donated = account.Donated, SalesPackages = new List(), UnknownSalesPackages = new List(), diff --git a/Website/LOC.Core/Tokens/Client/DonorToken.cs b/Website/LOC.Core/Tokens/Client/DonorToken.cs index 3f58af7f7..e2c168907 100644 --- a/Website/LOC.Core/Tokens/Client/DonorToken.cs +++ b/Website/LOC.Core/Tokens/Client/DonorToken.cs @@ -5,6 +5,7 @@ public class DonorToken { public int Gems { get; set; } + public int Coins { get; set; } public bool Donated { get; set; } public List SalesPackages { get; set; } public List UnknownSalesPackages { get; set; } diff --git a/Website/LOC.Core/Tokens/UnknownPurchaseToken.cs b/Website/LOC.Core/Tokens/UnknownPurchaseToken.cs index a8cee6445..d4beb255e 100644 --- a/Website/LOC.Core/Tokens/UnknownPurchaseToken.cs +++ b/Website/LOC.Core/Tokens/UnknownPurchaseToken.cs @@ -6,6 +6,8 @@ public string SalesPackageName { get; set; } + public bool CoinPurchase { get; set; } + public int Cost { get; set; } } } diff --git a/Website/LOC.Website.Common/Models/AccountAdministrator.cs b/Website/LOC.Website.Common/Models/AccountAdministrator.cs index 9dfd7d5f8..83a4c7760 100644 --- a/Website/LOC.Website.Common/Models/AccountAdministrator.cs +++ b/Website/LOC.Website.Common/Models/AccountAdministrator.cs @@ -146,6 +146,7 @@ var account = repository.Add(new Account { Gems = 1200, + Coins = 0, Name = name, Rank = repository.Where(x => x.RankId == 1).First(), LastVote = DateTime.Today.Subtract(TimeSpan.FromDays(5)), @@ -463,14 +464,15 @@ if (account == null) return TransactionResponse.Failed.ToString(); - if (account.Gems < token.Cost) + if (token.CoinPurchase ? account.Coins < token.Cost : account.Gems < token.Cost) return TransactionResponse.InsufficientFunds.ToString(); var accountTransaction = new AccountTransaction { Account = account, SalesPackageName = token.SalesPackageName, - Gems = token.Cost, + Gems = token.CoinPurchase ? 0 : token.Cost, + Coins = token.CoinPurchase ? token.Cost : 0 }; repository.Attach(account); @@ -483,8 +485,10 @@ account.AccountTransactions.Add(accountTransaction); } - account.Gems -= token.Cost; - + if (token.CoinPurchase) + account.Coins -= token.Cost; + else + account.Gems -= token.Cost; repository.CommitChanges(); @@ -603,6 +607,7 @@ Uuid = loginToken.Uuid, Rank = repository.Where(x => x.RankId == 1).First(), Gems = 0, + Coins = 0, Transactions = new List(), PvpTransactions = new List(), IpAddresses = new List(), diff --git a/Website/LOCWebsite.suo b/Website/LOCWebsite.suo index 6f1b215ac..9309867d0 100644 Binary files a/Website/LOCWebsite.suo and b/Website/LOCWebsite.suo differ