Hub gadgets
This commit is contained in:
parent
02258b9fd3
commit
1944c0003c
@ -39,6 +39,7 @@ import mineplex.minecraft.game.classcombat.shop.ClassCombatShop;
|
|||||||
import mineplex.minecraft.game.classcombat.shop.ClassShopManager;
|
import mineplex.minecraft.game.classcombat.shop.ClassShopManager;
|
||||||
import mineplex.minecraft.game.core.IRelation;
|
import mineplex.minecraft.game.core.IRelation;
|
||||||
import mineplex.minecraft.game.core.combat.CombatManager;
|
import mineplex.minecraft.game.core.combat.CombatManager;
|
||||||
|
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||||
import mineplex.minecraft.game.core.fire.Fire;
|
import mineplex.minecraft.game.core.fire.Fire;
|
||||||
import nautilus.minecraft.core.INautilusPlugin;
|
import nautilus.minecraft.core.INautilusPlugin;
|
||||||
@ -82,7 +83,7 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation
|
|||||||
PacketHandler packetHandler = new PacketHandler(this);
|
PacketHandler packetHandler = new PacketHandler(this);
|
||||||
Portal portal = new Portal(this);
|
Portal portal = new Portal(this);
|
||||||
PartyManager partyManager = new PartyManager(this, clientManager);
|
PartyManager partyManager = new PartyManager(this, clientManager);
|
||||||
HubManager hubManager = new HubManager(this, clientManager, donationManager, new DisguiseManager(this, packetHandler), new TaskManager(this, GetWebServerAddress()), portal, partyManager);
|
HubManager hubManager = new HubManager(this, clientManager, donationManager, new ConditionManager(this), new DisguiseManager(this, packetHandler), new TaskManager(this, GetWebServerAddress()), portal, partyManager);
|
||||||
new ServerManager(this, clientManager, donationManager, portal, partyManager, new ServerStatusManager(this, new LagMeter(this, clientManager)), hubManager, new StackerManager(hubManager));
|
new ServerManager(this, clientManager, donationManager, portal, partyManager, new ServerStatusManager(this, new LagMeter(this, clientManager)), hubManager, new StackerManager(hubManager));
|
||||||
new Chat(this, clientManager);
|
new Chat(this, clientManager);
|
||||||
new MemoryFix(this);
|
new MemoryFix(this);
|
||||||
@ -104,7 +105,7 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation
|
|||||||
new ClassCombatShop(shopManager, clientManager, donationManager, "Select Class Here");
|
new ClassCombatShop(shopManager, clientManager, donationManager, "Select Class Here");
|
||||||
new ClassCombatPurchaseShop(shopManager, clientManager, donationManager, "Class Shop");
|
new ClassCombatPurchaseShop(shopManager, clientManager, donationManager, "Class Shop");
|
||||||
new ClassCombatCustomBuildShop(shopManager, clientManager, donationManager, "Class Setup");
|
new ClassCombatCustomBuildShop(shopManager, clientManager, donationManager, "Class Setup");
|
||||||
|
|
||||||
//Updates
|
//Updates
|
||||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
|
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
|
||||||
}
|
}
|
||||||
|
@ -53,14 +53,17 @@ import mineplex.core.portal.Portal;
|
|||||||
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.gadget.GadgetManager;
|
||||||
import mineplex.hub.modules.*;
|
import mineplex.hub.modules.*;
|
||||||
import mineplex.hub.party.Party;
|
import mineplex.hub.party.Party;
|
||||||
import mineplex.hub.party.PartyManager;
|
import mineplex.hub.party.PartyManager;
|
||||||
import mineplex.hub.tutorial.TutorialManager;
|
import mineplex.hub.tutorial.TutorialManager;
|
||||||
|
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||||
|
|
||||||
public class HubManager extends MiniClientPlugin<HubClient>
|
public class HubManager extends MiniClientPlugin<HubClient>
|
||||||
{
|
{
|
||||||
private CoreClientManager _clientManager;
|
private CoreClientManager _clientManager;
|
||||||
|
private ConditionManager _conditionManager;
|
||||||
private DonationManager _donationManager;
|
private DonationManager _donationManager;
|
||||||
private DisguiseManager _disguiseManager;
|
private DisguiseManager _disguiseManager;
|
||||||
private PartyManager _partyManager;
|
private PartyManager _partyManager;
|
||||||
@ -83,11 +86,12 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
private boolean _shuttingDown;
|
private boolean _shuttingDown;
|
||||||
|
|
||||||
|
|
||||||
public HubManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager)
|
public HubManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager)
|
||||||
{
|
{
|
||||||
super("Hub Manager", plugin);
|
super("Hub Manager", plugin);
|
||||||
|
|
||||||
_clientManager = clientManager;
|
_clientManager = clientManager;
|
||||||
|
_conditionManager = conditionManager;
|
||||||
_donationManager = donationManager;
|
_donationManager = donationManager;
|
||||||
_disguiseManager = disguiseManager;
|
_disguiseManager = disguiseManager;
|
||||||
_portal = portal;
|
_portal = portal;
|
||||||
@ -101,6 +105,8 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
new MapManager(this);
|
new MapManager(this);
|
||||||
new WorldManager(this);
|
new WorldManager(this);
|
||||||
new JumpManager(this);
|
new JumpManager(this);
|
||||||
|
|
||||||
|
new GadgetManager(this);
|
||||||
|
|
||||||
_partyManager = partyManager;
|
_partyManager = partyManager;
|
||||||
_tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator);
|
_tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator);
|
||||||
@ -539,6 +545,11 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
{
|
{
|
||||||
return _clientManager;
|
return _clientManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConditionManager GetCondition()
|
||||||
|
{
|
||||||
|
return _conditionManager;
|
||||||
|
}
|
||||||
|
|
||||||
public DonationManager GetDonation()
|
public DonationManager GetDonation()
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
package mineplex.hub.gadget;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.MiniPlugin;
|
||||||
|
import mineplex.hub.HubManager;
|
||||||
|
import mineplex.hub.gadget.types.ArmorGadget;
|
||||||
|
import mineplex.hub.gadget.types.ArmorGadget.ArmorSlot;
|
||||||
|
import mineplex.hub.gadget.types.Gadget;
|
||||||
|
import mineplex.hub.gadget.types.ItemGadget;
|
||||||
|
|
||||||
|
public class GadgetManager extends MiniPlugin
|
||||||
|
{
|
||||||
|
public HubManager Manager;
|
||||||
|
|
||||||
|
private HashSet<Gadget> _gadgets;
|
||||||
|
|
||||||
|
public GadgetManager(HubManager manager)
|
||||||
|
{
|
||||||
|
super("Gadget Manager", manager.GetPlugin());
|
||||||
|
|
||||||
|
Manager = manager;
|
||||||
|
|
||||||
|
CreateGadgets();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateGadgets()
|
||||||
|
{
|
||||||
|
_gadgets = new HashSet<Gadget>();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Disallows two armor gadgets in same slot.
|
||||||
|
public void RemoveArmor(Player player, ArmorSlot slot)
|
||||||
|
{
|
||||||
|
for (Gadget gadget : _gadgets)
|
||||||
|
{
|
||||||
|
if (gadget instanceof ArmorGadget)
|
||||||
|
{
|
||||||
|
ArmorGadget armor = (ArmorGadget)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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
package mineplex.hub.gadget.gadgets;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
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 mineplex.core.recharge.Recharge;
|
||||||
|
import mineplex.hub.gadget.GadgetManager;
|
||||||
|
import mineplex.hub.gadget.types.ItemGadget;
|
||||||
|
|
||||||
|
public class Halloween2013_BatGun extends ItemGadget
|
||||||
|
{
|
||||||
|
public Halloween2013_BatGun(GadgetManager manager)
|
||||||
|
{
|
||||||
|
super(manager, "Halloween2013_BatGun", "Bat Gun", Material.COAL_BLOCK, (byte)0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Enable(Player player)
|
||||||
|
{
|
||||||
|
this.ApplyItem(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Disable(Player player)
|
||||||
|
{
|
||||||
|
this.RemoveItem(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void ItemUse(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
if (event.getAction() == Action.PHYSICAL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (!IsActive(player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!Recharge.Instance.use(player, GetName(), 10000, true))
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (int i=0 ; i<10 ; i++)
|
||||||
|
{
|
||||||
|
Bat bat = player.getWorld().spawn(player.getEyeLocation(), Bat.class);
|
||||||
|
bat.setVelocity(player.getLocation().getDirection().multiply(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getWorld().playSound(player.getLocation(), Sound.BAT_TAKEOFF, 2f, 1f);
|
||||||
|
player.getWorld().playSound(player.getLocation(), Sound.BAT_HURT, 2f, 1f);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package mineplex.hub.gadget.gadgets;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import mineplex.hub.gadget.GadgetManager;
|
||||||
|
import mineplex.hub.gadget.types.ArmorGadget;
|
||||||
|
|
||||||
|
public class Halloween2013_Helmet extends ArmorGadget
|
||||||
|
{
|
||||||
|
public Halloween2013_Helmet(GadgetManager manager)
|
||||||
|
{
|
||||||
|
super(manager, "Halloween2013_Helmet", "Pumpkin Helmet", ArmorSlot.Helmet, Material.PUMPKIN, (byte)0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Enable(Player player)
|
||||||
|
{
|
||||||
|
this.ApplyArmor(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Disable(Player player)
|
||||||
|
{
|
||||||
|
this.RemoveArmor(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void Effect(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.FAST)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (Player player : this.GetActive())
|
||||||
|
Manager.Manager.GetCondition().Factory().Invisible(GetName(), player, player, 1.9, 0, false, false, true);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
package mineplex.hub.gadget.types;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import mineplex.hub.gadget.GadgetManager;
|
||||||
|
|
||||||
|
public abstract class ArmorGadget extends Gadget
|
||||||
|
{
|
||||||
|
public enum ArmorSlot
|
||||||
|
{
|
||||||
|
Helmet,
|
||||||
|
Chest,
|
||||||
|
Legs,
|
||||||
|
Boots
|
||||||
|
}
|
||||||
|
|
||||||
|
private HashSet<Player> _active = new HashSet<Player>();
|
||||||
|
|
||||||
|
private ArmorSlot _slot;
|
||||||
|
private Material _material;
|
||||||
|
private byte _data;
|
||||||
|
|
||||||
|
public ArmorGadget(GadgetManager manager, String code, String name, ArmorSlot slot, Material mat, byte data)
|
||||||
|
{
|
||||||
|
super(manager, code, name);
|
||||||
|
|
||||||
|
_slot = slot;
|
||||||
|
_material = mat;
|
||||||
|
_data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashSet<Player> GetActive()
|
||||||
|
{
|
||||||
|
return _active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArmorSlot GetSlot()
|
||||||
|
{
|
||||||
|
return _slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ApplyArmor(Player player)
|
||||||
|
{
|
||||||
|
Manager.RemoveArmor(player, _slot);
|
||||||
|
|
||||||
|
if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(_material, _data, 1, F.item(GetName())));
|
||||||
|
else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(_material, _data, 1, F.item(GetName())));
|
||||||
|
else if (_slot == ArmorSlot.Legs) player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(_material, _data, 1, F.item(GetName())));
|
||||||
|
else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(_material, _data, 1, F.item(GetName())));
|
||||||
|
|
||||||
|
_active.add(player);
|
||||||
|
|
||||||
|
UtilPlayer.message(player, F.main("Gadget", "You put on " + F.elem(GetName()) + "."));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveArmor(Player player)
|
||||||
|
{
|
||||||
|
if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet(null);
|
||||||
|
else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate(null);
|
||||||
|
else if (_slot == ArmorSlot.Legs) player.getInventory().setLeggings(null);
|
||||||
|
else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots(null);
|
||||||
|
|
||||||
|
_active.remove(player);
|
||||||
|
|
||||||
|
UtilPlayer.message(player, F.main("Gadget", "You took off " + F.elem(GetName()) + "."));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
package mineplex.hub.gadget.types;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import mineplex.hub.gadget.GadgetManager;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
public abstract class Gadget implements Listener
|
||||||
|
{
|
||||||
|
public GadgetManager Manager;
|
||||||
|
|
||||||
|
private HashSet<Player> _owners = new HashSet<Player>();
|
||||||
|
|
||||||
|
private String _code;
|
||||||
|
private String _name;
|
||||||
|
|
||||||
|
public Gadget(GadgetManager manager, String code, String name)
|
||||||
|
{
|
||||||
|
Manager = manager;
|
||||||
|
|
||||||
|
_code = code;
|
||||||
|
_name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String GetName()
|
||||||
|
{
|
||||||
|
return _name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String GetCode()
|
||||||
|
{
|
||||||
|
return _code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashSet<Player> GetOwners()
|
||||||
|
{
|
||||||
|
return _owners;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean HasGadget(Player player)
|
||||||
|
{
|
||||||
|
return _owners.contains(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void PlayerJoin(PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
if (event.getPlayer().isOp())
|
||||||
|
{
|
||||||
|
_owners.add(event.getPlayer());
|
||||||
|
|
||||||
|
this.Enable(event.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void PlayerQuit(PlayerQuitEvent event)
|
||||||
|
{
|
||||||
|
_owners.remove(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void Enable(Player player);
|
||||||
|
public abstract void Disable(Player player);
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
package mineplex.hub.gadget.types;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilInv;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import mineplex.hub.gadget.GadgetManager;
|
||||||
|
|
||||||
|
public abstract class ItemGadget extends Gadget
|
||||||
|
{
|
||||||
|
private HashSet<Player> _active = new HashSet<Player>();
|
||||||
|
|
||||||
|
private Material _material;
|
||||||
|
private byte _data;
|
||||||
|
|
||||||
|
public ItemGadget(GadgetManager manager, String code, String name, Material mat, byte data)
|
||||||
|
{
|
||||||
|
super(manager, code, name);
|
||||||
|
|
||||||
|
_material = mat;
|
||||||
|
_data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
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(3, ItemStackFactory.Instance.CreateStack(_material, _data, 1, F.item(GetName())));
|
||||||
|
|
||||||
|
_active.add(player);
|
||||||
|
|
||||||
|
UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(GetName()) + "."));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveItem(Player player)
|
||||||
|
{
|
||||||
|
player.getInventory().setItem(3, null);
|
||||||
|
|
||||||
|
_active.remove(player);
|
||||||
|
|
||||||
|
UtilPlayer.message(player, F.main("Gadget", "You unequipped " + F.elem(GetName()) + "."));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean IsItem(Player player)
|
||||||
|
{
|
||||||
|
return UtilInv.IsItem(player.getItemInHand(), _material, _data);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user