Added coins Currency to web api
Added coins purchase for all cosmetic items Added Stats manager Added Inventory Manager Redesigned gadgets/morph/particle/pets/mounts page and inventory.
This commit is contained in:
parent
7408afa697
commit
6d86f403ac
@ -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;
|
||||
}
|
||||
}
|
@ -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)
|
||||
{
|
||||
|
@ -149,42 +149,37 @@ 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())
|
||||
{
|
||||
try
|
||||
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.stats;
|
||||
package mineplex.core.database;
|
||||
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.database.column.Column;
|
@ -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
|
||||
{
|
||||
|
@ -73,7 +73,7 @@ public class DonationManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public void PurchaseUnknownSalesPackage(final Callback<TransactionResponse> callback, final String name, final String packageName, final int gemCost, boolean oneTimePurchase)
|
||||
public void PurchaseUnknownSalesPackage(final Callback<TransactionResponse> 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<TransactionResponse> callback, final String name, final int salesPackageId)
|
||||
|
@ -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<Integer> _salesPackagesOwned;
|
||||
private List<String> _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;
|
||||
}
|
||||
}
|
||||
|
@ -26,12 +26,13 @@ public class DonationRepository
|
||||
new AsyncJsonWebCall(_webAddress + "PlayerAccount/PurchaseKnownSalesPackage").Execute(TransactionResponse.class, callback, token);
|
||||
}
|
||||
|
||||
public void PurchaseUnknownSalesPackage(Callback<TransactionResponse> callback, String name, String packageName, int gemCost)
|
||||
public void PurchaseUnknownSalesPackage(Callback<TransactionResponse> 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);
|
||||
|
@ -8,4 +8,5 @@ public class DonorToken
|
||||
public boolean Donated;
|
||||
public List<Integer> SalesPackages;
|
||||
public List<String> UnknownSalesPackages;
|
||||
public int Coins;
|
||||
}
|
||||
|
@ -6,4 +6,5 @@ public class UnknownPurchaseToken
|
||||
public String SalesPackageName;
|
||||
public int Cost;
|
||||
public boolean Premium;
|
||||
public boolean CoinPurchase;
|
||||
}
|
||||
|
@ -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<Gadget> _gadgets;
|
||||
|
||||
private NautHashMap<Player, NautHashMap<GadgetType, Gadget>> _playerActiveGadgetMap = new NautHashMap<Player, NautHashMap<GadgetType, Gadget>>();
|
||||
|
||||
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<Gadget>();
|
||||
|
||||
//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<Gadget> 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<Gadget> 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<GadgetType, Gadget>());
|
||||
|
||||
_playerActiveGadgetMap.get(player).put(gadget.getGadgetType(), gadget);
|
||||
}
|
||||
|
||||
public Gadget getActive(Player player, GadgetType gadgetType)
|
||||
{
|
||||
if (!_playerActiveGadgetMap.containsKey(player))
|
||||
_playerActiveGadgetMap.put(player, new NautHashMap<GadgetType, Gadget>());
|
||||
|
||||
return _playerActiveGadgetMap.get(player).get(gadgetType);
|
||||
}
|
||||
|
||||
public void removeActive(Player player, Gadget gadget)
|
||||
{
|
||||
if (!_playerActiveGadgetMap.containsKey(player))
|
||||
_playerActiveGadgetMap.put(player, new NautHashMap<GadgetType, Gadget>());
|
||||
|
||||
_playerActiveGadgetMap.get(player).remove(gadget.getGadgetType());
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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<Block> _blocks;
|
||||
|
||||
private boolean _cancelled = false;
|
||||
|
||||
public GadgetBlockEvent(Gadget gadget, List<Block> blocks)
|
||||
{
|
||||
_gadget = gadget;
|
||||
_blocks = blocks;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public Gadget getGadget()
|
||||
{
|
||||
return _gadget;
|
||||
}
|
||||
|
||||
public List<Block> getBlocks()
|
||||
{
|
||||
return _blocks;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancel)
|
||||
{
|
||||
_cancelled = cancel;
|
||||
}
|
||||
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return _cancelled;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
@ -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);
|
||||
|
@ -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<Block> blocks = new ArrayList<Block>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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<Player, Double> 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);
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
*/
|
||||
}
|
@ -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<Player> _active = new HashSet<Player>();
|
||||
|
||||
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<Player> 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)
|
@ -0,0 +1,7 @@
|
||||
package mineplex.core.gadget.types;
|
||||
|
||||
public enum GadgetType
|
||||
{
|
||||
Item,
|
||||
Morph,
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package mineplex.hub.gadget.types;
|
||||
package mineplex.core.gadget.types;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
@ -10,33 +10,43 @@ 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<Player> GetActive()
|
||||
{
|
||||
return _active;
|
||||
@ -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
|
||||
{
|
@ -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;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package mineplex.core.inventory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ClientInventory
|
||||
{
|
||||
public List<ClientItem> Items = new ArrayList<ClientItem>();
|
||||
|
||||
public int getChestCount()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package mineplex.core.inventory;
|
||||
|
||||
import mineplex.core.inventory.data.Item;
|
||||
|
||||
public class ClientItem
|
||||
{
|
||||
public Item Item;
|
||||
public int Count;
|
||||
}
|
@ -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<ClientInventory>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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<Category> retrieveCategories()
|
||||
{
|
||||
final List<Category> categories = new ArrayList<Category>();
|
||||
|
||||
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<Item> retrieveItems()
|
||||
{
|
||||
final List<Item> items = new ArrayList<Item>();
|
||||
|
||||
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<String, List<ClientItem>> 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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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<GadgetManager> implements PluginMessageListener
|
||||
public class InventoryShop extends ShopBase<InventoryManager> implements PluginMessageListener
|
||||
{
|
||||
private MountManager _mountManager;
|
||||
public InventoryShop(InventoryManager plugin, CoreClientManager clientManager, DonationManager donationManager, String name)
|
||||
{
|
||||
super(plugin, clientManager, donationManager, name, CurrencyType.Gems, CurrencyType.Coins);
|
||||
|
||||
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);
|
||||
}
|
||||
plugin.GetPlugin().getServer().getMessenger().registerIncomingPluginChannel(plugin.GetPlugin(), "MC|ItemName", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ShopPageBase<GadgetManager, ? extends ShopBase<GadgetManager>> BuildPagesFor(Player player)
|
||||
protected ShopPageBase<InventoryManager, ? extends ShopBase<InventoryManager>> BuildPagesFor(Player player)
|
||||
{
|
||||
return new GadgetPage(Plugin, this, _mountManager, ClientManager, DonationManager, " Gadgets", player);
|
||||
return new Menu(Plugin, this, ClientManager, DonationManager, player);
|
||||
}
|
||||
|
||||
@Override
|
@ -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<Pet>
|
||||
{
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package mineplex.hub.gadget.ui;
|
||||
package mineplex.core.inventory.ui.button;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
@ -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
|
||||
{
|
@ -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<InventoryManager, InventoryShop>
|
||||
{
|
||||
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<String> itemLore = new ArrayList<String>();
|
||||
|
||||
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<InventoryManager, InventoryShop>(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);
|
||||
}
|
||||
}
|
@ -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<InventoryManager, InventoryShop>
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
@ -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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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<InventoryManager, InventoryShop>
|
||||
{
|
||||
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<String> itemLore = new ArrayList<String>();
|
||||
|
||||
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<InventoryManager, InventoryShop>(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));
|
||||
}
|
||||
}
|
@ -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++;
|
||||
}
|
||||
}
|
||||
}
|
@ -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<InventoryManager, InventoryShop>
|
||||
{
|
||||
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<Pet> pets = new ArrayList<Pet>(Plugin.getPetManager().GetFactory().GetPets());
|
||||
|
||||
Collections.sort(pets, new PetSorter());
|
||||
|
||||
for (Pet pet : pets)
|
||||
{
|
||||
List<String> itemLore = new ArrayList<String>();
|
||||
|
||||
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<String> itemLore = new ArrayList<String>();
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
@ -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<GadgetManager, GadgetShop>
|
||||
public class PetTagPage extends ShopPageBase<InventoryManager, InventoryShop>
|
||||
{
|
||||
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<GadgetManager, GadgetShop>
|
||||
|
||||
_pet.setDisplayName(C.cGreen + "Purchase " + _tagName);
|
||||
|
||||
Shop.OpenPageForPlayer(Player, new ConfirmationPage<GadgetManager, GadgetShop>(Plugin, Shop, ClientManager, DonationManager, new Runnable()
|
||||
Shop.OpenPageForPlayer(Player, new ConfirmationPage<InventoryManager, InventoryShop>(Plugin, Shop, ClientManager, DonationManager, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package mineplex.hub.mount;
|
||||
package mineplex.core.mount;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
@ -1,4 +1,4 @@
|
||||
package mineplex.hub.mount;
|
||||
package mineplex.core.mount;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
@ -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<Horse>
|
||||
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<Horse>
|
||||
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);
|
||||
|
@ -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<T> extends SalesPackageBase implements Listener
|
||||
@ -37,12 +35,7 @@ public abstract class Mount<T> 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);
|
@ -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<Mount<?>> _types;
|
||||
private NautHashMap<Player, Mount<?>> _playerActiveMountMap = new NautHashMap<Player, Mount<?>>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
@ -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
|
||||
{
|
@ -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;
|
@ -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
|
||||
{
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -1,4 +1,4 @@
|
||||
package mineplex.hub.pet.event;
|
||||
package mineplex.core.pet.event;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
@ -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
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package mineplex.hub.pet.repository.token;
|
||||
package mineplex.core.pet.repository.token;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package mineplex.hub.pet.repository.token;
|
||||
package mineplex.core.pet.repository.token;
|
||||
|
||||
public class ClientPetTokenWrapper
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package mineplex.hub.pet.repository.token;
|
||||
package mineplex.core.pet.repository.token;
|
||||
|
||||
public class PetChangeToken
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package mineplex.hub.pet.repository.token;
|
||||
package mineplex.core.pet.repository.token;
|
||||
|
||||
public class PetExtraToken
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package mineplex.hub.pet.repository.token;
|
||||
package mineplex.core.pet.repository.token;
|
||||
|
||||
public class PetSalesToken
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package mineplex.hub.pet.repository.token;
|
||||
package mineplex.core.pet.repository.token;
|
||||
|
||||
public class PetToken
|
||||
{
|
@ -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;
|
||||
|
||||
@ -37,24 +38,49 @@ 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());
|
||||
}
|
||||
@ -139,6 +161,11 @@ public class ShopItem extends CraftItemStack
|
||||
return _displayItem;
|
||||
}
|
||||
|
||||
public void addGlow()
|
||||
{
|
||||
UtilInv.addDullEnchantment(this);
|
||||
}
|
||||
|
||||
public void SetLocked(boolean owns)
|
||||
{
|
||||
_locked = owns;
|
||||
|
@ -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<PluginType extends MiniPlugin, ShopType extends Sh
|
||||
{
|
||||
ShowResultsPage(response);
|
||||
}
|
||||
}, Player.getName(), _salesItem.GetName(), _salesItem.GetCost(SelectedCurrency), _salesItem.OneTimePurchase());
|
||||
}, Player.getName(), _salesItem.GetName(), SelectedCurrency == CurrencyType.Coins, _salesItem.GetCost(SelectedCurrency), _salesItem.OneTimePurchase());
|
||||
}
|
||||
|
||||
_taskId = Plugin.GetScheduler().scheduleSyncRepeatingTask(Plugin.GetPlugin(), this, 2L, 2L);
|
||||
|
@ -12,6 +12,7 @@ import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
@ -97,6 +98,11 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
|
||||
ButtonMap.put(slot, button);
|
||||
}
|
||||
|
||||
protected void addGlow(int slot)
|
||||
{
|
||||
UtilInv.addDullEnchantment(getItem(slot));
|
||||
}
|
||||
|
||||
protected void RemoveButton(int slot)
|
||||
{
|
||||
getInventory().setItem(slot, null);
|
||||
@ -157,4 +163,10 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
|
||||
Shop = null;
|
||||
Plugin = null;
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
clear();
|
||||
BuildPage();
|
||||
}
|
||||
}
|
||||
|
7
Plugins/Mineplex.Core/src/mineplex/core/stats/Stat.java
Normal file
7
Plugins/Mineplex.Core/src/mineplex/core/stats/Stat.java
Normal file
@ -0,0 +1,7 @@
|
||||
package mineplex.core.stats;
|
||||
|
||||
public class Stat
|
||||
{
|
||||
public int Id;
|
||||
public String Name;
|
||||
}
|
@ -1,42 +1,32 @@
|
||||
package mineplex.core.stats;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.database.Table;
|
||||
import mineplex.core.database.column.Column;
|
||||
import mineplex.core.database.column.ColumnInt;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
|
||||
public class StatsManager extends MiniPlugin
|
||||
public class StatsManager extends MiniClientPlugin<PlayerStats>
|
||||
{
|
||||
private static Object _statSync = new Object();
|
||||
|
||||
private NautHashMap<String, NautHashMap<String, Row>> _statUploadQueue = new NautHashMap<String, NautHashMap<String, Row>>();
|
||||
private StatsRepository _repository;
|
||||
|
||||
private NautHashMap<String, Integer> _stats = new NautHashMap<String, Integer>();
|
||||
private NautHashMap<String, NautHashMap<String, Integer>> _statUploadQueue = new NautHashMap<String, NautHashMap<String, Integer>>();
|
||||
private Runnable _saveRunnable;
|
||||
|
||||
private NautHashMap<String, Table> _tables = new NautHashMap<String, Table>();
|
||||
|
||||
private NautHashMap<String, NautHashMap<String, Row>> _playerStatList = new NautHashMap<String, NautHashMap<String, Row>>();
|
||||
|
||||
public StatsManager(JavaPlugin plugin)
|
||||
{
|
||||
super("StatsManager", plugin);
|
||||
|
||||
_repository = new StatsRepository(plugin);
|
||||
|
||||
if (_saveRunnable == null)
|
||||
{
|
||||
_saveRunnable = new Runnable()
|
||||
@ -47,161 +37,45 @@ 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<Column<?>> columnList = new ArrayList<Column<?>>();
|
||||
columnList.add(playerColumn);
|
||||
Get(player).addStat(statName, Get(player).getStat(statName) + value);
|
||||
|
||||
for (String column : columns)
|
||||
{
|
||||
columnList.add(new ColumnInt(column));
|
||||
}
|
||||
|
||||
Table statTable = new Table(tableName, columnList, columnList, playerColumn);
|
||||
statTable.initialize();
|
||||
|
||||
// Can't Arrays.asList here because of weird java generics
|
||||
_tables.put(tableName, statTable);
|
||||
}
|
||||
|
||||
if (!_playerStatList.containsKey(tableName))
|
||||
{
|
||||
_playerStatList.put(tableName, new NautHashMap<String, Row>());
|
||||
}
|
||||
|
||||
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));
|
||||
String uuidString = player.getUniqueId().toString();
|
||||
|
||||
synchronized (_statSync)
|
||||
{
|
||||
if (!_statUploadQueue.containsKey(table))
|
||||
if (!_statUploadQueue.containsKey(uuidString))
|
||||
{
|
||||
_statUploadQueue.put(table, new NautHashMap<String, Row>());
|
||||
_statUploadQueue.put(uuidString, new NautHashMap<String, Integer>());
|
||||
}
|
||||
|
||||
_statUploadQueue.get(table).put(playerName, _playerStatList.get(table).get(playerName));
|
||||
if (!_statUploadQueue.get(uuidString).containsKey(statName))
|
||||
{
|
||||
_statUploadQueue.get(uuidString).put(statName, 0);
|
||||
}
|
||||
|
||||
_statUploadQueue.get(uuidString).put(statName, _statUploadQueue.get(uuidString).get(statName) + value);
|
||||
}
|
||||
}
|
||||
|
||||
@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()
|
||||
// Verify stat is in our local cache, if not add it remotely.
|
||||
if (!_stats.containsKey(statName))
|
||||
{
|
||||
public void run()
|
||||
Bukkit.getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
||||
{
|
||||
event.decreaseProcessingCount();
|
||||
}
|
||||
});
|
||||
/* HA YOU THOUGHT I WAS GOING TO RUN DIDN'T YOU? */
|
||||
|
||||
if (true)
|
||||
return;
|
||||
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
for (Entry<String, Table> tableEntry : _tables.entrySet())
|
||||
{
|
||||
Table table = tableEntry.getValue();
|
||||
String tableName = tableEntry.getKey();
|
||||
|
||||
try
|
||||
{
|
||||
// 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<Column<?>> columnList = new ArrayList<Column<?>>();
|
||||
columnList.add(new ColumnVarChar("playerUuid", 256, event.getUniqueId().toString()));
|
||||
List<Row> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,35 +85,25 @@ public class StatsManager extends MiniPlugin
|
||||
|
||||
try
|
||||
{
|
||||
NautHashMap<String, NautHashMap<String, Row>> uploadQueue = new NautHashMap<String, NautHashMap<String, Row>>();
|
||||
NautHashMap<String, NautHashMap<Integer, Integer>> uploadQueue = new NautHashMap<String, NautHashMap<Integer, Integer>>();
|
||||
|
||||
synchronized (_statSync)
|
||||
{
|
||||
for (String key : _statUploadQueue.keySet())
|
||||
{
|
||||
uploadQueue.put(key, new NautHashMap<String, Row>());
|
||||
uploadQueue.put(key, new NautHashMap<Integer, Integer>());
|
||||
|
||||
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<Entry<String, Row>> iterator = uploadQueue.get(tableName).entrySet().iterator(); iterator.hasNext();)
|
||||
{
|
||||
Entry<String, Row> entry = iterator.next();
|
||||
|
||||
if (!_tables.get(tableName).update(new ArrayList<Column<?>>(entry.getValue().Columns.values()), new ColumnVarChar("playerName", 16, entry.getKey())))
|
||||
_tables.get(tableName).insert(new ArrayList<Column<?>>(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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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<Stat> retrieveStats()
|
||||
{
|
||||
final List<Stat> stats = new ArrayList<Stat>();
|
||||
|
||||
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<String, NautHashMap<Integer, Integer>> 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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -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<HubClient>
|
||||
{
|
||||
@ -94,6 +101,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
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<HubClient>
|
||||
|
||||
_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<HubClient>
|
||||
@Override
|
||||
public void AddCommands()
|
||||
{
|
||||
AddCommand(new GadgetToggle(this));
|
||||
AddCommand(new NewsCommand(this));
|
||||
}
|
||||
|
||||
@ -310,6 +318,50 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
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)
|
||||
{
|
||||
@ -812,6 +864,13 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
return _visibilityManager;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void gadgetCollide(GadgetCollideEntityEvent event)
|
||||
{
|
||||
if (!event.isCancelled())
|
||||
SetPortalDelay(event.getOther());
|
||||
}
|
||||
|
||||
public void SetPortalDelay(Entity ent)
|
||||
{
|
||||
if (ent instanceof Player)
|
||||
|
@ -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<HubManager>
|
||||
{
|
||||
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()));
|
||||
}
|
||||
}
|
@ -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<Gadget> _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<Gadget>();
|
||||
|
||||
//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<Gadget> 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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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<GadgetManager, GadgetShop>
|
||||
{
|
||||
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<Pet> pets = new ArrayList<Pet>(Plugin.getPetManager().GetFactory().GetPets());
|
||||
|
||||
Collections.sort(pets, new PetSorter());
|
||||
|
||||
for (Pet pet : pets)
|
||||
{
|
||||
List<String> itemLore = new ArrayList<String>();
|
||||
|
||||
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<String> itemLore = new ArrayList<String>();
|
||||
|
||||
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<String> itemLore = new ArrayList<String>();
|
||||
|
||||
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<String> itemLore = new ArrayList<String>();
|
||||
|
||||
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<GadgetManager, GadgetShop>(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<GadgetManager, GadgetShop>(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();
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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; }
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user