Hub stuff
This commit is contained in:
parent
1d549e38ff
commit
937f5d8ef2
@ -14,7 +14,7 @@ public enum Rank
|
||||
MODERATOR("Mod", ChatColor.GOLD),
|
||||
HELPER("Helper", ChatColor.GREEN),
|
||||
MAPDEV("Mapper", ChatColor.BLUE),
|
||||
YOUTUBE("Legend", ChatColor.DARK_GREEN),
|
||||
YOUTUBE("YouTube", ChatColor.RED),
|
||||
HERO("Hero", ChatColor.LIGHT_PURPLE),
|
||||
ULTRA("Ultra", ChatColor.AQUA),
|
||||
ALL("All", ChatColor.YELLOW);
|
||||
|
@ -85,6 +85,8 @@ public class UtilInv
|
||||
|
||||
public static void Clear(Player player)
|
||||
{
|
||||
player.getOpenInventory().close();
|
||||
|
||||
PlayerInventory inv = player.getInventory();
|
||||
|
||||
inv.clear();
|
||||
@ -263,6 +265,16 @@ public class UtilInv
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UseItemInHand(Player player)
|
||||
{
|
||||
if (player.getItemInHand().getAmount() > 1)
|
||||
player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
|
||||
else
|
||||
player.setItemInHand(null);
|
||||
|
||||
Update(player);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class Portal extends MiniPlugin
|
||||
|
@ -27,8 +27,8 @@ import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.hub.HubManager;
|
||||
import mineplex.hub.commands.GadgetToggle;
|
||||
import mineplex.hub.gadget.gadgets.*;
|
||||
import mineplex.hub.gadget.types.ArmorGadget;
|
||||
import mineplex.hub.gadget.types.ArmorGadget.ArmorSlot;
|
||||
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;
|
||||
@ -57,23 +57,21 @@ public class GadgetManager extends MiniPlugin
|
||||
|
||||
private void CreateGadgets()
|
||||
{
|
||||
_gadgets = new HashSet<Gadget>();
|
||||
_gadgets = new HashSet<Gadget>();
|
||||
|
||||
//Items
|
||||
_gadgets.add(new GadgetPaintballGun(this));
|
||||
_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));
|
||||
|
||||
//Helmet
|
||||
//Morphs
|
||||
_gadgets.add(new MorphBlaze(this));
|
||||
|
||||
//Halloween 2013
|
||||
_gadgets.add(new GadgetBatGun(this));
|
||||
_gadgets.add(new MorphPumpkinKing(this));
|
||||
|
||||
//Christmas 2013
|
||||
//_gadgets.add(new Christmas2013_Helmet(this));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
event.getPlayer().getInventory().setItem(5, ItemStackFactory.Instance.CreateStack(Material.CHEST, (byte)0, 1, ChatColor.RESET + C.cGreen + "Gadget Menu"));
|
||||
@ -135,9 +133,9 @@ public class GadgetManager extends MiniPlugin
|
||||
{
|
||||
for (Gadget gadget : _gadgets)
|
||||
{
|
||||
if (gadget instanceof ArmorGadget)
|
||||
if (gadget instanceof MorphGadget)
|
||||
{
|
||||
ArmorGadget armor = (ArmorGadget)gadget;
|
||||
MorphGadget armor = (MorphGadget)gadget;
|
||||
|
||||
if (armor.GetSlot() == slot)
|
||||
{
|
||||
|
@ -9,17 +9,13 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Bat;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
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.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilGear;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
@ -31,21 +27,22 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.gadget.GadgetManager;
|
||||
import mineplex.hub.gadget.types.ItemGadget;
|
||||
|
||||
public class GadgetBatGun extends ItemGadget
|
||||
public class ItemBatGun extends ItemGadget
|
||||
{
|
||||
private HashMap<Player, Long> _active = new HashMap<Player, Long>();
|
||||
private HashMap<Player, Location> _velocity = new HashMap<Player, Location>();
|
||||
private HashMap<Player, ArrayList<Bat>> _bats = new HashMap<Player, ArrayList<Bat>>();
|
||||
|
||||
public GadgetBatGun(GadgetManager manager)
|
||||
public ItemBatGun(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Bat Blaster", new String[]
|
||||
{
|
||||
C.cWhite + "Launch waves of annoying bats",
|
||||
C.cWhite + "at people you don't like!",
|
||||
},
|
||||
10000,
|
||||
Material.IRON_BARDING, (byte)0);
|
||||
0,
|
||||
Material.IRON_BARDING, (byte)0,
|
||||
6000, 4, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -62,32 +59,9 @@ public class GadgetBatGun extends ItemGadget
|
||||
Clear(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Activate(PlayerInteractEvent event)
|
||||
@Override
|
||||
public void ActivateCustom(Player player)
|
||||
{
|
||||
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
if (UtilBlock.usable(event.getClickedBlock()))
|
||||
return;
|
||||
|
||||
if (!UtilGear.isMat(event.getPlayer().getItemInHand(), Material.IRON_BARDING))
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!IsActive(player))
|
||||
return;
|
||||
|
||||
if (Manager.Manager.GetParkour().InParkour(player))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Parkour", "You cannot use Bat Blaster near Parkour Challenges."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Recharge.Instance.use(player, GetName(), 8000, true, false))
|
||||
return;
|
||||
|
||||
//Start
|
||||
_velocity.put(player, player.getEyeLocation());
|
||||
_active.put(player, System.currentTimeMillis());
|
@ -0,0 +1,52 @@
|
||||
package mineplex.hub.gadget.gadgets;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.hub.gadget.GadgetManager;
|
||||
import mineplex.hub.gadget.types.ItemGadget;
|
||||
|
||||
public class ItemFirework extends ItemGadget
|
||||
{
|
||||
public ItemFirework(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Fireworks", new String[]
|
||||
{
|
||||
C.cWhite + "FIREWORKS!",
|
||||
},
|
||||
0,
|
||||
Material.TNT, (byte)0,
|
||||
500, 10, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void EnableCustom(Player player)
|
||||
{
|
||||
this.ApplyItem(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Disable(Player player)
|
||||
{
|
||||
this.RemoveItem(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ActivateCustom(Player player)
|
||||
{
|
||||
//Inform
|
||||
UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + "."));
|
||||
|
||||
UtilFirework.launchFirework(player.getEyeLocation().add(player.getLocation().getDirection()),
|
||||
FireworkEffect.builder().flicker(false).withColor(Color.GREEN).with(Type.BURST).trail(false).build(), new Vector(0,1,0), 1 + (int)Math.random()*3);
|
||||
}
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
package mineplex.hub.gadget.gadgets;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
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
|
||||
{
|
||||
private HashMap<Item, Long> _active = new HashMap<Item, Long>();
|
||||
private HashSet<Item> _gems = new HashSet<Item>();
|
||||
|
||||
public ItemGemBomb(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Gem Party Bomb", new String[]
|
||||
{
|
||||
C.cWhite + "It's party time! You will be",
|
||||
C.cWhite + "everyones favourite player",
|
||||
C.cWhite + "when you use one of these!",
|
||||
},
|
||||
0,
|
||||
Material.EMERALD_BLOCK, (byte)0,
|
||||
30000, 1000, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void EnableCustom(Player player)
|
||||
{
|
||||
this.ApplyItem(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Disable(Player player)
|
||||
{
|
||||
this.RemoveItem(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ActivateCustom(Player player)
|
||||
{
|
||||
Item item = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), new ItemStack(Material.EMERALD_BLOCK));
|
||||
UtilAction.velocity(item, player.getLocation().getDirection(), 1, false, 0, 0.2, 1, false);
|
||||
_active.put(item, System.currentTimeMillis());
|
||||
|
||||
//Inform
|
||||
UtilPlayer.message(player, F.main("Skill", "You threw a " + F.skill(GetName()) + "."));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
Iterator<Item> itemIterator = _active.keySet().iterator();
|
||||
|
||||
while (itemIterator.hasNext())
|
||||
{
|
||||
Item item = itemIterator.next();
|
||||
long time = _active.get(item);
|
||||
|
||||
if (UtilTime.elapsed(time, 3000))
|
||||
{
|
||||
UtilFirework.playFirework(item.getLocation(), FireworkEffect.builder().flicker(false).withColor(Color.GREEN).with(Type.BURST).trail(false).build());
|
||||
|
||||
Item gem = item.getWorld().dropItem(item.getLocation(), new ItemStack(Material.EMERALD));
|
||||
|
||||
Vector vel = new Vector(Math.random() - 0.5, Math.random(), Math.random() - 0.5);
|
||||
|
||||
UtilAction.velocity(gem, vel, 0.5 + Math.random(), false, 0, 0, 1, false);
|
||||
|
||||
gem.setPickupDelay(60);
|
||||
|
||||
_gems.add(gem);
|
||||
}
|
||||
|
||||
if (UtilTime.elapsed(time, 23000))
|
||||
{
|
||||
item.remove();
|
||||
itemIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Pickup(PlayerPickupItemEvent event)
|
||||
{
|
||||
if (_active.keySet().contains(event.getItem()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (_gems.contains(event.getItem()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.getItem().remove();
|
||||
|
||||
Manager.Manager.GetDonation().RewardGems(null, event.getPlayer().getName(), GetName(), 4);
|
||||
|
||||
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1f, 2f);
|
||||
}
|
||||
}
|
||||
}
|
@ -12,32 +12,30 @@ import org.bukkit.entity.EnderPearl;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
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.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.gadget.GadgetManager;
|
||||
import mineplex.hub.gadget.types.ItemGadget;
|
||||
|
||||
public class GadgetPaintballGun extends ItemGadget
|
||||
public class ItemPaintballGun extends ItemGadget
|
||||
{
|
||||
private HashSet<Projectile> _balls = new HashSet<Projectile>();
|
||||
|
||||
public GadgetPaintballGun(GadgetManager manager)
|
||||
public ItemPaintballGun(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Paintball Gun", new String[]
|
||||
{
|
||||
C.cWhite + "PEW PEW PEW PEW!",
|
||||
},
|
||||
5000,
|
||||
Material.GOLD_BARDING, (byte)0);
|
||||
0,
|
||||
Material.GOLD_BARDING, (byte)0,
|
||||
1000, 2, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -52,31 +50,9 @@ public class GadgetPaintballGun extends ItemGadget
|
||||
this.RemoveItem(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Shoot(PlayerInteractEvent event)
|
||||
@Override
|
||||
public void ActivateCustom(Player player)
|
||||
{
|
||||
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
if (UtilBlock.usable(event.getClickedBlock()))
|
||||
return;
|
||||
|
||||
if (event.getPlayer().getItemInHand() == null)
|
||||
return;
|
||||
|
||||
if (event.getPlayer().getItemInHand().getType() != Material.GOLD_BARDING)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!IsActive(player))
|
||||
return;
|
||||
|
||||
if (!Recharge.Instance.use(player, GetName(), 400, false, false))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
Projectile proj = player.launchProjectile(EnderPearl.class);
|
||||
proj.setVelocity(proj.getVelocity().multiply(2));
|
||||
_balls.add(proj);
|
@ -0,0 +1,111 @@
|
||||
package mineplex.hub.gadget.gadgets;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
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.hub.gadget.GadgetManager;
|
||||
import mineplex.hub.gadget.types.ItemGadget;
|
||||
|
||||
public class ItemTNT extends ItemGadget
|
||||
{
|
||||
private HashSet<Item> _gems = new HashSet<Item>();
|
||||
|
||||
public ItemTNT(GadgetManager manager)
|
||||
{
|
||||
super(manager, "TNT", new String[]
|
||||
{
|
||||
C.cWhite + "Throw some TNT!",
|
||||
C.cWhite + "Players hit by it will drop",
|
||||
C.cWhite + "some gems for you to steal!",
|
||||
},
|
||||
10000,
|
||||
Material.TNT, (byte)0,
|
||||
5000, 100, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void EnableCustom(Player player)
|
||||
{
|
||||
this.ApplyItem(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Disable(Player player)
|
||||
{
|
||||
this.RemoveItem(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ActivateCustom(Player player)
|
||||
{
|
||||
TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), TNTPrimed.class);
|
||||
UtilAction.velocity(tnt, player.getLocation().getDirection(), 1, false, 0, 0.2, 1, false);
|
||||
|
||||
//Inform
|
||||
UtilPlayer.message(player, F.main("Skill", "You threw " + F.skill(GetName()) + "."));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Update(EntityExplodeEvent event)
|
||||
{
|
||||
if (!(event.getEntity() instanceof TNTPrimed))
|
||||
return;
|
||||
|
||||
HashMap<Player, Double> players = UtilPlayer.getInRadius(event.getLocation(), 10);
|
||||
for (Player player : players.keySet())
|
||||
{
|
||||
double mult = players.get(player);
|
||||
|
||||
//Drop Gems
|
||||
int gemDrop = (int)(10*mult);
|
||||
|
||||
Manager.Manager.GetDonation().RewardGems(null, player.getName(), GetName(), -(gemDrop*4));
|
||||
|
||||
for (int i=0 ; i<gemDrop ; i++)
|
||||
{
|
||||
Item gem = event.getLocation().getWorld().dropItem(event.getLocation(), new ItemStack(Material.EMERALD));
|
||||
|
||||
Vector vel = new Vector(Math.random() - 0.5, Math.random(), Math.random() - 0.5);
|
||||
|
||||
UtilAction.velocity(gem, vel, 0.3 + Math.random()*0.3, false, 0, 0, 1, false);
|
||||
|
||||
gem.setPickupDelay(60);
|
||||
|
||||
_gems.add(gem);
|
||||
}
|
||||
|
||||
//Knockback
|
||||
UtilAction.velocity(player, UtilAlg.getTrajectory(event.getLocation(), player.getLocation()), 1.6 * mult, false, 0, 0.2 + 0.4 * mult, 10, true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Pickup(PlayerPickupItemEvent event)
|
||||
{
|
||||
if (_gems.contains(event.getItem()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.getItem().remove();
|
||||
|
||||
Manager.Manager.GetDonation().RewardGems(null, event.getPlayer().getName(), GetName(), 4);
|
||||
|
||||
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1f, 2f);
|
||||
}
|
||||
}
|
||||
}
|
@ -16,9 +16,9 @@ import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.gadget.GadgetManager;
|
||||
import mineplex.hub.gadget.types.ArmorGadget;
|
||||
import mineplex.hub.gadget.types.MorphGadget;
|
||||
|
||||
public class MorphBlaze extends ArmorGadget
|
||||
public class MorphBlaze extends MorphGadget
|
||||
{
|
||||
public MorphBlaze(GadgetManager manager)
|
||||
{
|
||||
|
@ -8,9 +8,9 @@ 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.ArmorGadget;
|
||||
import mineplex.hub.gadget.types.MorphGadget;
|
||||
|
||||
public class MorphPumpkinKing extends ArmorGadget
|
||||
public class MorphPumpkinKing extends MorphGadget
|
||||
{
|
||||
public MorphPumpkinKing(GadgetManager manager)
|
||||
{
|
||||
|
@ -6,9 +6,9 @@ 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.ArmorGadget;
|
||||
import mineplex.hub.gadget.types.MorphGadget;
|
||||
|
||||
public class MorphSnowman extends ArmorGadget
|
||||
public class MorphSnowman extends MorphGadget
|
||||
{
|
||||
public MorphSnowman(GadgetManager manager)
|
||||
{
|
||||
|
@ -23,6 +23,7 @@ public abstract class Gadget extends SalesPackageBase implements Listener
|
||||
public Gadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data)
|
||||
{
|
||||
super(name, mat, data, desc, cost);
|
||||
|
||||
KnownPackage = false;
|
||||
|
||||
Manager = manager;
|
||||
|
@ -6,42 +6,56 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
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.itemstack.ItemStackFactory;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.hub.gadget.GadgetManager;
|
||||
|
||||
public abstract class ItemGadget extends Gadget
|
||||
{
|
||||
public ItemGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data)
|
||||
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)
|
||||
{
|
||||
super(manager, name, desc, cost, mat, data);
|
||||
|
||||
_recharge = recharge;
|
||||
_gemsPerUse = gemsPerUse;
|
||||
_nearParkour = canUseNearParkour;
|
||||
}
|
||||
|
||||
|
||||
public HashSet<Player> GetActive()
|
||||
{
|
||||
return _active;
|
||||
}
|
||||
|
||||
|
||||
public boolean IsActive(Player player)
|
||||
{
|
||||
return _active.contains(player);
|
||||
}
|
||||
|
||||
|
||||
public void ApplyItem(Player player)
|
||||
{
|
||||
Manager.RemoveItem(player);
|
||||
|
||||
|
||||
player.getInventory().setItem(4, ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(GetName())));
|
||||
|
||||
|
||||
_active.add(player);
|
||||
|
||||
|
||||
UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(GetName()) + "."));
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void orderThatChest(final PlayerDropItemEvent event)
|
||||
{
|
||||
@ -55,13 +69,13 @@ public abstract class ItemGadget extends Gadget
|
||||
{
|
||||
event.getPlayer().getInventory().remove(GetDisplayMaterial());
|
||||
event.getPlayer().getInventory().setItem(4, ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(GetName())));
|
||||
event.getPlayer().updateInventory();
|
||||
UtilInv.Update(event.getPlayer());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void RemoveItem(Player player)
|
||||
{
|
||||
if (_active.remove(player))
|
||||
@ -70,9 +84,59 @@ public abstract class ItemGadget extends Gadget
|
||||
UtilPlayer.message(player, F.main("Gadget", "You unequipped " + F.elem(GetName()) + "."));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean IsItem(Player player)
|
||||
{
|
||||
return UtilInv.IsItem(player.getItemInHand(), GetDisplayMaterial(), GetDisplayData());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Activate(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
if (UtilBlock.usable(event.getClickedBlock()))
|
||||
return;
|
||||
|
||||
if (!UtilGear.isMat(event.getPlayer().getItemInHand(), Material.IRON_BARDING))
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!IsActive(player))
|
||||
return;
|
||||
|
||||
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."));
|
||||
return;
|
||||
}
|
||||
|
||||
//Recharge
|
||||
if (!Recharge.Instance.use(player, GetName(), _recharge, true, false))
|
||||
return;
|
||||
|
||||
//Use Gems
|
||||
if (_gemsPerUse > 0)
|
||||
{
|
||||
if (Manager.Manager.GetDonation().Get(player.getName()).GetGems() > _gemsPerUse)
|
||||
{
|
||||
Manager.Manager.GetDonation().RewardGems(null, player.getName(), GetName(), -_gemsPerUse);
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Gadget", "You do not have enough Gems to use "+this.GetName()+"."));
|
||||
Disable(player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ActivateCustom(event.getPlayer());
|
||||
}
|
||||
|
||||
public abstract void ActivateCustom(Player player);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.hub.gadget.GadgetManager;
|
||||
|
||||
public abstract class ArmorGadget extends Gadget
|
||||
public abstract class MorphGadget extends Gadget
|
||||
{
|
||||
public enum ArmorSlot
|
||||
{
|
||||
@ -20,7 +20,7 @@ public abstract class ArmorGadget extends Gadget
|
||||
|
||||
private ArmorSlot _slot;
|
||||
|
||||
public ArmorGadget(GadgetManager manager, String name, String[] desc, int cost, ArmorSlot slot, Material mat, byte data)
|
||||
public MorphGadget(GadgetManager manager, String name, String[] desc, int cost, ArmorSlot slot, Material mat, byte data)
|
||||
{
|
||||
super(manager, name, desc, cost, mat, data);
|
||||
|
@ -17,7 +17,7 @@ import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.page.ConfirmationPage;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.hub.gadget.GadgetManager;
|
||||
import mineplex.hub.gadget.types.ArmorGadget;
|
||||
import mineplex.hub.gadget.types.MorphGadget;
|
||||
import mineplex.hub.gadget.types.Gadget;
|
||||
import mineplex.hub.gadget.types.ItemGadget;
|
||||
import mineplex.hub.mount.HorseMount;
|
||||
@ -74,9 +74,9 @@ public class GadgetPage extends ShopPageBase<GadgetManager, GadgetShop>
|
||||
{
|
||||
int slot = 0;
|
||||
|
||||
if (gadget instanceof ArmorGadget)
|
||||
if (gadget instanceof MorphGadget)
|
||||
{
|
||||
switch (((ArmorGadget)gadget).GetSlot())
|
||||
switch (((MorphGadget)gadget).GetSlot())
|
||||
{
|
||||
case Boots:
|
||||
slot = bootSlot;
|
||||
|
@ -253,13 +253,13 @@ public class QueueManager extends MiniPlugin
|
||||
}
|
||||
|
||||
for (String key : assignedCopy.keySet())
|
||||
// {
|
||||
{
|
||||
if (assignedCopy.get(key).AssignedMatch == -1)
|
||||
{
|
||||
synchronized (_assignedLock)
|
||||
{
|
||||
_assignedPlayerMatchList.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
synchronized (_queueLock)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user