Hub Commands (/forcefield and /gadget)
This commit is contained in:
parent
fbb0031dc1
commit
8c3deeba49
@ -8,6 +8,7 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.craftbukkit.v1_7_R3.CraftWorld;
|
import org.bukkit.craftbukkit.v1_7_R3.CraftWorld;
|
||||||
import org.bukkit.entity.Egg;
|
import org.bukkit.entity.Egg;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -42,7 +43,10 @@ import mineplex.core.blockrestore.BlockRestore;
|
|||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.F;
|
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.UtilInv;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilParticle;
|
import mineplex.core.common.util.UtilParticle;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
@ -56,10 +60,13 @@ import mineplex.core.donation.DonationManager;
|
|||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.core.logger.Logger;
|
import mineplex.core.logger.Logger;
|
||||||
import mineplex.core.portal.Portal;
|
import mineplex.core.portal.Portal;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.stats.StatsManager;
|
import mineplex.core.stats.StatsManager;
|
||||||
import mineplex.core.task.TaskManager;
|
import mineplex.core.task.TaskManager;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import mineplex.hub.commands.ForcefieldToggle;
|
||||||
|
import mineplex.hub.commands.GadgetToggle;
|
||||||
import mineplex.hub.gadget.GadgetManager;
|
import mineplex.hub.gadget.GadgetManager;
|
||||||
import mineplex.hub.modules.*;
|
import mineplex.hub.modules.*;
|
||||||
import mineplex.hub.mount.MountManager;
|
import mineplex.hub.mount.MountManager;
|
||||||
@ -103,6 +110,10 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
private int _slot = 7;
|
private int _slot = 7;
|
||||||
private HashSet<Player> _disabled = new HashSet<Player>();
|
private HashSet<Player> _disabled = new HashSet<Player>();
|
||||||
|
|
||||||
|
//Admin
|
||||||
|
private boolean _gadgetsEnabled = true;
|
||||||
|
private HashSet<Player> _forcefield = new HashSet<Player>();
|
||||||
|
|
||||||
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager)
|
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager)
|
||||||
{
|
{
|
||||||
super("Hub Manager", plugin);
|
super("Hub Manager", plugin);
|
||||||
@ -137,6 +148,13 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true;
|
((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void AddCommands()
|
||||||
|
{
|
||||||
|
AddCommand(new GadgetToggle(this));
|
||||||
|
AddCommand(new ForcefieldToggle(this));
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void reflectMotd(ServerListPingEvent event)
|
public void reflectMotd(ServerListPingEvent event)
|
||||||
{
|
{
|
||||||
@ -771,6 +789,20 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
return UtilTime.elapsed(_portalTime.get(player.getName()), 5000);
|
return UtilTime.elapsed(_portalTime.get(player.getName()), 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean CanBump(LivingEntity ent)
|
||||||
|
{
|
||||||
|
if (!(ent instanceof Player))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (BumpDisabled(ent))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (GetVisibility().IsHiding(ent))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void HeartDisplay(UpdateEvent event)
|
public void HeartDisplay(UpdateEvent event)
|
||||||
{
|
{
|
||||||
@ -779,7 +811,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
|
|
||||||
for (Player player : UtilServer.getPlayers())
|
for (Player player : UtilServer.getPlayers())
|
||||||
{
|
{
|
||||||
if (!player.isOp() && !player.getName().equals("MonsieurApple"))
|
if (!player.isOp())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (Player other : UtilServer.getPlayers())
|
for (Player other : UtilServer.getPlayers())
|
||||||
@ -810,4 +842,51 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
{
|
{
|
||||||
event.SetCancelled(true);
|
event.SetCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean IsGadgetEnabled()
|
||||||
|
{
|
||||||
|
return _gadgetsEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetGadgetEnabled(boolean _enabled)
|
||||||
|
{
|
||||||
|
this._gadgetsEnabled = _enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean ToggleForcefield(Player caller)
|
||||||
|
{
|
||||||
|
if (_forcefield.add(caller))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
_forcefield.remove(caller);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void ForcefieldUpdate(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.FAST)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (Player player : _forcefield)
|
||||||
|
{
|
||||||
|
for (Player other : UtilServer.getPlayers())
|
||||||
|
{
|
||||||
|
if (player.equals(other))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (UtilMath.offset(other, player) > 5)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (GetClients().Get(other).GetRank().Has(Rank.ADMIN))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (Recharge.Instance.use(other, "Forcefield Bump", 500, false, false))
|
||||||
|
{
|
||||||
|
UtilAction.velocity(other, UtilAlg.getTrajectory2d(player, other), 1.6, true, 0.8, 0, 10, true);
|
||||||
|
other.getWorld().playSound(other.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.5f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
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 ForcefieldToggle extends CommandBase<HubManager>
|
||||||
|
{
|
||||||
|
public ForcefieldToggle(HubManager plugin)
|
||||||
|
{
|
||||||
|
super(plugin, Rank.ADMIN, new String[] {"forcefield", "ff"});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Execute(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, C.Bold + "Forcefield: " + F.tf(Plugin.ToggleForcefield(caller)));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
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()));
|
||||||
|
}
|
||||||
|
}
|
@ -18,10 +18,14 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilAction;
|
import mineplex.core.common.util.UtilAction;
|
||||||
import mineplex.core.common.util.UtilAlg;
|
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.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.hub.HubManager;
|
import mineplex.hub.HubManager;
|
||||||
|
import mineplex.hub.commands.GadgetToggle;
|
||||||
import mineplex.hub.gadget.gadgets.*;
|
import mineplex.hub.gadget.gadgets.*;
|
||||||
import mineplex.hub.gadget.types.ArmorGadget;
|
import mineplex.hub.gadget.types.ArmorGadget;
|
||||||
import mineplex.hub.gadget.types.ArmorGadget.ArmorSlot;
|
import mineplex.hub.gadget.types.ArmorGadget.ArmorSlot;
|
||||||
@ -38,6 +42,8 @@ public class GadgetManager extends MiniPlugin
|
|||||||
|
|
||||||
private HashSet<Gadget> _gadgets;
|
private HashSet<Gadget> _gadgets;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public GadgetManager(HubManager manager, MountManager mountManager)
|
public GadgetManager(HubManager manager, MountManager mountManager)
|
||||||
{
|
{
|
||||||
super("Gadget Manager", manager.GetPlugin());
|
super("Gadget Manager", manager.GetPlugin());
|
||||||
@ -54,14 +60,14 @@ public class GadgetManager extends MiniPlugin
|
|||||||
_gadgets = new HashSet<Gadget>();
|
_gadgets = new HashSet<Gadget>();
|
||||||
|
|
||||||
//Items
|
//Items
|
||||||
_gadgets.add(new PaintballGun(this));
|
_gadgets.add(new GadgetPaintballGun(this));
|
||||||
|
|
||||||
//Helmet
|
//Helmet
|
||||||
_gadgets.add(new BlazeHelmet(this));
|
_gadgets.add(new MorphBlaze(this));
|
||||||
|
|
||||||
//Halloween 2013
|
//Halloween 2013
|
||||||
_gadgets.add(new Halloween2013_BatGun(this));
|
_gadgets.add(new GadgetBatGun(this));
|
||||||
_gadgets.add(new Halloween2013_Helmet(this));
|
_gadgets.add(new MorphPumpkinKing(this));
|
||||||
|
|
||||||
//Christmas 2013
|
//Christmas 2013
|
||||||
//_gadgets.add(new Christmas2013_Helmet(this));
|
//_gadgets.add(new Christmas2013_Helmet(this));
|
||||||
@ -106,8 +112,16 @@ public class GadgetManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
if (event.hasItem() && event.getItem().getType() == Material.CHEST)
|
if (event.hasItem() && event.getItem().getType() == Material.CHEST)
|
||||||
{
|
{
|
||||||
_gadgetShop.attemptShopOpen(event.getPlayer());
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
if (!Manager.IsGadgetEnabled())
|
||||||
|
{
|
||||||
|
UtilPlayer.message(event.getPlayer(), F.main("Gadget", "Gadgets are currently disabled."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_gadgetShop.attemptShopOpen(event.getPlayer());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,4 +202,11 @@ public class GadgetManager extends MiniPlugin
|
|||||||
//No Portal
|
//No Portal
|
||||||
Manager.SetPortalDelay(event.GetDamageeEntity());
|
Manager.SetPortalDelay(event.GetDamageeEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DisableAll()
|
||||||
|
{
|
||||||
|
for (Gadget gadget : _gadgets)
|
||||||
|
for (Player player : UtilServer.getPlayers())
|
||||||
|
gadget.Disable(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,13 +31,13 @@ import mineplex.core.updater.event.UpdateEvent;
|
|||||||
import mineplex.hub.gadget.GadgetManager;
|
import mineplex.hub.gadget.GadgetManager;
|
||||||
import mineplex.hub.gadget.types.ItemGadget;
|
import mineplex.hub.gadget.types.ItemGadget;
|
||||||
|
|
||||||
public class Halloween2013_BatGun extends ItemGadget
|
public class GadgetBatGun extends ItemGadget
|
||||||
{
|
{
|
||||||
private HashMap<Player, Long> _active = new HashMap<Player, Long>();
|
private HashMap<Player, Long> _active = new HashMap<Player, Long>();
|
||||||
private HashMap<Player, Location> _velocity = new HashMap<Player, Location>();
|
private HashMap<Player, Location> _velocity = new HashMap<Player, Location>();
|
||||||
private HashMap<Player, ArrayList<Bat>> _bats = new HashMap<Player, ArrayList<Bat>>();
|
private HashMap<Player, ArrayList<Bat>> _bats = new HashMap<Player, ArrayList<Bat>>();
|
||||||
|
|
||||||
public Halloween2013_BatGun(GadgetManager manager)
|
public GadgetBatGun(GadgetManager manager)
|
||||||
{
|
{
|
||||||
super(manager, "Bat Blaster", new String[]
|
super(manager, "Bat Blaster", new String[]
|
||||||
{
|
{
|
||||||
@ -49,7 +49,7 @@ public class Halloween2013_BatGun extends ItemGadget
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Enable(Player player)
|
public void EnableCustom(Player player)
|
||||||
{
|
{
|
||||||
this.ApplyItem(player);
|
this.ApplyItem(player);
|
||||||
}
|
}
|
||||||
@ -133,6 +133,9 @@ public class Halloween2013_BatGun extends ItemGadget
|
|||||||
if (other.equals(cur))
|
if (other.equals(cur))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (!Manager.Manager.CanBump(other))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!Recharge.Instance.usable(other, "Hit by Bat"))
|
if (!Recharge.Instance.usable(other, "Hit by Bat"))
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -19,20 +19,18 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
|||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.F;
|
|
||||||
import mineplex.core.common.util.UtilBlock;
|
import mineplex.core.common.util.UtilBlock;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.hub.gadget.GadgetManager;
|
import mineplex.hub.gadget.GadgetManager;
|
||||||
import mineplex.hub.gadget.types.ItemGadget;
|
import mineplex.hub.gadget.types.ItemGadget;
|
||||||
|
|
||||||
public class PaintballGun extends ItemGadget
|
public class GadgetPaintballGun extends ItemGadget
|
||||||
{
|
{
|
||||||
private HashSet<Projectile> _balls = new HashSet<Projectile>();
|
private HashSet<Projectile> _balls = new HashSet<Projectile>();
|
||||||
|
|
||||||
public PaintballGun(GadgetManager manager)
|
public GadgetPaintballGun(GadgetManager manager)
|
||||||
{
|
{
|
||||||
super(manager, "Paintball Gun", new String[]
|
super(manager, "Paintball Gun", new String[]
|
||||||
{
|
{
|
||||||
@ -43,7 +41,7 @@ public class PaintballGun extends ItemGadget
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Enable(Player player)
|
public void EnableCustom(Player player)
|
||||||
{
|
{
|
||||||
this.ApplyItem(player);
|
this.ApplyItem(player);
|
||||||
}
|
}
|
@ -2,7 +2,6 @@ package mineplex.hub.gadget.gadgets;
|
|||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Horse;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
@ -19,9 +18,9 @@ import mineplex.core.updater.event.UpdateEvent;
|
|||||||
import mineplex.hub.gadget.GadgetManager;
|
import mineplex.hub.gadget.GadgetManager;
|
||||||
import mineplex.hub.gadget.types.ArmorGadget;
|
import mineplex.hub.gadget.types.ArmorGadget;
|
||||||
|
|
||||||
public class BlazeHelmet extends ArmorGadget
|
public class MorphBlaze extends ArmorGadget
|
||||||
{
|
{
|
||||||
public BlazeHelmet(GadgetManager manager)
|
public MorphBlaze(GadgetManager manager)
|
||||||
{
|
{
|
||||||
super(manager, "Blaze Helmet", new String[]
|
super(manager, "Blaze Helmet", new String[]
|
||||||
{
|
{
|
||||||
@ -37,7 +36,7 @@ public class BlazeHelmet extends ArmorGadget
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Enable(final Player player)
|
public void EnableCustom(final Player player)
|
||||||
{
|
{
|
||||||
this.ApplyArmor(player);
|
this.ApplyArmor(player);
|
||||||
|
|
@ -10,9 +10,9 @@ import mineplex.core.disguise.disguises.DisguiseSkeleton;
|
|||||||
import mineplex.hub.gadget.GadgetManager;
|
import mineplex.hub.gadget.GadgetManager;
|
||||||
import mineplex.hub.gadget.types.ArmorGadget;
|
import mineplex.hub.gadget.types.ArmorGadget;
|
||||||
|
|
||||||
public class Halloween2013_Helmet extends ArmorGadget
|
public class MorphPumpkinKing extends ArmorGadget
|
||||||
{
|
{
|
||||||
public Halloween2013_Helmet(GadgetManager manager)
|
public MorphPumpkinKing(GadgetManager manager)
|
||||||
{
|
{
|
||||||
super(manager, "Pumpkin Kings Head", new String[]
|
super(manager, "Pumpkin Kings Head", new String[]
|
||||||
{
|
{
|
||||||
@ -28,7 +28,7 @@ public class Halloween2013_Helmet extends ArmorGadget
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Enable(final Player player)
|
public void EnableCustom(final Player player)
|
||||||
{
|
{
|
||||||
this.ApplyArmor(player);
|
this.ApplyArmor(player);
|
||||||
|
|
@ -2,18 +2,15 @@ package mineplex.hub.gadget.gadgets;
|
|||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.block.EntityBlockFormEvent;
|
|
||||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.disguise.disguises.DisguiseSnowman;
|
import mineplex.core.disguise.disguises.DisguiseSnowman;
|
||||||
import mineplex.hub.gadget.GadgetManager;
|
import mineplex.hub.gadget.GadgetManager;
|
||||||
import mineplex.hub.gadget.types.ArmorGadget;
|
import mineplex.hub.gadget.types.ArmorGadget;
|
||||||
|
|
||||||
public class Christmas2013_Helmet extends ArmorGadget
|
public class MorphSnowman extends ArmorGadget
|
||||||
{
|
{
|
||||||
public Christmas2013_Helmet(GadgetManager manager)
|
public MorphSnowman(GadgetManager manager)
|
||||||
{
|
{
|
||||||
super(manager, "Snowmans Head", new String[]
|
super(manager, "Snowmans Head", new String[]
|
||||||
{
|
{
|
||||||
@ -29,7 +26,7 @@ public class Christmas2013_Helmet extends ArmorGadget
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Enable(final Player player)
|
public void EnableCustom(final Player player)
|
||||||
{
|
{
|
||||||
this.ApplyArmor(player);
|
this.ApplyArmor(player);
|
||||||
|
|
@ -3,6 +3,8 @@ package mineplex.hub.gadget.types;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import mineplex.core.common.CurrencyType;
|
import mineplex.core.common.CurrencyType;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.shop.item.SalesPackageBase;
|
import mineplex.core.shop.item.SalesPackageBase;
|
||||||
import mineplex.hub.gadget.GadgetManager;
|
import mineplex.hub.gadget.GadgetManager;
|
||||||
|
|
||||||
@ -44,7 +46,17 @@ public abstract class Gadget extends SalesPackageBase implements Listener
|
|||||||
Disable(event.getPlayer());
|
Disable(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void Enable(Player player);
|
public final void Enable(Player player)
|
||||||
|
{
|
||||||
|
if (!Manager.Manager.IsGadgetEnabled())
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, F.main("Gadget", "Gadgets are currently disabled."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EnableCustom(player);
|
||||||
|
}
|
||||||
|
public abstract void EnableCustom(Player player);
|
||||||
public abstract void Disable(Player player);
|
public abstract void Disable(Player player);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -46,11 +46,8 @@ public class StackerManager extends MiniPlugin implements IThrown
|
|||||||
|
|
||||||
private ProjectileManager _projectileManager;
|
private ProjectileManager _projectileManager;
|
||||||
|
|
||||||
|
|
||||||
private HashSet<Entity> _tempStackShift = new HashSet<Entity>();
|
private HashSet<Entity> _tempStackShift = new HashSet<Entity>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public StackerManager(HubManager manager)
|
public StackerManager(HubManager manager)
|
||||||
{
|
{
|
||||||
super("Stacker", manager.GetPlugin());
|
super("Stacker", manager.GetPlugin());
|
||||||
@ -60,26 +57,6 @@ public class StackerManager extends MiniPlugin implements IThrown
|
|||||||
_projectileManager = new ProjectileManager(manager.GetPlugin());
|
_projectileManager = new ProjectileManager(manager.GetPlugin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean CanStack(LivingEntity ent)
|
|
||||||
{
|
|
||||||
if (!(ent instanceof Player))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (Manager.BumpDisabled(ent))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (Manager.GetVisibility().IsHiding(ent))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void GrabEntity(PlayerInteractEntityEvent event)
|
public void GrabEntity(PlayerInteractEntityEvent event)
|
||||||
{
|
{
|
||||||
@ -101,7 +78,7 @@ public class StackerManager extends MiniPlugin implements IThrown
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CanStack(stacker))
|
if (!Manager.CanBump(stacker))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(stacker, F.main("Stacker", "You are not playing stacker."));
|
UtilPlayer.message(stacker, F.main("Stacker", "You are not playing stacker."));
|
||||||
return;
|
return;
|
||||||
@ -129,7 +106,7 @@ public class StackerManager extends MiniPlugin implements IThrown
|
|||||||
if (stackee instanceof Player && ((Player)stackee).getGameMode() != GameMode.SURVIVAL)
|
if (stackee instanceof Player && ((Player)stackee).getGameMode() != GameMode.SURVIVAL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (stackee instanceof Player && !CanStack(((Player)stackee)))
|
if (stackee instanceof Player && !Manager.CanBump(((Player)stackee)))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(stacker, F.main("Stacker", F.name(UtilEnt.getName(stackee)) + " is not playing stacker."));
|
UtilPlayer.message(stacker, F.main("Stacker", F.name(UtilEnt.getName(stackee)) + " is not playing stacker."));
|
||||||
return;
|
return;
|
||||||
@ -247,6 +224,9 @@ public class StackerManager extends MiniPlugin implements IThrown
|
|||||||
if (target.getCustomName() != null || (target.getPassenger() != null && target.getPassenger() instanceof LivingEntity && ((LivingEntity)target.getPassenger()).getCustomName() != null))
|
if (target.getCustomName() != null || (target.getPassenger() != null && target.getPassenger() instanceof LivingEntity && ((LivingEntity)target.getPassenger()).getCustomName() != null))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!Manager.CanBump(target))
|
||||||
|
return;
|
||||||
|
|
||||||
//Velocity
|
//Velocity
|
||||||
UtilAction.velocity(target, UtilAlg.getTrajectory2d(data.GetThrown(), target), 1, true, 0.8, 0, 10, true);
|
UtilAction.velocity(target, UtilAlg.getTrajectory2d(data.GetThrown(), target), 1, true, 0.8, 0, 10, true);
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ public class DragonMount extends Mount<DragonData>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Enable(final Player player)
|
public void EnableCustom(final Player player)
|
||||||
{
|
{
|
||||||
player.leaveVehicle();
|
player.leaveVehicle();
|
||||||
player.eject();
|
player.eject();
|
||||||
|
@ -92,7 +92,7 @@ public class HorseMount extends Mount<Horse>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Enable(Player player)
|
public void EnableCustom(Player player)
|
||||||
{
|
{
|
||||||
player.leaveVehicle();
|
player.leaveVehicle();
|
||||||
player.eject();
|
player.eject();
|
||||||
|
@ -11,6 +11,8 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import mineplex.core.common.CurrencyType;
|
import mineplex.core.common.CurrencyType;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.shop.item.SalesPackageBase;
|
import mineplex.core.shop.item.SalesPackageBase;
|
||||||
|
|
||||||
public abstract class Mount<T> extends SalesPackageBase implements Listener
|
public abstract class Mount<T> extends SalesPackageBase implements Listener
|
||||||
@ -33,7 +35,17 @@ public abstract class Mount<T> extends SalesPackageBase implements Listener
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void Enable(Player player);
|
public final void Enable(Player player)
|
||||||
|
{
|
||||||
|
if (!Manager.Manager.IsGadgetEnabled())
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, F.main("Gadget", "Gadgets are currently disabled."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EnableCustom(player);
|
||||||
|
}
|
||||||
|
public abstract void EnableCustom(Player player);
|
||||||
public abstract void Disable(Player player);
|
public abstract void Disable(Player player);
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -14,6 +14,7 @@ import mineplex.core.MiniPlugin;
|
|||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.hub.HubManager;
|
import mineplex.hub.HubManager;
|
||||||
import mineplex.hub.mount.types.*;
|
import mineplex.hub.mount.types.*;
|
||||||
|
|
||||||
@ -21,7 +22,7 @@ public class MountManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
public HubManager Manager;
|
public HubManager Manager;
|
||||||
|
|
||||||
private HashSet<Mount> _types;
|
private HashSet<Mount<?>> _types;
|
||||||
|
|
||||||
public MountManager(HubManager manager)
|
public MountManager(HubManager manager)
|
||||||
{
|
{
|
||||||
@ -34,7 +35,7 @@ public class MountManager extends MiniPlugin
|
|||||||
|
|
||||||
private void CreateGadgets()
|
private void CreateGadgets()
|
||||||
{
|
{
|
||||||
_types = new HashSet<Mount>();
|
_types = new HashSet<Mount<?>>();
|
||||||
|
|
||||||
_types.add(new Undead(this));
|
_types.add(new Undead(this));
|
||||||
_types.add(new Frost(this));
|
_types.add(new Frost(this));
|
||||||
@ -42,7 +43,7 @@ public class MountManager extends MiniPlugin
|
|||||||
_types.add(new Dragon(this));
|
_types.add(new Dragon(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashSet<Mount> getMounts()
|
public HashSet<Mount<?>> getMounts()
|
||||||
{
|
{
|
||||||
return _types;
|
return _types;
|
||||||
}
|
}
|
||||||
@ -52,7 +53,7 @@ public class MountManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
if (Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.MODERATOR))
|
if (Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.MODERATOR))
|
||||||
{
|
{
|
||||||
for (Mount mount : _types)
|
for (Mount<?> mount : _types)
|
||||||
{
|
{
|
||||||
Manager.GetDonation().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(mount.GetName());
|
Manager.GetDonation().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(mount.GetName());
|
||||||
}
|
}
|
||||||
@ -62,7 +63,7 @@ public class MountManager extends MiniPlugin
|
|||||||
//Disallows two mounts active
|
//Disallows two mounts active
|
||||||
public void DeregisterAll(Player player)
|
public void DeregisterAll(Player player)
|
||||||
{
|
{
|
||||||
for (Mount mount : _types)
|
for (Mount<?> mount : _types)
|
||||||
mount.Disable(player);
|
mount.Disable(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,4 +89,11 @@ public class MountManager extends MiniPlugin
|
|||||||
if (event.getEntity().getItemStack().getType() == Material.LEASH)
|
if (event.getEntity().getItemStack().getType() == Material.LEASH)
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DisableAll()
|
||||||
|
{
|
||||||
|
for (Mount<?> mount : _types)
|
||||||
|
for (Player player : UtilServer.getPlayers())
|
||||||
|
mount.Disable(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user