From 1944c0003c8dbbf3db244acf32e1da458f819188 Mon Sep 17 00:00:00 2001 From: Chiss Date: Sat, 19 Oct 2013 16:52:15 +1100 Subject: [PATCH 1/3] Hub gadgets --- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 5 +- .../src/mineplex/hub/HubManager.java | 13 +++- .../mineplex/hub/gadget/GadgetManager.java | 63 ++++++++++++++++ .../gadget/gadgets/Halloween2013_BatGun.java | 57 +++++++++++++++ .../gadget/gadgets/Halloween2013_Helmet.java | 40 ++++++++++ .../hub/gadget/types/ArmorGadget.java | 73 +++++++++++++++++++ .../src/mineplex/hub/gadget/types/Gadget.java | 69 ++++++++++++++++++ .../mineplex/hub/gadget/types/ItemGadget.java | 65 +++++++++++++++++ 8 files changed, 382 insertions(+), 3 deletions(-) create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/Halloween2013_BatGun.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/Halloween2013_Helmet.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ArmorGadget.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/Gadget.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ItemGadget.java diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 83f3bf5ca..7c09216a3 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -39,6 +39,7 @@ import mineplex.minecraft.game.classcombat.shop.ClassCombatShop; import mineplex.minecraft.game.classcombat.shop.ClassShopManager; import mineplex.minecraft.game.core.IRelation; 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.fire.Fire; import nautilus.minecraft.core.INautilusPlugin; @@ -82,7 +83,7 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation PacketHandler packetHandler = new PacketHandler(this); Portal portal = new Portal(this); 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 Chat(this, clientManager); new MemoryFix(this); @@ -104,7 +105,7 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation new ClassCombatShop(shopManager, clientManager, donationManager, "Select Class Here"); new ClassCombatPurchaseShop(shopManager, clientManager, donationManager, "Class Shop"); new ClassCombatCustomBuildShop(shopManager, clientManager, donationManager, "Class Setup"); - + //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index a71004118..c4a966b37 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -53,14 +53,17 @@ import mineplex.core.portal.Portal; import mineplex.core.task.TaskManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.gadget.GadgetManager; import mineplex.hub.modules.*; import mineplex.hub.party.Party; import mineplex.hub.party.PartyManager; import mineplex.hub.tutorial.TutorialManager; +import mineplex.minecraft.game.core.condition.ConditionManager; public class HubManager extends MiniClientPlugin { private CoreClientManager _clientManager; + private ConditionManager _conditionManager; private DonationManager _donationManager; private DisguiseManager _disguiseManager; private PartyManager _partyManager; @@ -83,11 +86,12 @@ public class HubManager extends MiniClientPlugin 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); _clientManager = clientManager; + _conditionManager = conditionManager; _donationManager = donationManager; _disguiseManager = disguiseManager; _portal = portal; @@ -101,6 +105,8 @@ public class HubManager extends MiniClientPlugin new MapManager(this); new WorldManager(this); new JumpManager(this); + + new GadgetManager(this); _partyManager = partyManager; _tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator); @@ -539,6 +545,11 @@ public class HubManager extends MiniClientPlugin { return _clientManager; } + + public ConditionManager GetCondition() + { + return _conditionManager; + } public DonationManager GetDonation() { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java new file mode 100644 index 000000000..54cad633b --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java @@ -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 _gadgets; + + public GadgetManager(HubManager manager) + { + super("Gadget Manager", manager.GetPlugin()); + + Manager = manager; + + CreateGadgets(); + } + + private void CreateGadgets() + { + _gadgets = new HashSet(); + } + + //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); + } + } + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/Halloween2013_BatGun.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/Halloween2013_BatGun.java new file mode 100644 index 000000000..280181d1c --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/Halloween2013_BatGun.java @@ -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); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/Halloween2013_Helmet.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/Halloween2013_Helmet.java new file mode 100644 index 000000000..71b8b8b36 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/Halloween2013_Helmet.java @@ -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); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ArmorGadget.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ArmorGadget.java new file mode 100644 index 000000000..03e55b265 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ArmorGadget.java @@ -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 _active = new HashSet(); + + 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 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()) + ".")); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/Gadget.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/Gadget.java new file mode 100644 index 000000000..e90a442b5 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/Gadget.java @@ -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 _owners = new HashSet(); + + 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 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); +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ItemGadget.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ItemGadget.java new file mode 100644 index 000000000..043ccb00d --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ItemGadget.java @@ -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 _active = new HashSet(); + + 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 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); + } +} From 1977572ced0c6d65a1bdd15e29154fcaae81ba46 Mon Sep 17 00:00:00 2001 From: Chiss Date: Tue, 22 Oct 2013 15:46:31 +1100 Subject: [PATCH 2/3] Added Halloween Minigame Updated gadgets and other minor things. --- .../core/common/util/UtilDisplay.java | 191 +++++ .../mineplex/core/common/util/UtilEnt.java | 13 + .../src/mineplex/core/antihack/AntiHack.java | 2 +- .../src/mineplex/core/chat/Chat.java | 10 + .../core/chat/command/FilterChatCommand.java | 2 +- .../mineplex/core/explosion/Explosion.java | 7 +- Plugins/Mineplex.Hub/.classpath | 2 +- .../Mineplex.Hub/src/mineplex/hub/Dragon.java | 202 ------ .../Mineplex.Hub/src/mineplex/hub/Hub.java | 4 +- .../src/mineplex/hub/HubManager.java | 13 +- .../mineplex/hub/gadget/GadgetManager.java | 5 + .../src/mineplex/hub/gadget/types/Gadget.java | 4 +- .../src/mineplex/hub/modules/NewsManager.java | 71 ++ .../mineplex/hub/modules/WorldManager.java | 94 ++- .../.classpath | 2 +- .../Mineplex.Minecraft.Game.Core/.classpath | 2 +- Plugins/Nautilus.Game.Arcade/.classpath | 4 +- .../src/nautilus/game/arcade/GameFactory.java | 2 + .../src/nautilus/game/arcade/GameType.java | 1 + .../game/games/dragonescape/DragonEscape.java | 2 +- .../games/dragonescape/DragonEscapeData.java | 2 - .../game/games/dragonriders/DragonData.java | 2 +- .../game/games/halloween/Halloween.java | 279 ++++++++ .../game/games/halloween/TargetData.java | 20 + .../halloween/creatures/CreatureBase.java | 110 +++ .../games/halloween/creatures/MobCreeper.java | 87 +++ .../games/halloween/creatures/MobGhast.java | 57 ++ .../games/halloween/creatures/MobGiant.java | 85 +++ .../creatures/MobSkeletonArcher.java | 89 +++ .../games/halloween/creatures/MobSpider.java | 112 +++ .../games/halloween/creatures/MobZombie.java | 87 +++ .../halloween/creatures/PumpkinKing.java | 673 ++++++++++++++++++ .../game/games/halloween/kits/KitDefault.java | 60 ++ .../game/games/smash/kits/KitGolem.java | 2 +- .../game/arcade/kit/perks/PerkWolf.java | 1 + .../worldevent/creature/BroodMother.java.orig | 366 ---------- 36 files changed, 2065 insertions(+), 600 deletions(-) create mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilDisplay.java delete mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/Dragon.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/TargetData.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/CreatureBase.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobCreeper.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobGhast.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobGiant.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSkeletonArcher.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSpider.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobZombie.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/PumpkinKing.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitDefault.java delete mode 100644 Plugins/Nautilus.Game.PvP/src/nautilus/game/pvp/worldevent/creature/BroodMother.java.orig diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilDisplay.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilDisplay.java new file mode 100644 index 000000000..055025dc3 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilDisplay.java @@ -0,0 +1,191 @@ +package mineplex.core.common.util; + +import java.lang.reflect.Field; +import java.util.HashMap; + +import net.minecraft.server.v1_6_R3.DataWatcher; +import net.minecraft.server.v1_6_R3.EntityPlayer; +import net.minecraft.server.v1_6_R3.Packet; +import net.minecraft.server.v1_6_R3.Packet205ClientCommand; +import net.minecraft.server.v1_6_R3.Packet24MobSpawn; +import net.minecraft.server.v1_6_R3.Packet29DestroyEntity; +import net.minecraft.server.v1_6_R3.Packet40EntityMetadata; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; + +public class UtilDisplay +{ + public static final int ENTITY_ID = 1234; + + private static HashMap hasHealthBar = new HashMap(); + + public static void sendPacket(Player player, Packet packet){ + EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); + + entityPlayer.playerConnection.sendPacket(packet); + } + + //Accessing packets + public static Packet24MobSpawn getMobPacket(String text, double healthPercent, Location loc){ + Packet24MobSpawn mobPacket = new Packet24MobSpawn(); + + mobPacket.a = (int) ENTITY_ID; //Entity ID + mobPacket.b = (byte) EntityType.ENDER_DRAGON.getTypeId(); //Mob type (ID: 64) + mobPacket.c = (int) Math.floor(loc.getBlockX() * 32.0D); //X position + mobPacket.d = (int) -200; //Y position + mobPacket.e = (int) Math.floor(loc.getBlockZ() * 32.0D); //Z position + mobPacket.f = (byte) 0; //Pitch + mobPacket.g = (byte) 0; //Head Pitch + mobPacket.h = (byte) 0; //Yaw + mobPacket.i = (short) 0; //X velocity + mobPacket.j = (short) 0; //Y velocity + mobPacket.k = (short) 0; //Z velocity + + DataWatcher watcher = getWatcher(text, healthPercent * 200); + + try{ + Field t = Packet24MobSpawn.class.getDeclaredField("t"); + + t.setAccessible(true); + t.set(mobPacket, watcher); + } catch(Exception e){ + e.printStackTrace(); + } + + return mobPacket; + } + + public static Packet29DestroyEntity getDestroyEntityPacket(){ + Packet29DestroyEntity packet = new Packet29DestroyEntity(); + + packet.a = new int[]{ENTITY_ID}; + + return packet; + } + + public static Packet40EntityMetadata getMetadataPacket(DataWatcher watcher){ + Packet40EntityMetadata metaPacket = new Packet40EntityMetadata(); + + metaPacket.a = (int) ENTITY_ID; + + try{ + Field b = Packet40EntityMetadata.class.getDeclaredField("b"); + + b.setAccessible(true); + b.set(metaPacket, watcher.c()); + } catch(Exception e){ + e.printStackTrace(); + } + + return metaPacket; + } + + public static Packet205ClientCommand getRespawnPacket(){ + Packet205ClientCommand packet = new Packet205ClientCommand(); + + packet.a = (int) 1; + + return packet; + } + + public static DataWatcher getWatcher(String text, double health){ + DataWatcher watcher = new DataWatcher(); + + watcher.a(0, (Byte) (byte) 0x20); //Flags, 0x20 = invisible + watcher.a(6, (Float) (float) health); + watcher.a(10, (String) text); //Entity name + watcher.a(11, (Byte) (byte) 1); //Show name, 1 = show, 0 = don't show + watcher.a(16, (Integer) (int) health); //Wither health, 200 = full health + + return watcher; + } + + //Other methods + public static void displayTextBar(JavaPlugin plugin, final Player player, double healthPercent, String text) + { + Packet24MobSpawn mobPacket = getMobPacket(text, healthPercent, player.getLocation()); + + sendPacket(player, mobPacket); + hasHealthBar.put(player.getName(), true); + + new BukkitRunnable(){ + @Override + public void run(){ + Packet29DestroyEntity destroyEntityPacket = getDestroyEntityPacket(); + + sendPacket(player, destroyEntityPacket); + hasHealthBar.put(player.getName(), false); + } + }.runTaskLater(plugin, 120L); + } + + public static void displayLoadingBar(final String text, final String completeText, final Player player, final int healthAdd, final long delay, final boolean loadUp, final JavaPlugin plugin){ + Packet24MobSpawn mobPacket = getMobPacket(text, 0, player.getLocation()); + + sendPacket(player, mobPacket); + hasHealthBar.put(player.getName(), true); + + new BukkitRunnable(){ + int health = (loadUp ? 0 : 200); + + @Override + public void run(){ + if((loadUp ? health < 200 : health > 0)){ + DataWatcher watcher = getWatcher(text, health); + Packet40EntityMetadata metaPacket = getMetadataPacket(watcher); + + sendPacket(player, metaPacket); + + if(loadUp){ + health += healthAdd; + } else { + health -= healthAdd; + } + } else { + DataWatcher watcher = getWatcher(text, (loadUp ? 200 : 0)); + Packet40EntityMetadata metaPacket = getMetadataPacket(watcher); + Packet29DestroyEntity destroyEntityPacket = getDestroyEntityPacket(); + + sendPacket(player, metaPacket); + sendPacket(player, destroyEntityPacket); + hasHealthBar.put(player.getName(), false); + + //Complete text + Packet24MobSpawn mobPacket = getMobPacket(completeText, 100, player.getLocation()); + + sendPacket(player, mobPacket); + hasHealthBar.put(player.getName(), true); + + DataWatcher watcher2 = getWatcher(completeText, 200); + Packet40EntityMetadata metaPacket2 = getMetadataPacket(watcher2); + + sendPacket(player, metaPacket2); + + new BukkitRunnable(){ + @Override + public void run(){ + Packet29DestroyEntity destroyEntityPacket = getDestroyEntityPacket(); + + sendPacket(player, destroyEntityPacket); + hasHealthBar.put(player.getName(), false); + } + }.runTaskLater(plugin, 40L); + + this.cancel(); + } + } + }.runTaskTimer(plugin, delay, delay); + } + + public static void displayLoadingBar(final String text, final String completeText, final Player player, final int secondsDelay, final boolean loadUp, JavaPlugin plugin){ + final int healthChangePerSecond = 200 / secondsDelay; + + displayLoadingBar(text, completeText, player, healthChangePerSecond, 20L, loadUp, plugin); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java index 91eb6d961..21494a340 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java @@ -401,8 +401,21 @@ public class UtilEnt { for (int z=zMin ; z<=zMax ; z++) { + //half block, carpet, snow, etc + //if (player.getLocation().getBlock().getType() != Material.AIR) + // return true; + + //standing on... if (player.getLocation().add(x, -0.5, z).getBlock().getType() != Material.AIR) return true; + + //fences/walls + Material beneath = player.getLocation().add(x, -1.5, z).getBlock().getType(); + if (player.getLocation().getY() % 0.5 == 0 && + (beneath == Material.FENCE || + beneath == Material.NETHER_FENCE || + beneath == Material.COBBLE_WALL)) + return true; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 1f0bbf8bb..b4e3ca9f6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -172,7 +172,7 @@ public class AntiHack extends MiniPlugin (_ignore.containsKey(player) && System.currentTimeMillis() < _ignore.get(player))) //Ignore { _speedTicks.remove(player); - return; + return; } UpdateSpeed(player, event); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index e1f84e4a8..3469fcc6c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -70,6 +70,16 @@ public class Chat extends MiniPlugin } } + @EventHandler + public void lagTest(PlayerCommandPreprocessEvent event) + { + if (event.getMessage().equals("lag") || event.getMessage().equals("ping")) + { + event.getPlayer().sendMessage(F.main(GetName(), "PONG!")); + event.setCancelled(true); + } + } + @EventHandler public void SilenceUpdate(UpdateEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/command/FilterChatCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/command/FilterChatCommand.java index ac05c1877..dda7b90cf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/command/FilterChatCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/command/FilterChatCommand.java @@ -16,6 +16,6 @@ public class FilterChatCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - Plugin.Get(caller).ToggleFilterChat(); + //Plugin.Get(caller).ToggleFilterChat(); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java index 09ac5ea65..7ef4f5eaa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java @@ -273,7 +273,7 @@ public class Explosion extends MiniPlugin return _explosionBlocks; } - public void BlockExplosion(Collection blockSet, Location mid) + public void BlockExplosion(Collection blockSet, Location mid, boolean onlyAbove) { if (blockSet.isEmpty()) return; @@ -286,10 +286,13 @@ public class Explosion extends MiniPlugin if (cur.getTypeId() == 0) continue; + if (onlyAbove && cur.getY() < mid.getY()) + continue; + blocks.put(cur, new AbstractMap.SimpleEntry(cur.getTypeId(), cur.getData())); if (cur.getTypeId() != 98 || cur.getData() != 0) - cur.setTypeId(0); + cur.setType(Material.AIR); } //DELAY diff --git a/Plugins/Mineplex.Hub/.classpath b/Plugins/Mineplex.Hub/.classpath index 8147b149b..72429f1b6 100644 --- a/Plugins/Mineplex.Hub/.classpath +++ b/Plugins/Mineplex.Hub/.classpath @@ -4,12 +4,12 @@ - + diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Dragon.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Dragon.java deleted file mode 100644 index 51dc1420e..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Dragon.java +++ /dev/null @@ -1,202 +0,0 @@ -package mineplex.hub; - -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilWorld; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEnderDragon; -import org.bukkit.entity.EnderDragon; -import org.bukkit.entity.Entity; -import org.bukkit.event.EventHandler; -import org.bukkit.util.Vector; - -public class Dragon extends MiniPlugin -{ - HubManager Manager; - - public EnderDragon Dragon = null; - - public Entity TargetEntity = null; - - public Location Target = null; - public Location Location = null; - - public float Pitch = 0; - public Vector Velocity = new Vector(0,0,0); - - public double RangeBest = 1000; - public long RangeTime = 0; - - public int textA = 0; - public int textB = 0; - - public Dragon(HubManager manager) - { - super("Dragon Manager", manager.GetPlugin()); - - Manager = manager; - } - - public void Spawn() - { - if (Dragon != null) - Dragon.remove(); - - if (UtilServer.getPlayers().length == 0) - return; - - if (!Manager.GetSpawn().getWorld().isChunkLoaded(Manager.GetSpawn().getChunk())) - return; - - for (Entity ent : Manager.GetSpawn().getWorld().getEntities()) - { - if (ent instanceof EnderDragon) - ent.remove(); - } - - Dragon = Manager.GetSpawn().getWorld().spawn(Manager.GetSpawn().add(0, 50, 0), EnderDragon.class); - UtilEnt.Vegetate(Dragon); - - Dragon.setCustomName(C.cGreen + C.Bold + "The Mineplex Dragon"); - - Velocity = Dragon.getLocation().getDirection().setY(0).normalize(); - Pitch = UtilAlg.GetPitch(Dragon.getLocation().getDirection()); - - Location = Dragon.getLocation(); - - TargetSky(); - } - - @EventHandler - public void MoveUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - if (Dragon == null || !Dragon.isValid()) - { - //Spawn(); - return; - } - - Turn(); - - Location.add(Velocity); - Location.add(0, -Pitch, 0); - - Location.setPitch(-1 * Pitch); - Location.setYaw(180 + UtilAlg.GetYaw(Velocity)); - - ((CraftEnderDragon)Dragon).getHandle().setTargetBlock(Location.getBlockX(), Location.getBlockY(), Location.getBlockZ()); - } - - @EventHandler - public void ColorEvent(UpdateEvent event) - { - if (event.getType() != UpdateType.FASTEST) - return; - - if (Dragon == null || !Dragon.isValid()) - return; - - ChatColor aCol = ChatColor.RED; - if (textA == 1) aCol = ChatColor.GOLD; - else if (textA == 2) aCol = ChatColor.YELLOW; - else if (textA == 3) aCol = ChatColor.GREEN; - else if (textA == 4) aCol = ChatColor.AQUA; - else if (textA == 5) aCol = ChatColor.LIGHT_PURPLE; - - textA = (textA+1)%6; - - ChatColor bCol = ChatColor.GREEN; - if (textB > 6) bCol = ChatColor.WHITE; - - textB = (textB+1)%14; - - Dragon.setCustomName(aCol + C.Bold + C.Line + Manager.DragonTextA +ChatColor.RESET + " - " + bCol + C.Bold + C.Line + Manager.DragonTextB); - } - - private void Turn() - { - //Pitch - float desiredPitch = UtilAlg.GetPitch(UtilAlg.getTrajectory(Location, Target)); - if (desiredPitch < Pitch) Pitch = (float)(Pitch - 0.05); - if (desiredPitch > Pitch) Pitch = (float)(Pitch + 0.05); - if (Pitch > 0.5) Pitch = 0.5f; - if (Pitch < -0.5) Pitch = -0.5f; - - //Flat - Vector desired = UtilAlg.getTrajectory2d(Location, Target); - desired.subtract(UtilAlg.Normalize(new Vector(Velocity.getX(), 0, Velocity.getZ()))); - desired.multiply(0.075); - - Velocity.add(desired); - - //Speed - UtilAlg.Normalize(Velocity); - } - - public void Target() - { - if (TargetEntity != null) - { - if (!TargetEntity.isValid()) - { - TargetEntity = null; - } - else - { - Target = TargetEntity.getLocation().subtract(0, 8, 0); - } - - return; - } - - if (Target == null) - { - TargetSky(); - } - - if (UtilMath.offset(Location, Target) < 10) - { - TargetSky(); - } - - TargetTimeout(); - } - - public void TargetTimeout() - { - if (UtilMath.offset(Location, Target)+1 < RangeBest) - { - RangeTime = System.currentTimeMillis(); - RangeBest = UtilMath.offset(Location, Target); - } - else - { - if (UtilTime.elapsed(RangeTime, 10000)) - { - TargetSky(); - } - } - } - - public void TargetSky() - { - RangeBest = 9000; - RangeTime = System.currentTimeMillis(); - - Target = Manager.GetSpawn().add(40 - UtilMath.r(80), 50 + UtilMath.r(30), 40 - UtilMath.r(80)); - - System.out.println("Dragon flying to: " + UtilWorld.locToStrClean(Target)); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 7c09216a3..37115c414 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -80,10 +80,10 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation new PetManager(this, clientManager, donationManager, creature, GetWebServerAddress()); //Main Modules - PacketHandler packetHandler = new PacketHandler(this); + PacketHandler packetHandler = new PacketHandler(this); Portal portal = new Portal(this); PartyManager partyManager = new PartyManager(this, clientManager); - HubManager hubManager = new HubManager(this, clientManager, donationManager, new ConditionManager(this), new DisguiseManager(this, packetHandler), new TaskManager(this, GetWebServerAddress()), portal, partyManager); + HubManager hubManager = new HubManager(this, new BlockRestore(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 Chat(this, clientManager); new MemoryFix(this); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index c4a966b37..66f796bf9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -38,6 +38,7 @@ import org.bukkit.scoreboard.Scoreboard; import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -62,6 +63,9 @@ import mineplex.minecraft.game.core.condition.ConditionManager; public class HubManager extends MiniClientPlugin { + public String Mode = "Halloween"; + + private BlockRestore _blockRestore; private CoreClientManager _clientManager; private ConditionManager _conditionManager; private DonationManager _donationManager; @@ -86,10 +90,11 @@ public class HubManager extends MiniClientPlugin private boolean _shuttingDown; - public HubManager(JavaPlugin plugin, 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); + _blockRestore = blockRestore; _clientManager = clientManager; _conditionManager = conditionManager; _donationManager = donationManager; @@ -105,6 +110,7 @@ public class HubManager extends MiniClientPlugin new MapManager(this); new WorldManager(this); new JumpManager(this); + new NewsManager(this); new GadgetManager(this); @@ -540,6 +546,11 @@ public class HubManager extends MiniClientPlugin { return new HubClient(player); } + + public BlockRestore GetBlockRestore() + { + return _blockRestore; + } public CoreClientManager GetClients() { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java index 54cad633b..7ae6ccaaf 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java @@ -6,6 +6,8 @@ import org.bukkit.entity.Player; import mineplex.core.MiniPlugin; import mineplex.hub.HubManager; +import mineplex.hub.gadget.gadgets.Halloween2013_BatGun; +import mineplex.hub.gadget.gadgets.Halloween2013_Helmet; import mineplex.hub.gadget.types.ArmorGadget; import mineplex.hub.gadget.types.ArmorGadget.ArmorSlot; import mineplex.hub.gadget.types.Gadget; @@ -29,6 +31,9 @@ public class GadgetManager extends MiniPlugin private void CreateGadgets() { _gadgets = new HashSet(); + + _gadgets.add(new Halloween2013_BatGun(this)); + _gadgets.add(new Halloween2013_Helmet(this)); } //Disallows two armor gadgets in same slot. diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/Gadget.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/Gadget.java index e90a442b5..dc214577d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/Gadget.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/Gadget.java @@ -25,6 +25,8 @@ public abstract class Gadget implements Listener _code = code; _name = name; + + Manager.GetPlugin().getServer().getPluginManager().registerEvents(this, Manager.GetPlugin()); } public String GetName() @@ -53,8 +55,6 @@ public abstract class Gadget implements Listener if (event.getPlayer().isOp()) { _owners.add(event.getPlayer()); - - this.Enable(event.getPlayer()); } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java new file mode 100644 index 000000000..9cb986066 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java @@ -0,0 +1,71 @@ +package mineplex.hub.modules; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilDisplay; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.HubManager; + +public class NewsManager extends MiniPlugin +{ + public HubManager Manager; + + private String[] _news; + private int _newsIndex = 0; + private long _newsTime = System.currentTimeMillis(); + + private int _mineplexIndex = 0; + + public NewsManager(HubManager manager) + { + super("News Manager", manager.GetPlugin()); + + Manager = manager; + + _news = new String[] + { + "New Game: " + C.cRed + C.Bold + "Halloween Horror" + ChatColor.RESET + "! Limited time!", + "Halloween Hub Gadgets! Unlockable for limited time!", + "New Super Smash Mobs Kit: " + C.cYellow + C.Bold + "Witch" + ChatColor.RESET + "!" + }; + } + + @EventHandler + public void FlightUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + return; + + //Mineplex Color + ChatColor col = ChatColor.RED; + if (_mineplexIndex == 1) col = ChatColor.GOLD; + else if (_mineplexIndex == 2) col = ChatColor.YELLOW; + else if (_mineplexIndex == 3) col = ChatColor.GREEN; + else if (_mineplexIndex == 4) col = ChatColor.AQUA; + else if (_mineplexIndex == 5) col = ChatColor.LIGHT_PURPLE; + _mineplexIndex = (_mineplexIndex + 1)%6; + + //News Change + if (UtilTime.elapsed(_newsTime, 3000)) + { + _newsIndex = (_newsIndex + 1)%_news.length; + _newsTime = System.currentTimeMillis(); + } + + //Text + String text = col + C.Bold + "MINEPLEX" + ChatColor.RESET + " - " + _news[_newsIndex]; + if (text.length() > 64) + text = text.substring(0, 64); + + for (Player player : UtilServer.getPlayers()) + UtilDisplay.displayTextBar(Manager.GetPlugin(), player, (double)_newsIndex/(double)(_news.length-1), text); + } + +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java index e72d9b37e..53ba535e9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java @@ -4,21 +4,31 @@ import java.util.HashSet; import java.util.Iterator; import mineplex.core.MiniPlugin; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilWorld; +import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.HubManager; +import net.minecraft.server.v1_6_R3.EntitySkeleton; import org.bukkit.GameMode; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_6_R3.entity.CraftSkeleton; import org.bukkit.entity.Chicken; import org.bukkit.entity.Cow; +import org.bukkit.entity.Creature; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Pig; import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Skeleton.SkeletonType; +import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; @@ -34,14 +44,14 @@ public class WorldManager extends MiniPlugin public HubManager Manager; private HashSet _mobs = new HashSet(); - + public WorldManager(HubManager manager) { super("World Manager", manager.GetPlugin()); - + Manager = manager; } - + @EventHandler public void SpawnAnimals(UpdateEvent event) { @@ -75,13 +85,30 @@ public class WorldManager extends MiniPlugin else loc.add(0, 0.5, -32); //Spawn - r = Math.random(); + if (Manager.Mode.equals("Halloween")) + { + Skeleton ent = loc.getWorld().spawn(loc, Skeleton.class); - if (r > 0.66) _mobs.add(loc.getWorld().spawn(loc, Cow.class)); - else if (r > 0.33) _mobs.add(loc.getWorld().spawn(loc, Pig.class)); - else _mobs.add(loc.getWorld().spawn(loc, Chicken.class)); + if (Math.random() > 0.5) + ent.setSkeletonType(SkeletonType.WITHER); + + ent.getEquipment().setHelmet(ItemStackFactory.Instance.CreateStack(Material.PUMPKIN)); + + _mobs.add(ent); + + Manager.GetCondition().Factory().Invisible("Perm", ent, ent, 999999999, 0, false, false, true); + Manager.GetCondition().Factory().Slow("Perm", ent, ent, 999999999, 1, false, false, false, true); + } + else + { + r = Math.random(); + + if (r > 0.66) _mobs.add(loc.getWorld().spawn(loc, Cow.class)); + else if (r > 0.33) _mobs.add(loc.getWorld().spawn(loc, Pig.class)); + else _mobs.add(loc.getWorld().spawn(loc, Chicken.class)); + } } - + @EventHandler public void BlockBreak(BlockBreakEvent event) { @@ -102,7 +129,7 @@ public class WorldManager extends MiniPlugin { event.setCancelled(true); } - + @EventHandler public void LeaveDecay(LeavesDecayEvent event) { @@ -134,7 +161,7 @@ public class WorldManager extends MiniPlugin } } } - + @EventHandler(priority = EventPriority.LOW) public void ItemPickup(PlayerPickupItemEvent event) { @@ -152,15 +179,56 @@ public class WorldManager extends MiniPlugin event.setCancelled(true); } - + @EventHandler public void UpdateWeather(UpdateEvent event) { - if (event.getType() != UpdateType.SEC) + if (event.getType() != UpdateType.TICK) return; World world = UtilWorld.getWorld("world"); - world.setTime(6000); + + if (Manager.Mode.equals("Halloween")) world.setTime(16000); + else world.setTime(6000); + world.setStorm(false); } + + @EventHandler + public void HalloweenUpdates(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (!Manager.Mode.equals("Halloween")) + return; + + //Block Lightup + for (Player player : UtilServer.getPlayers()) + { + for (Block block : UtilBlock.getInRadius(player.getLocation(), 3d).keySet()) + { + if (block.getType() == Material.PUMPKIN) + Manager.GetBlockRestore().Add(block, 91, block.getData(), 2000); + } + } + + //Mob Helmets + for (LivingEntity ent : _mobs) + { + if (!(ent instanceof Creature)) + continue; + + Creature skel = (Creature)ent; + + if (skel.getTarget() != null && skel.getTarget() instanceof Player && UtilMath.offset(skel, skel.getTarget()) < 6) + { + skel.getEquipment().setHelmet(ItemStackFactory.Instance.CreateStack(Material.JACK_O_LANTERN)); + } + else + { + skel.getEquipment().setHelmet(ItemStackFactory.Instance.CreateStack(Material.PUMPKIN)); + } + } + } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/.classpath b/Plugins/Mineplex.Minecraft.Game.ClassCombat/.classpath index 8bb62ab28..aa32c3000 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/.classpath +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/.classpath @@ -5,7 +5,7 @@ - + diff --git a/Plugins/Mineplex.Minecraft.Game.Core/.classpath b/Plugins/Mineplex.Minecraft.Game.Core/.classpath index 94c68654f..18dfff3dc 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/.classpath +++ b/Plugins/Mineplex.Minecraft.Game.Core/.classpath @@ -3,8 +3,8 @@ - + diff --git a/Plugins/Nautilus.Game.Arcade/.classpath b/Plugins/Nautilus.Game.Arcade/.classpath index 11dbd4e6d..3d5304c8c 100644 --- a/Plugins/Nautilus.Game.Arcade/.classpath +++ b/Plugins/Nautilus.Game.Arcade/.classpath @@ -2,12 +2,12 @@ - - + + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java index a5a7f8a8b..4d46d2c7d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java @@ -14,6 +14,7 @@ import nautilus.game.arcade.game.games.dragonescape.DragonEscape; import nautilus.game.arcade.game.games.dragonriders.DragonRiders; import nautilus.game.arcade.game.games.dragons.Dragons; import nautilus.game.arcade.game.games.evolution.Evolution; +import nautilus.game.arcade.game.games.halloween.Halloween; import nautilus.game.arcade.game.games.hungergames.HungerGames; import nautilus.game.arcade.game.games.milkcow.MilkCow; import nautilus.game.arcade.game.games.mineware.MineWare; @@ -50,6 +51,7 @@ public class GameFactory else if (gameType == GameType.DragonEscape) return new DragonEscape(_manager); else if (gameType == GameType.DragonRiders) return new DragonRiders(_manager); else if (gameType == GameType.Evolution) return new Evolution(_manager); + else if (gameType == GameType.Halloween) return new Halloween(_manager); else if (gameType == GameType.HungerGames) return new HungerGames(_manager); else if (gameType == GameType.MineWare) return new MineWare(_manager); else if (gameType == GameType.MilkCow) return new MilkCow(_manager); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index e14066c82..51c44ce96 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -12,6 +12,7 @@ public enum GameType DragonRiders("Dragon Riders"), Dragons("Dragons"), Evolution("Evolution"), + Halloween("Halloween Horror"), Horse("Horseback"), HungerGames("Hunger Games"), MineWare("MineWare"), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java index 2a7d04113..a8b0bbb20 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java @@ -149,7 +149,7 @@ public class DragonEscape extends SoloGame _dragonData.Move(); - Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(_dragonData.Location, 10d).keySet(), _dragonData.Location); + Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(_dragonData.Location, 10d).keySet(), _dragonData.Location, false); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeData.java index 83b55c7d2..47ec44048 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeData.java @@ -66,8 +66,6 @@ public class DragonEscapeData Location.setYaw(180 + UtilAlg.GetYaw(Velocity)); Dragon.teleport(Location); - - System.out.println("Flying towards: " + UtilWorld.locToStrClean(Target)); } private void Turn() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonriders/DragonData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonriders/DragonData.java index 06897a36e..34247d9e8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonriders/DragonData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonriders/DragonData.java @@ -53,7 +53,7 @@ public class DragonData { ((CraftEnderDragon)Dragon).getHandle().setTargetBlock(GetTarget().getBlockX(), GetTarget().getBlockY(), GetTarget().getBlockZ()); - Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(Dragon.getLocation(), 10d).keySet(), Dragon.getLocation()); + Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(Dragon.getLocation(), 10d).keySet(), Dragon.getLocation(), false); } public Location GetTarget() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java new file mode 100644 index 000000000..8eab25368 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java @@ -0,0 +1,279 @@ +package nautilus.game.arcade.game.games.halloween; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.*; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.entity.ItemSpawnEvent; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.halloween.creatures.*; +import nautilus.game.arcade.game.games.halloween.kits.KitDefault; +import nautilus.game.arcade.game.games.spleef.kits.*; +import nautilus.game.arcade.kit.Kit; +public class Halloween extends SoloGame +{ + private ArrayList> _spawns; + private int _spawnWave = 0; + private int _spawnTick = 0; + + private String _waveName = ""; + private int _wave = 0; + private long _waveStart = 0; + private long _waveDuration = 0; + + private PumpkinKing _king; + + private HashSet _mobs = new HashSet(); + + public Halloween(ArcadeManager manager) + { + super(manager, GameType.Halloween, + + new Kit[] + { + new KitDefault(manager) + }, + + new String[] + { + "Work as a team!", + "Revive fallen allies!", + "Defeat the hordes of monsters" + }); + + this.DamagePvP = false; + + this.WorldTimeSet = 16000; + + this.ItemDrop = true; + this.ItemPickup = true; + + this.PrepareFreeze = false; + } + + @Override + public void ParseData() + { + _spawns = new ArrayList>(); + _spawns.add(WorldData.GetDataLocs("RED")); + _spawns.add(WorldData.GetDataLocs("YELLOW")); + _spawns.add(WorldData.GetDataLocs("GREEN")); + _spawns.add(WorldData.GetDataLocs("BLUE")); + } + + @EventHandler + public void TeamGen(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + return; + + GetTeamList().add(new GameTeam("Halloween Monsters", ChatColor.RED, WorldData.GetDataLocs("RED"))); + } + + @EventHandler + public void SoundUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOW) + return; + + if (!IsLive()) + return; + + if (Math.random() > 0.85) + return; + + for (Player player : UtilServer.getPlayers()) + player.playSound(player.getLocation(), Sound.AMBIENCE_CAVE, 3f, 1f); + } + + @EventHandler + public void UpdateWave(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (!IsLive()) + return; + + //Display Remaining Time + if (_wave > 0) + for (Player player : UtilServer.getPlayers()) + { + player.setExp(Math.min(0.999f, (float)(_waveDuration - (System.currentTimeMillis() - _waveStart)) / (float)_waveDuration)); + player.setLevel(_wave); + } + + if (!UtilTime.elapsed(_waveStart, _waveDuration) || (_wave == 4 && !_king.GetEntity().isValid())) + return; + + _wave = _wave + 1; + _waveStart = System.currentTimeMillis(); + _waveDuration = 60000; + _spawnTick = 0; + + _spawnWave = UtilMath.r(_spawns.size()); + + if (_wave == 1) _waveName = "Zombies, Skeletons and Creepers, OH MY!"; + if (_wave == 2) _waveName = "A Giant? Better kill that guy!"; + if (_wave == 3) _waveName = "SPIDERS SPIDERS SPIDERS!!!!!"; + if (_wave == 4) _waveName = "THE SKELETON KING EMERGES"; + + if (_wave <= 4) + Announce(C.cRed + C.Bold + "Wave " + _wave + ": " + C.cYellow + _waveName); + } + + public Location GetSpawn() + { + return _spawns.get(_spawnWave).get(UtilMath.r(_spawns.get(_spawnWave).size())); + } + + @EventHandler + public void SpawnCreatures(UpdateEvent event) + { + //Boss Swarm + if (event.getType() == UpdateType.SEC && _wave == 4 && _mobs.size() < 20) + { + Location loc = _spawns.get(UtilMath.r(_spawns.size())).get(UtilMath.r(_spawns.get(_spawnWave).size())); + _mobs.add(new MobZombie(this, loc)); + } + + if (event.getType() != UpdateType.FAST) + return; + + if (!IsLive()) + return; + + this.CreatureAllowOverride = true; + + //Plain + if (_wave == 1) + { + if (UtilTime.elapsed(_waveStart, 12000 + (_wave * 2000))) + return; + + _mobs.add(new MobZombie(this, GetSpawn())); + + if (_spawnTick % 3 == 0) + _mobs.add(new MobSkeletonArcher(this, GetSpawn())); + + if (_spawnTick % 5 == 0) + _mobs.add(new MobCreeper(this, GetSpawn())); + } + //Single Giant + if (_wave == 2) + { + _mobs.add(new MobZombie(this, GetSpawn())); + + if (_spawnTick % 3 == 0) + _mobs.add(new MobSkeletonArcher(this, GetSpawn())); + + if (_spawnTick % 5 == 0) + _mobs.add(new MobCreeper(this, GetSpawn())); + + if (_spawnTick == 0) + _mobs.add(new MobGiant(this, GetSpawn())); + } + //Spiders + if (_wave == 3) + { + _mobs.add(new MobSpider(this, GetSpawn())); + _mobs.add(new MobSpider(this, GetSpawn())); + } + //Quad Giant + if (_wave == 4) + { + if (_spawnTick == 0) + { + _waveDuration = 900000; + _king = new PumpkinKing(this, WorldData.GetDataLocs("BLACK").get(0)); + _mobs.add(_king); + } + } + + this.CreatureAllowOverride = false; + + _spawnTick++; + } + + @EventHandler + public void CreatureUpdate(UpdateEvent event) + { + if (!IsLive()) + return; + + //Clean + Iterator mobIterator = _mobs.iterator(); + while (mobIterator.hasNext()) + { + CreatureBase base = mobIterator.next(); + + if (base.Updater(event)) + mobIterator.remove(); + } + } + + @EventHandler + public void CreatureDamage(CustomDamageEvent event) + { + for (CreatureBase base : _mobs) + base.Damage(event); + } + + @EventHandler + public void CreatureTarget(EntityTargetEvent event) + { + for (CreatureBase base : _mobs) + base.Target(event); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void EntityDeath(EntityDeathEvent event) + { + event.getDrops().clear(); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + if (_wave == 5) + { + SetState(GameState.End); + SetCustomWinLine("You defeated the Pumpkin King!!!"); + AnnounceEnd(this.GetTeamList().get(0)); + + return; + } + + if (GetPlayers(true).size() == 0) + { + SetState(GameState.End); + SetCustomWinLine("The Pumpkin King is victorious again!"); + AnnounceEnd(this.GetTeamList().get(1)); + return; + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/TargetData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/TargetData.java new file mode 100644 index 000000000..4f7345516 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/TargetData.java @@ -0,0 +1,20 @@ +package nautilus.game.arcade.game.games.halloween; + +import org.bukkit.Location; + +public class TargetData +{ + public Location Target; + public long Time; + + public TargetData(Location target) + { + SetTarget(target); + } + + public void SetTarget(Location target) + { + Target = target; + Time = System.currentTimeMillis(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/CreatureBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/CreatureBase.java new file mode 100644 index 000000000..fc8598ec3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/CreatureBase.java @@ -0,0 +1,110 @@ +package nautilus.game.arcade.game.games.halloween.creatures; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.Game; + +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.util.Vector; + +public abstract class CreatureBase +{ + public Game Host; + + private String _name; + private T _ent; + + private Location _target; + private long _targetTime; + + public CreatureBase(Game game, String name, Class mobClass, Location loc) + { + Host = game; + _name = name; + + game.CreatureAllowOverride = true; + _ent = loc.getWorld().spawn(loc, mobClass); + + + if (_name != null) + { + _ent.setCustomName(name); + _ent.setCustomNameVisible(true); + } + + SpawnCustom(_ent); + + game.CreatureAllowOverride = false; + } + + public abstract void SpawnCustom(T ent); + + public String GetName() + { + return _name; + } + + public T GetEntity() + { + return _ent; + } + + public Location GetTarget() + { + return _target; + } + + public void SetTarget(Location loc) + { + _target = loc; + _targetTime = System.currentTimeMillis(); + } + + public long GetTargetTime() + { + return _targetTime; + } + + public Location GetPlayerTarget() + { + if (Host.GetPlayers(true).size() == 0) + { + return Host.GetTeamList().get(0).GetSpawn(); + } + else + { + Player target = Host.GetPlayers(true).get(UtilMath.r(Host.GetPlayers(true).size())); + return target.getLocation(); + } + } + + public Location GetRoamTarget() + { + Vector vec = new Vector(UtilMath.r(80) - 40, 0, UtilMath.r(80) - 40); + return vec.toLocation(Host.GetSpectatorLocation().getWorld()); + } + + public boolean Updater(UpdateEvent event) + { + if (_ent == null || !_ent.isValid()) + { + System.out.println(_ent.getType() + " INVALID"); + return true; + } + + + Update(event); + + return false; + } + + public abstract void Update(UpdateEvent event); + + public abstract void Damage(CustomDamageEvent event); + + public abstract void Target(EntityTargetEvent event); +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobCreeper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobCreeper.java new file mode 100644 index 000000000..69e400ef2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobCreeper.java @@ -0,0 +1,87 @@ +package nautilus.game.arcade.game.games.halloween.creatures; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.Game; +import net.minecraft.server.v1_6_R3.EntityCreature; +import net.minecraft.server.v1_6_R3.Navigation; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature; +import org.bukkit.entity.Creeper; +import org.bukkit.event.entity.EntityTargetEvent; + +public class MobCreeper extends CreatureBase +{ + public MobCreeper(Game game, Location loc) + { + super(game, null, Creeper.class, loc); + } + + @Override + public void SpawnCustom(Creeper ent) + { + + } + + @Override + public void Damage(CustomDamageEvent event) + { + + } + + @Override + public void Target(EntityTargetEvent event) + { + + } + + @Override + public void Update(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + //New Target via Distance + if (GetTarget() == null || + UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 10 || + UtilMath.offset2d(GetEntity().getLocation(), GetTarget()) < 6 || + UtilTime.elapsed(GetTargetTime(), 10000)) + { + SetTarget(GetRoamTarget()); + return; + } + + //Untarget + if (GetEntity().getTarget() != null) + { + if (UtilMath.offset2d(GetEntity(), GetEntity().getTarget()) > 10) + { + GetEntity().setTarget(null); + } + } + //Move + else + { + EntityCreature ec = ((CraftCreature)GetEntity()).getHandle(); + Navigation nav = ec.getNavigation(); + + if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) > 12) + { + Location target = GetEntity().getLocation(); + + target.add(UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget()).multiply(12)); + + nav.a(target.getX(), target.getY(), target.getZ(), 1f); + } + else + { + nav.a(GetTarget().getX(), GetTarget().getY(), GetTarget().getZ(), 1f); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobGhast.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobGhast.java new file mode 100644 index 000000000..2d31035f8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobGhast.java @@ -0,0 +1,57 @@ +package nautilus.game.arcade.game.games.halloween.creatures; + +import mineplex.core.common.util.UtilBlock; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.Game; + +import org.bukkit.Location; +import org.bukkit.entity.Ghast; +import org.bukkit.event.entity.EntityTargetEvent; + +public class MobGhast extends CreatureBase +{ + public MobGhast(Game game, Location loc) + { + super(game, null, Ghast.class, loc); + } + + @Override + public void SpawnCustom(Ghast ent) + { + ent.teleport(new Location(ent.getWorld(), 0, 50, 0)); + } + + @Override + public void Damage(CustomDamageEvent event) + { + + } + + @Override + public void Target(EntityTargetEvent event) + { + + } + + @Override + public void Update(UpdateEvent event) + { + if (event.getType() == UpdateType.TICK) + Move(); + + if (event.getType() == UpdateType.FASTER) + Destroy(); + } + + private void Destroy() + { + Host.Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(GetEntity().getLocation().add(0, 8, 0), 6d).keySet(), GetEntity().getLocation().add(0, 8, 0), false); + } + + private void Move() + { + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobGiant.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobGiant.java new file mode 100644 index 000000000..005e8c3ed --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobGiant.java @@ -0,0 +1,85 @@ +package nautilus.game.arcade.game.games.halloween.creatures; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.Game; + +import org.bukkit.Location; +import org.bukkit.entity.Giant; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.util.Vector; + +public class MobGiant extends CreatureBase +{ + private Location _tpLoc; + + public MobGiant(Game game, Location loc) + { + super(game, null, Giant.class, loc); + } + + @Override + public void SpawnCustom(Giant ent) + { + _tpLoc = ent.getLocation(); + } + + @Override + public void Damage(CustomDamageEvent event) + { + + } + + @Override + public void Target(EntityTargetEvent event) + { + + } + + @Override + public void Update(UpdateEvent event) + { + if (event.getType() == UpdateType.TICK) + Move(); + + if (event.getType() == UpdateType.FASTER) + Destroy(); + } + + private void Destroy() + { + Host.Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(GetEntity().getLocation().add(0, 8, 0), 6d).keySet(), GetEntity().getLocation().add(0, 8, 0), false); + Host.Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(GetEntity().getLocation().add(0, 2, 0), 3.5d).keySet(), GetEntity().getLocation(), true); + Host.Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(GetEntity().getLocation().add(0, 0, 0), 3.5d).keySet(), GetEntity().getLocation(), true); + } + + private void Move() + { + //New Target via Distance + if (GetTarget() == null || + UtilMath.offset2d(GetEntity().getLocation(), GetTarget()) < 0.5 || + UtilTime.elapsed(GetTargetTime(), 20000)) + { + SetTarget(GetPlayerTarget()); + return; + } + + if (_tpLoc == null) + _tpLoc = GetEntity().getLocation(); + + Vector dir = UtilAlg.getTrajectory2d(GetEntity().getLocation(), GetTarget()); + + _tpLoc.setPitch(UtilAlg.GetPitch(dir)); + _tpLoc.setYaw(UtilAlg.GetYaw(dir)); + + _tpLoc.add(dir.multiply(0.1)); + + //Move + GetEntity().teleport(_tpLoc); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSkeletonArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSkeletonArcher.java new file mode 100644 index 000000000..27c679631 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSkeletonArcher.java @@ -0,0 +1,89 @@ +package nautilus.game.arcade.game.games.halloween.creatures; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.Game; +import net.minecraft.server.v1_6_R3.EntityCreature; +import net.minecraft.server.v1_6_R3.Navigation; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.inventory.ItemStack; + +public class MobSkeletonArcher extends CreatureBase +{ + public MobSkeletonArcher(Game game, Location loc) + { + super(game, null, Skeleton.class, loc); + } + + @Override + public void SpawnCustom(Skeleton ent) + { + ent.getEquipment().setItemInHand(new ItemStack(Material.BOW)); + } + + @Override + public void Damage(CustomDamageEvent event) + { + + } + + @Override + public void Target(EntityTargetEvent event) + { + + } + + @Override + public void Update(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + //New Target via Distance + if (GetTarget() == null || + UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 10 || + UtilMath.offset2d(GetEntity().getLocation(), GetTarget()) < 6 || + UtilTime.elapsed(GetTargetTime(), 10000)) + { + SetTarget(GetRoamTarget()); + return; + } + + //Untarget + if (GetEntity().getTarget() != null) + { + if (UtilMath.offset2d(GetEntity(), GetEntity().getTarget()) > 10) + { + GetEntity().setTarget(null); + } + } + //Move + else + { + EntityCreature ec = ((CraftCreature)GetEntity()).getHandle(); + Navigation nav = ec.getNavigation(); + + if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) > 12) + { + Location target = GetEntity().getLocation(); + + target.add(UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget()).multiply(12)); + + nav.a(target.getX(), target.getY(), target.getZ(), 1f); + } + else + { + nav.a(GetTarget().getX(), GetTarget().getY(), GetTarget().getZ(), 1f); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSpider.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSpider.java new file mode 100644 index 000000000..99c750b4f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSpider.java @@ -0,0 +1,112 @@ +package nautilus.game.arcade.game.games.halloween.creatures; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.Game; +import net.minecraft.server.v1_6_R3.EntityCreature; +import net.minecraft.server.v1_6_R3.Navigation; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature; +import org.bukkit.entity.Spider; +import org.bukkit.event.entity.EntityTargetEvent; + +public class MobSpider extends CreatureBase +{ + public MobSpider(Game game, Location loc) + { + super(game, null, Spider.class, loc); + } + + @Override + public void SpawnCustom(Spider ent) + { + + } + + @Override + public void Damage(CustomDamageEvent event) + { + + } + + @Override + public void Target(EntityTargetEvent event) + { + + } + + @Override + public void Update(UpdateEvent event) + { + if (event.getType() == UpdateType.FAST) + Move(); + + if (event.getType() == UpdateType.SEC) + Leap(); + } + + private void Leap() + { + if (GetTarget() == null) + return; + + if (Math.random() > 0.5) + return; + + if (!UtilEnt.isGrounded(GetEntity())) + return; + + if (GetEntity().getTarget() != null) + UtilAction.velocity(GetEntity(), UtilAlg.getTrajectory2d(GetEntity(), GetEntity().getTarget()), 1, true, 0.6, 0, 10, true); + else + UtilAction.velocity(GetEntity(), UtilAlg.getTrajectory2d(GetEntity().getLocation(), GetTarget()), 1, true, 0.6, 0, 10, true); + } + + private void Move() + { + //New Target via Distance + if (GetTarget() == null || + UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 10 || + UtilMath.offset2d(GetEntity().getLocation(), GetTarget()) < 6 || + UtilTime.elapsed(GetTargetTime(), 10000)) + { + SetTarget(GetRoamTarget()); + return; + } + + //Untarget + if (GetEntity().getTarget() != null) + { + if (UtilMath.offset2d(GetEntity(), GetEntity().getTarget()) > 10) + { + GetEntity().setTarget(null); + } + } + //Move + else + { + EntityCreature ec = ((CraftCreature)GetEntity()).getHandle(); + Navigation nav = ec.getNavigation(); + + if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) > 12) + { + Location target = GetEntity().getLocation(); + + target.add(UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget()).multiply(12)); + + nav.a(target.getX(), target.getY(), target.getZ(), 1.6f); + } + else + { + nav.a(GetTarget().getX(), GetTarget().getY(), GetTarget().getZ(), 1.2f); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobZombie.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobZombie.java new file mode 100644 index 000000000..3c00ea91f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobZombie.java @@ -0,0 +1,87 @@ +package nautilus.game.arcade.game.games.halloween.creatures; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.Game; +import net.minecraft.server.v1_6_R3.EntityCreature; +import net.minecraft.server.v1_6_R3.Navigation; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature; +import org.bukkit.entity.Zombie; +import org.bukkit.event.entity.EntityTargetEvent; + +public class MobZombie extends CreatureBase +{ + public MobZombie(Game game, Location loc) + { + super(game, null, Zombie.class, loc); + } + + @Override + public void SpawnCustom(Zombie ent) + { + + } + + @Override + public void Damage(CustomDamageEvent event) + { + + } + + @Override + public void Update(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + //New Target via Distance + if (GetTarget() == null || + UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 10 || + UtilMath.offset2d(GetEntity().getLocation(), GetTarget()) < 6 || + UtilTime.elapsed(GetTargetTime(), 10000)) + { + SetTarget(GetRoamTarget()); + return; + } + + //Untarget + if (GetEntity().getTarget() != null) + { + if (UtilMath.offset2d(GetEntity(), GetEntity().getTarget()) > 10) + { + GetEntity().setTarget(null); + } + } + //Move + else + { + EntityCreature ec = ((CraftCreature)GetEntity()).getHandle(); + Navigation nav = ec.getNavigation(); + + if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) > 12) + { + Location target = GetEntity().getLocation(); + + target.add(UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget()).multiply(12)); + + nav.a(target.getX(), target.getY(), target.getZ(), 1.6f); + } + else + { + nav.a(GetTarget().getX(), GetTarget().getY(), GetTarget().getZ(), 1.2f); + } + } + } + + @Override + public void Target(EntityTargetEvent event) + { + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/PumpkinKing.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/PumpkinKing.java new file mode 100644 index 000000000..09fb6dc53 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/PumpkinKing.java @@ -0,0 +1,673 @@ +package nautilus.game.arcade.game.games.halloween.creatures; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; + +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.UtilDisplay; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.Game; +import net.minecraft.server.v1_6_R3.EntityArrow; +import net.minecraft.server.v1_6_R3.EntityCreature; +import net.minecraft.server.v1_6_R3.Navigation; + +import org.bukkit.ChatColor; +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_6_R3.entity.CraftArrow; +import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.MagmaCube; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.entity.Skeleton.SkeletonType; +import org.bukkit.entity.Slime; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +public class PumpkinKing extends CreatureBase +{ + private int _state = 0; + private long _stateTime = System.currentTimeMillis(); + + private ArrayList _minions = new ArrayList(); + private int _minionsMax = 12; //12 + private HashMap _minionTargets = new HashMap(); + private boolean _minionSpawn = true; + + private ArrayList _shields = new ArrayList(); + private int _shieldsMax = 6; //6 + private long _shieldSpawn = 0; + + private Location _kingLocation; + private Player _kingTarget = null; + + private HashSet _arrows = new HashSet(); + + public PumpkinKing(Game game, Location loc) + { + super(game, null, Skeleton.class, loc); + + _kingLocation = loc; + } + + @Override + public void SpawnCustom(Skeleton ent) + { + ent.setSkeletonType(SkeletonType.WITHER); + ent.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN)); + + ent.setMaxHealth(200); + ent.setHealth(ent.getMaxHealth()); + + ent.getWorld().strikeLightningEffect(ent.getLocation()); + ent.getWorld().strikeLightningEffect(ent.getLocation()); + ent.getWorld().strikeLightningEffect(ent.getLocation()); + } + + @Override + public void Damage(CustomDamageEvent event) + { + //Attacked King + if (event.GetDamageeEntity().equals(GetEntity())) + { + if (_shields.size() > 0) + { + event.SetCancelled("Shielded"); + UtilPlayer.message(event.GetDamagerPlayer(true), F.main("Boss", "You must destroy " + F.elem("Flame Shields") + " first!")); + } + else if (_minions.size() > 0) + { + event.SetCancelled("Shielded"); + UtilPlayer.message(event.GetDamagerPlayer(true), F.main("Boss", "You must destroy " + F.elem("Pumpkin Minions") + " first!")); + } + + if (event.GetCause() == DamageCause.ENTITY_EXPLOSION) + event.SetCancelled("Explosion Resist"); + + event.SetKnockback(false); + } + //Attacked Minion + else if (_minions.contains(event.GetDamageeEntity())) + { + if (_shields.size() > 0) + { + event.SetCancelled("Shielded"); + UtilPlayer.message(event.GetDamagerPlayer(true), F.main("Boss", "You must destroy " + F.elem("Flame Shields") + " first!")); + } + else if (event.GetProjectile() != null) + { + event.SetCancelled("Projectile"); + UtilPlayer.message(event.GetDamagerPlayer(true), F.main("Boss", "Projectiles cannot harm " + F.elem("Pumpkin Minions") + "!")); + } + } + //Attacked Shield + else if (_shields.contains(event.GetDamageeEntity())) + { + event.SetCancelled("Shield Break"); + + if (event.GetProjectile() == null) + return; + + event.GetProjectile().remove(); + + //Effect + Host.Manager.GetBlood().Effects(event.GetDamageeEntity().getLocation(), 10, 0.2, null, 0f, 0f, Material.FIRE, (byte)0, 10, false); + event.GetDamageeEntity().getWorld().playEffect(event.GetDamageeEntity().getLocation(), Effect.STEP_SOUND, 51); + + //Remove + _shields.remove(event.GetDamageeEntity()); + event.GetDamageeEntity().remove(); + + //Health + KingUpdateHealth(); + + //Shield Spawn Delay + _shieldSpawn = System.currentTimeMillis(); + } + } + + @Override + public void Update(UpdateEvent event) + { + //Main + if (event.getType() == UpdateType.FASTER) + StateUpdate(); + + if (event.getType() == UpdateType.FAST) + KingDestroyBlocks(); + + if (event.getType() == UpdateType.TICK) + KingUpdateHealth(); + + //Minions + if (event.getType() == UpdateType.TICK) + MinionControl(); + + if (event.getType() == UpdateType.FASTEST) + MinionArrow(); + + if (event.getType() == UpdateType.FAST) + MinionSpawn(); + + //Final + if (event.getType() == UpdateType.FAST) + KingControl(); + + if (event.getType() == UpdateType.SEC) + KingLeap(); + + if (event.getType() == UpdateType.SEC) + KingBomb(); + + if (event.getType() == UpdateType.SLOW) + KingTarget(); + + //Shield + if (event.getType() == UpdateType.TICK) + ShieldOrbit(false); + + if (event.getType() == UpdateType.FAST) + ShieldSpawn(); + } + + private void KingTarget() + { + if (Math.random() > 0.25) + _kingTarget = GetRandomPlayer(); + } + + private void KingControl() + { + if (GetState() >= 4) + { + if (_kingTarget == null) + _kingTarget = GetRandomPlayer(); + + GetEntity().setTarget(_kingTarget); + + Location loc = _kingTarget.getLocation(); + if (UtilMath.offset(loc, GetEntity().getLocation()) > 16) + loc = GetEntity().getLocation().add(UtilAlg.getTrajectory(GetEntity().getLocation(), loc).multiply(16)); + + //Move + EntityCreature ec = ((CraftCreature)GetEntity()).getHandle(); + Navigation nav = ec.getNavigation(); + nav.a(loc.getX(), loc.getY(), loc.getZ(), 1f); + } + else + { + GetEntity().teleport(_kingLocation); + } + } + + private void KingLeap() + { + if (GetState() < 4) + return; + + if (_kingTarget == null) + return; + + if (Math.random() > 0.4) + return; + + UtilAction.velocity(GetEntity(), UtilAlg.getTrajectory2d(GetEntity(), _kingTarget), 1.2, false, 0, 0.4, 10, true); + } + + private void KingBomb() + { + if (GetState() < 4) + return; + + if (_kingTarget == null) + return; + + if (Math.random() > 0.4) + return; + + TNTPrimed tnt = GetEntity().getWorld().spawn(GetEntity().getEyeLocation().add(GetEntity().getLocation().getDirection()), TNTPrimed.class); + + Player target = GetRandomPlayer(); + + UtilAction.velocity(tnt, UtilAlg.getTrajectory(tnt, target), 1.2, false, 0, 0.4, 10, false); + } + + private void KingUpdateHealth() + { + for (Player player : UtilServer.getPlayers()) + { + if (_shields.size() > 0) + { + double percent = (double)_shields.size() / (double)_shieldsMax; + UtilDisplay.displayTextBar(Host.Manager.GetPlugin(), player, percent, C.cGold + C.Bold + "The Pumpkin King" + C.cWhite + C.Bold + " - " + C.cYellow + C.Bold + "Flame Shield"); + } + else + { + if (_minions.size() > 0) + { + double percent = (double)_minions.size() / (double)_minionsMax; + UtilDisplay.displayTextBar(Host.Manager.GetPlugin(), player, percent, C.cGold + C.Bold + "The Pumpkin King" + C.cWhite + C.Bold + " - " + C.cYellow + C.Bold + "Pumpkin Soldiers"); + } + else + { + double percent = GetEntity().getHealth()/GetEntity().getMaxHealth(); + UtilDisplay.displayTextBar(Host.Manager.GetPlugin(), player, percent, C.cGold + C.Bold + "The Pumpkin King" + C.cWhite + C.Bold + " - " + C.cYellow + C.Bold + "Final Stage"); + } + } + } + } + + private void KingDestroyBlocks() + { + Host.Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(GetEntity().getLocation(), 7d).keySet(), GetEntity().getLocation(), true); + } + + @EventHandler + public void MinionSpawn() + { + Iterator shieldIterator = _minions.iterator(); + while (shieldIterator.hasNext()) + { + Skeleton skel = shieldIterator.next(); + + if (!skel.isValid()) + shieldIterator.remove(); + } + + if (!_minionSpawn) + return; + + if (_minions.size() >= _minionsMax) + { + _minionSpawn = false; + return; + } + + Host.CreatureAllowOverride = true; + Skeleton skel = GetEntity().getWorld().spawn(GetEntity().getLocation(), Skeleton.class); + Host.Manager.GetCondition().Factory().Invisible("Cloak", skel, skel, 999999, 0, false, false, false); + + skel.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN)); + skel.getEquipment().setItemInHand(new ItemStack(Material.BOW)); + + skel.setMaxHealth(50); + skel.setHealth(skel.getMaxHealth()); + + _minions.add(skel); + + Host.CreatureAllowOverride = false; + } + + public void MinionControl() + { + for (int i=0 ; i<_minions.size() ; i++) + { + Skeleton minion = _minions.get(i); + + //Orbit + if (GetState() == 0 || GetState() == 1 || GetState() == 2) + { + minion.setTarget(null); + + double lead = i * ((2d * Math.PI)/_minions.size()); + + double sizeMod = 2 + (_minions.size() / 12); + + //Orbit + double speed = 20d; + double oX = Math.sin(GetEntity().getTicksLived()/speed + lead) * 2 * sizeMod; + double oY = 1; + double oZ = Math.cos(GetEntity().getTicksLived()/speed + lead) * 2 * sizeMod; + + Location loc = GetEntity().getLocation().add(oX, oY, oZ); + if (UtilMath.offset(loc, minion.getLocation()) > 16) + loc = minion.getLocation().add(UtilAlg.getTrajectory(minion.getLocation(), GetEntity().getLocation().add(oX, oY, oZ)).multiply(16)); + + //Move + EntityCreature ec = ((CraftCreature)minion).getHandle(); + Navigation nav = ec.getNavigation(); + nav.a(loc.getX(), loc.getY(), loc.getZ(), 1.2f); + } + //Attack + else + { + LivingEntity target = _minionTargets.get(minion); + if (target == null) + continue; + + minion.setTarget(target); + + Location loc = target.getLocation(); + if (UtilMath.offset(loc, minion.getLocation()) > 12) + loc = minion.getLocation().add(UtilAlg.getTrajectory(minion.getLocation(), loc).multiply(12)); + + //Move + EntityCreature ec = ((CraftCreature)minion).getHandle(); + Navigation nav = ec.getNavigation(); + nav.a(loc.getX(), loc.getY(), loc.getZ(), 1f); + } + } + } + + public void MinionArrow() + { + //Clean + Iterator arrowIterator = _arrows.iterator(); + while (arrowIterator.hasNext()) + { + Arrow arrow = arrowIterator.next(); + + if (arrow.getTicksLived() > 200 || arrow.isOnGround()) + { + if (arrow.isValid() && Math.random() > 0.90) + { + try + { + EntityArrow entityArrow = ((CraftArrow)arrow).getHandle(); + + Field fieldX = EntityArrow.class.getDeclaredField("d"); + Field fieldY = EntityArrow.class.getDeclaredField("e"); + Field fieldZ = EntityArrow.class.getDeclaredField("f"); + + fieldX.setAccessible(true); + fieldY.setAccessible(true); + fieldZ.setAccessible(true); + + int x = fieldX.getInt(entityArrow); + int y = fieldY.getInt(entityArrow); + int z = fieldZ.getInt(entityArrow); + + Block block = arrow.getWorld().getBlockAt(x, y, z); + + if (block.getY() > GetEntity().getLocation().getY()) + block.breakNaturally(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + arrow.remove(); + arrowIterator.remove(); + } + } + + if (GetState() != 1) + return; + + for (int i=0 ; i<_minions.size() ; i++) + { + Skeleton minion = _minions.get(i); + + if (!minion.isValid()) + continue; + + Vector traj = UtilAlg.getTrajectory2d(GetEntity(), minion); + traj.add(new Vector(0,Math.random()*0.2,0)); + + Arrow arrow = GetEntity().getWorld().spawnArrow(minion.getEyeLocation().add(traj), traj, 2f, 16f); + arrow.setShooter(minion); + + _arrows.add(arrow); + } + } + + + @EventHandler + public void ShieldSpawn() + { + if (GetState() == 3 || GetState() == 4) + return; + + Iterator shieldIterator = _shields.iterator(); + while (shieldIterator.hasNext()) + { + Slime slime = shieldIterator.next(); + + if (!slime.isValid()) + shieldIterator.remove(); + } + + if (!UtilTime.elapsed(_shieldSpawn, 3000)) + return; + + if (_shields.size() >= _shieldsMax) + return; + + //Delay + _shieldSpawn = System.currentTimeMillis(); + + int toSpawn = 1; + if (_shields.size() == 0) + toSpawn = _shieldsMax; + + for (int i=0 ; i 0) + GetEntity().getWorld().playEffect(GetEntity().getLocation().add(0, 6, 0), Effect.ENDER_SIGNAL, 0); + } + + public int GetState() + { + return _state; + } + + public void SetState(int state) + { + _state = state; + _stateTime = System.currentTimeMillis(); + + if (state == 3) + { + //Update Gear + for (int i=0 ; i<_minions.size() ; i++) + { + Skeleton minion = _minions.get(i); + + minion.getEquipment().setHelmet(new ItemStack(Material.JACK_O_LANTERN)); + minion.getEquipment().setItemInHand(new ItemStack(Material.WOOD_AXE)); + + //Speed + Host.Manager.GetCondition().Factory().Speed("Minion Speed", minion, minion, 15, 0, false, false, false); + + //Sound + GetEntity().getWorld().playSound(GetEntity().getLocation(), Sound.WITHER_SPAWN, 10f, 1.5f); + + //Target + _minionTargets.put(minion, GetRandomPlayer()); + } + } + } + + public void StateUpdate() + { + if (GetEntity() == null) + return; + + if (GetState() == 0) + { + if (UtilTime.elapsed(_stateTime, 10000)) + { + double r = Math.random(); + + SetState(1); + } + } + //Outward Arrows + else if (GetState() == 1) + { + if (UtilTime.elapsed(_stateTime, 5000)) + { + SetState(0); + } + } + //Upwards Arrows + else if (GetState() == 2) + { + if (UtilTime.elapsed(_stateTime, 5000)) + { + SetState(0); + } + } + else if (GetState() == 3) + { + if (UtilTime.elapsed(_stateTime, 15000)) + { + SetState(0); + + //Update Minions + for (int i=0 ; i<_minions.size() ; i++) + { + Skeleton minion = _minions.get(i); + minion.setTarget(null); + minion.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN)); + minion.getEquipment().setItemInHand(new ItemStack(Material.BOW)); + } + + ShieldSpawn(); + + _minionTargets.clear(); + } + } + + //Skeleton Scatter + if (GetState() != 3 && UtilTime.elapsed(_stateTime, 2000)) + { + if (_shields.size() == 0 && _minions.size() > 0) + { + SetState(3); + } + } + + //Final Stage + if (GetState() != 4 && UtilTime.elapsed(_stateTime, 2000)) + { + if (_shields.size() == 0 && _minions.size() == 0) + { + SetState(4); + + //Sound + GetEntity().getWorld().playSound(GetEntity().getLocation(), Sound.WITHER_SPAWN, 10f, 1.5f); + GetEntity().getWorld().playSound(GetEntity().getLocation(), Sound.ZOMBIE_PIG_ANGRY, 10f, 0.5f); + + //Speed + Host.Manager.GetCondition().Factory().Speed("King Speed", GetEntity(), GetEntity(), 9999, 1, false, false, false); + + //Equip + GetEntity().getEquipment().setItemInHand(new ItemStack(Material.IRON_SWORD)); + } + } + } + + public void Target(EntityTargetEvent event) + { + if (event.getEntity().equals(GetEntity())) + { + if (GetState() != 4 || _kingTarget == null || !_kingTarget.equals(event.getTarget())) + { + event.setCancelled(true); + } + } + + if (_minions.contains(event.getEntity())) + { + if (GetState() != 3) + { + event.setCancelled(true); + } + else + { + if (!_minionTargets.containsKey(event.getEntity())) + { + event.setCancelled(true); + } + else + { + Player player = _minionTargets.get(event.getEntity()); + + if (!player.equals(event.getTarget())) + event.setCancelled(true); + + if (!Host.IsAlive(player)) + _minionTargets.put(event.getEntity(), GetRandomPlayer()); + } + } + } + } + + public Player GetRandomPlayer() + { + if (Host.GetPlayers(true).isEmpty()) + return null; + + return Host.GetPlayers(true).get(UtilMath.r(Host.GetPlayers(true).size())); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitDefault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitDefault.java new file mode 100644 index 000000000..c58b58001 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitDefault.java @@ -0,0 +1,60 @@ +package nautilus.game.arcade.game.games.halloween.kits; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +public class KitDefault extends Kit +{ + public KitDefault(ArcadeManager manager) + { + super(manager, "Halloween Dude", KitAvailability.Free, + + new String[] + { + "Just a dude, at halloween." + }, + + new Perk[] + { + + }, + + EntityType.ZOMBIE, new ItemStack(Material.IRON_SWORD)); + + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD)); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW)); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.ARROW, 64)); + + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + + + player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(Material.JACK_O_LANTERN)); + player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE)); + player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS)); + player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS)); + } + + @Override + public void SpawnCustom(LivingEntity ent) + { + ent.getEquipment().setHelmet(new ItemStack(Material.JACK_O_LANTERN)); + ent.getEquipment().setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE)); + ent.getEquipment().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS)); + ent.getEquipment().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS)); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitGolem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitGolem.java index 7391c4938..cb6eb537e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitGolem.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitGolem.java @@ -58,7 +58,7 @@ public class KitGolem extends SmashKit new String[] { ChatColor.RESET + "Take a mighty leap into the air, then", - ChatColor.RESET + "slam back into the gruond with huge force.", + ChatColor.RESET + "slam back into the ground with huge force.", ChatColor.RESET + "Nearby opponents take damage and knockback.", })); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolf.java index 7882e7af3..3bc25293f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolf.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolf.java @@ -9,6 +9,7 @@ import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature; +import org.bukkit.craftbukkit.v1_6_R3.entity.CraftWolf; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Wolf; diff --git a/Plugins/Nautilus.Game.PvP/src/nautilus/game/pvp/worldevent/creature/BroodMother.java.orig b/Plugins/Nautilus.Game.PvP/src/nautilus/game/pvp/worldevent/creature/BroodMother.java.orig deleted file mode 100644 index 9d020ee14..000000000 --- a/Plugins/Nautilus.Game.PvP/src/nautilus/game/pvp/worldevent/creature/BroodMother.java.orig +++ /dev/null @@ -1,366 +0,0 @@ -package nautilus.game.pvp.worldevent.creature; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; - -import org.bukkit.Effect; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Creature; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Item; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.util.Vector; - -import me.chiss.Core.Items.IThrown; -import me.chiss.Core.Managers.Throw.IProjectileUser; -import me.chiss.Core.Updater.UpdateEvent; -import me.chiss.Core.Updater.UpdateEvent.UpdateType; -import me.chiss.Core.Utility.UtilAction; -import me.chiss.Core.Utility.UtilTime; -import nautilus.game.pvp.worldevent.EventBase; -import nautilus.game.pvp.worldevent.EventCreatureBase; - -public class BroodMother extends EventCreatureBase implements IThrown -{ - private ArrayList _minions = new ArrayList(); - private int _minionsMax = 100; - - private HashMap _eggs = new HashMap(); - private long _eggLast = System.currentTimeMillis(); - private int _eggSpawns = 0; - - private long _webLast = System.currentTimeMillis(); - private int _webSpawns = 0; - private int _webMax = 100; - - private int _eggItems = 0; - private int _eggItemMax = 20; - - private long _stateLast = System.currentTimeMillis(); - - private int _state = 0; - //Normal - //Eggs - //Run - //Webs - - public BroodMother(EventBase event, Location location) - { - super(event, location, "Brood Mother", true, 800, EntityType.SPIDER); - } - - @EventHandler - public void Heal(UpdateEvent event) - { - if (GetEntity() == null) - return; - - if (event.getType() != UpdateType.SEC) - return; - - ModifyHealth(1); - } - - @Override - public void Die() - { - Event.Manager.Blood().Effects(GetEntity().getEyeLocation(), 50, 0.8, - Sound.SPIDER_DEATH, 2f, 0.5f, Material.BONE, (byte)0, false); - Loot(); - Remove(); - } - - @Override - public void Loot() - { - Event.Manager.Loot().DropLoot(GetEntity().getEyeLocation(), 40, 40, 0.2f, 0.05f, 3d); - } - - @EventHandler - public void StateSwitch(UpdateEvent event) - { - if (_state != 0) - return; - - if (event.getType() != UpdateType.SEC) - return; - - if (!UtilTime.elapsed(_stateLast, 12000)) - return; - - if (Math.random() > 0.5 || _minions.size() + _eggs.size() < 6) - { - if (_minions.size() + _eggs.size() < 6 || UtilTime.elapsed(_eggLast, 30000)) - { - _eggLast = System.currentTimeMillis(); - _state = 1; - _eggSpawns = GetMinionsMax(); - ((Creature)GetEntity()).setTarget(null); - } - } - else - { - if (UtilTime.elapsed(_webLast, 30000)) - { - _webLast = System.currentTimeMillis(); - _state = 2; - _webSpawns = Scale(_webMax); - ((Creature)GetEntity()).setTarget(null); - } - } - } - - private int Scale(int a) - { - return (int) (a * (0.1 + (0.9 - 0.9 * (GetHealthCur() / GetHealthMax())))); - } - - private int GetMinionsMax() - { - int max = Scale(_minionsMax); - max -= _minions.size(); - - return max; - } - - @EventHandler - public void WebSpawn(UpdateEvent event) - { - if (_state != 2) - return; - - if (event.getType() != UpdateType.FASTEST) - return; - - if (GetEntity() == null) - return; - - if (_webSpawns <= 0) - { - _state = 0; - _stateLast = System.currentTimeMillis(); - return; - } - - _webSpawns--; - - //Item - Item item = GetEntity().getWorld().dropItem(GetEntity().getLocation().add(0, 0.5, 0), - Event.Manager.Item().CreateStack(Material.WEB)); - - //Velocity - UtilAction.velocity(item, new Vector(Math.random()-0.5, 0, Math.random()-0.5).normalize(), - Math.random() * 0.4 + 0.2, false, 0, Math.random() * 0.6 + 0.4, 10, false); - - //Sound - item.getWorld().playSound(item.getLocation(), Sound.BREATH, 0.5f, 0.2f); - - //Thrown - Event.Manager.Throw().AddThrow(item, GetEntity(), this, - -1, false, false, true, - null, 2f, 0.5f, - null, 0, UpdateType.TICK, 1.5d); - } - - @EventHandler - public void EggSpawn(UpdateEvent event) - { - if (_state != 1) - return; - - if (event.getType() != UpdateType.FASTEST) - return; - - if (GetEntity() == null) - return; - - if (_eggSpawns <= 0) - { - _state = 0; - _stateLast = System.currentTimeMillis(); - return; - } - - if (_eggItems >= _eggItemMax) - return; - - _eggSpawns--; - - //Item - Item item = GetEntity().getWorld().dropItem(GetEntity().getLocation().add(0, 0.5, 0), - Event.Manager.Item().CreateStack(Material.DRAGON_EGG)); - - //Velocity - UtilAction.velocity(item, new Vector(Math.random()-0.5, 0, Math.random()-0.5).normalize(), - Math.random() * 0.4 + 0.2, false, 0, Math.random() * 0.6 + 0.4, 10, false); - - //Sound - item.getWorld().playSound(item.getLocation(), Sound.CHICKEN_EGG_POP, 1f, 1f); - - //Thrown - Event.Manager.Throw().AddThrow(item, GetEntity(), this, - -1, false, false, true, - null, 2f, 0.5f, - null, 0, UpdateType.TICK, 1.5d); - - _eggItems++; - } - - @Override - public void Collide(LivingEntity target, Block block, IProjectileUser data) - { - //Null - } - - @Override - public void Idle(IProjectileUser data) - { - BlockForm(data); - } - - @Override - public void Expire(IProjectileUser data) - { - BlockForm(data); - } - - public void BlockForm(IProjectileUser data) - { - Material mat = ((Item)data.GetThrown()).getItemStack().getType(); - - if (mat == Material.DRAGON_EGG) - { - Block egg = data.GetThrown().getLocation().getBlock(); - - if (egg.getRelative(BlockFace.DOWN).getType() != Material.DRAGON_EGG && - egg.getRelative(BlockFace.DOWN).getType() != Material.WEB) - { - egg.setType(Material.DRAGON_EGG); - _eggs.put(egg, System.currentTimeMillis()); - } - - _eggItems--; - } - else if (mat == Material.WEB) - { - Block web = data.GetThrown().getLocation().getBlock(); - - if (web.getType() != Material.WATER && web.getType() != Material.STATIONARY_WATER) - Event.Manager.BlockRestore().Add(web, 30, (byte)0, Scale(40000)); - } - - data.GetThrown().remove(); - } - - @EventHandler - public void EggHatch(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - if (_eggs.isEmpty()) - return; - - HashSet hatch = new HashSet(); - - for (Block block : _eggs.keySet()) - if (Math.random() > 0.98) - if (UtilTime.elapsed(_eggs.get(block), 12000)) - hatch.add(block); - - for (Block block : hatch) - { - _eggs.remove(block); - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId()); - block.setTypeId(0); - Event.CreatureRegister(new Broodling(Event, block.getLocation().add(0.5, 0.5, 0.5), this)); - } - } - - @EventHandler - public void EggCrush(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - for (Player cur : GetEntity().getWorld().getPlayers()) - { - Block below = cur.getLocation().getBlock().getRelative(BlockFace.DOWN); - if (below.getType() != Material.DRAGON_EGG) - continue; - - if (!_eggs.containsKey(below)) - continue; - - _eggs.remove(below); - below.setTypeId(0); - below.getWorld().playEffect(below.getLocation(), Effect.STEP_SOUND, 122); - - UtilAction.velocity(cur, cur.getLocation().getDirection(), 0.3, true, 0.3, 0, 10, true); - } - } - - @EventHandler - public void EggHit(PlayerInteractEvent event) - { - if (event.getClickedBlock() == null) - return; - - if (!_eggs.containsKey(event.getClickedBlock())) - return; - - event.setCancelled(true); - } - - public void MinionRegister(Broodling minion) - { - _minions.add(minion); - } - - public void MinionDeregister(Broodling minion) - { - _minions.remove(minion); - } - - public ArrayList GetMinions() - { - return _minions; - } - - @EventHandler(priority = EventPriority.LOWEST) - public void TargetCancel(EntityTargetEvent event) - { - if (!event.getEntity().equals(GetEntity())) - return; - - if (_state == 0 && (GetHealthCur() / GetHealthMax()) < 0.5) - return; - - event.setCancelled(true); - } - - public boolean CanTarget(LivingEntity ent) - { - int i = 0; - - for (Broodling cur : _minions) - { - LivingEntity target = ((Creature)cur.GetEntity()).getTarget(); - - if (target != null && target.equals(ent)) - i++; - } - - return i < Scale(20); - } -} From 5563d9411112eda4bd8e933eb58f99e6c022b919 Mon Sep 17 00:00:00 2001 From: Chiss Date: Fri, 25 Oct 2013 19:20:14 +1100 Subject: [PATCH 3/3] Halloween event update hub News hub mounts hub gadgets --- .../mineplex/core/common/util/EntData.java | 16 ++ .../mineplex/core/common/util/UtilEnt.java | 9 +- .../core/common/util/UtilParticle.java | 107 ++++++++++ .../src/mineplex/core/antihack/AntiHack.java | 2 +- .../src/mineplex/core/pet/PetManager.java | 2 + .../src/mineplex/hub/HubManager.java | 53 +++-- .../src/mineplex/hub/commands/HorseSpawn.java | 6 +- .../gadget/gadgets/Halloween2013_Helmet.java | 28 +-- .../hub/gadget/types/ArmorGadget.java | 9 +- .../src/mineplex/hub/gadget/types/Gadget.java | 12 ++ .../mineplex/hub/gadget/types/ItemGadget.java | 4 - ...untManager.java => AdminMountManager.java} | 26 +-- .../src/mineplex/hub/modules/NewsManager.java | 11 +- .../mineplex/hub/modules/ParkourManager.java | 2 +- .../mineplex/hub/modules/StackerManager.java | 70 ++++--- .../hub/modules/VisibilityManager.java | 168 ++++++++++++++++ .../mineplex/hub/modules/WorldManager.java | 6 +- .../src/mineplex/hub/mount/Mount.java | 187 ++++++++++++++++++ .../src/mineplex/hub/mount/MountManager.java | 70 +++++++ .../src/mineplex/hub/mount/types/Mule.java | 16 ++ .../src/mineplex/hub/mount/types/Undead.java | 68 +++++++ .../game/games/halloween/Halloween.java | 177 ++++++----------- .../halloween/creatures/CreatureBase.java | 4 - .../games/halloween/creatures/MobCreeper.java | 2 +- .../games/halloween/creatures/MobGiant.java | 6 +- .../halloween/creatures/MobPigZombie.java | 94 +++++++++ .../creatures/MobSkeletonArcher.java | 2 +- .../creatures/MobSkeletonWarrior.java | 89 +++++++++ .../{MobSpider.java => MobSpiderLeaper.java} | 10 +- .../halloween/creatures/MobSpiderWebber.java | 108 ++++++++++ .../games/halloween/creatures/MobWitch.java | 106 ++++++++++ .../games/halloween/creatures/MobZombie.java | 25 +-- .../halloween/creatures/PumpkinKing.java | 2 +- .../game/games/halloween/kits/KitFinn.java | 88 +++++++++ .../{KitDefault.java => KitRobinHood.java} | 55 ++++-- .../game/games/halloween/kits/KitThor.java | 88 +++++++++ .../game/games/halloween/waves/Wave1.java | 31 +++ .../game/games/halloween/waves/Wave2.java | 35 ++++ .../game/games/halloween/waves/Wave3.java | 27 +++ .../game/games/halloween/waves/Wave4.java | 27 +++ .../game/games/halloween/waves/Wave5.java | 27 +++ .../game/games/halloween/waves/Wave6.java | 35 ++++ .../game/games/halloween/waves/Wave7.java | 35 ++++ .../game/games/halloween/waves/WaveBase.java | 118 +++++++++++ .../game/games/halloween/waves/WaveBoss.java | 35 ++++ .../games/halloween/waves/WaveVictory.java | 46 +++++ .../arcade/kit/perks/PerkBlizzardFinn.java | 154 +++++++++++++++ .../arcade/kit/perks/PerkHammerThrow.java | 170 ++++++++++++++++ .../arcade/kit/perks/PerkInfernoFinn.java | 119 +++++++++++ .../arcade/kit/perks/PerkKnockbackAttack.java | 44 +++++ .../game/arcade/kit/perks/PerkQuickshot.java | 2 +- .../kit/perks/PerkQuickshotRobinHood.java | 56 ++++++ .../arcade/kit/perks/PerkSeismicHammer.java | 92 +++++++++ .../nautilus/game/arcade/world/WorldData.java | 2 + 54 files changed, 2514 insertions(+), 269 deletions(-) create mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/EntData.java create mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java rename Plugins/Mineplex.Hub/src/mineplex/hub/modules/{MountManager.java => AdminMountManager.java} (91%) create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/modules/VisibilityManager.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/mount/Mount.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/mount/MountManager.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Mule.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Undead.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobPigZombie.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSkeletonWarrior.java rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/{MobSpider.java => MobSpiderLeaper.java} (91%) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSpiderWebber.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobWitch.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitFinn.java rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/{KitDefault.java => KitRobinHood.java} (57%) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitThor.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave1.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave2.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave3.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave4.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave5.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave6.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave7.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveBase.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveBoss.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveVictory.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlizzardFinn.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHammerThrow.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInfernoFinn.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockbackAttack.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkQuickshotRobinHood.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicHammer.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/EntData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/EntData.java new file mode 100644 index 000000000..2bb557f17 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/EntData.java @@ -0,0 +1,16 @@ +package mineplex.core.common.util; + +import org.bukkit.entity.EntityType; + +public class EntData +{ + public String Name; + public EntityType Type; + public double Height; + public double Scale; + + public EntData(String name, EntityType type, double height, double scale) + { + + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java index 21494a340..a91c130b4 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java @@ -162,6 +162,13 @@ public class UtilEnt if (GetEntityNames().containsKey(ent)) return GetEntityNames().get(ent); + if (ent instanceof LivingEntity) + { + LivingEntity le = (LivingEntity)ent; + if (le.getCustomName() != null) + return le.getCustomName(); + } + return getName(ent.getType()); } @@ -322,7 +329,7 @@ public class UtilEnt } } else - if (loc.getY() > ent.getLocation().getY() && loc.getY() < ent.getLocation().getY() + 1) + if (loc.getY() > ent.getLocation().getY() && loc.getY() < ent.getLocation().getY() + 2) if (UtilMath.offset2d(loc, ent.getLocation()) < 0.5 * mult) return true; diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java new file mode 100644 index 000000000..7bbcc0014 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java @@ -0,0 +1,107 @@ +package mineplex.core.common.util; + +import java.lang.reflect.Field; + +import net.minecraft.server.v1_6_R3.Packet63WorldParticles; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer; +import org.bukkit.entity.Player; + +public class UtilParticle +{ + public enum ParticleType + { + HUGE_EXPLOSION("hugeexplosion"), + LARGE_EXPLODE("largeexplode"), + FIREWORKS_SPARK("fireworksSpark"), + BUBBLE("bubble"), + SUSPEND("suspend"), + DEPTH_SUSPEND("depthSuspend"), + TOWN_AURA("townaura"), + CRIT("crit"), + MAGIC_CRIT("magicCrit"), + MOB_SPELL("mobSpell"), + MOB_SPELL_AMBIENT("mobSpellAmbient"), + SPELL("spell"), + INSTANT_SPELL("instantSpell"), + WITCH_MAGIC("witchMagic"), + NOTE("note"), + PORTAL("portal"), + ENCHANTMENT_TABLE("enchantmenttable"), + EXPLODE("explode"), + FLAME("flame"), + LAVA("lava"), + FOOTSTEP("footstep"), + SPLASH("splash"), + LARGE_SMOKE("largesmoke"), + CLOUD("cloud"), + RED_DUST("reddust"), + SNOWBALL_POOF("snowballpoof"), + DRIP_WATER("dripWater"), + DRIP_LAVA("dripLava"), + SNOW_SHOVEL("snowshovel"), + SLIME("slime"), + HEART("heart"), + ANGRY_VILLAGER("angryVillager"), + HAPPY_VILLAGER("happerVillager"); + + public String particleName; + + ParticleType(String particleName) + { + this.particleName = particleName; + } + } + + public static void PlayParticle(Player player, ParticleType type, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count) + { + Packet63WorldParticles packet = new Packet63WorldParticles(); + + for (Field field : packet.getClass().getDeclaredFields()) + { + try + { + field.setAccessible(true); + String fieldName = field.getName(); + switch (fieldName) + { + case "a": + field.set(packet, type.particleName); //Particle name + break; + case "b": + field.setFloat(packet, (float)location.getX()); //Block X + break; + case "c": + field.setFloat(packet, (float)location.getY()); //Block Y + break; + case "d": + field.setFloat(packet, (float)location.getZ()); //Block Z + break; + case "e": + field.setFloat(packet, offsetX); //Random X Offset + break; + case "f": + field.setFloat(packet, offsetY); //Random Y Offset + break; + case "g": + field.setFloat(packet, offsetZ); //Random Z Offset + break; + case "h": + field.setFloat(packet, speed); //Speed/data of particles + break; + case "i": + field.setInt(packet, count); //Amount of particles + break; + } + } + catch (Exception e) + { + System.out.println(e.getMessage()); + return; + } + } + + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index b4e3ca9f6..d1b351b6c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -357,7 +357,7 @@ public class AntiHack extends MiniPlugin //Staff for (Player other : UtilServer.getPlayers()) - if (other.isOp()) + if (other.isOp() && other.getGameMode() == GameMode.CREATIVE) UtilPlayer.message(other, C.cGold + C.Bold + player.getName() + " received offense for " + type + "."); //Print (Debug) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java index 65a533048..4a990bac0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java @@ -177,11 +177,13 @@ public class PetManager extends MiniClientPlugin } } + /* not necessary for hub @EventHandler(priority = EventPriority.HIGHEST) public void onPlayerInventoryClick(InventoryClickEvent event) { UtilInv.DisallowMovementOf(event, "Pet Menu", Material.BONE, (byte)0, true, true); } + */ @EventHandler public void onPlayerJoin(PlayerJoinEvent event) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 66f796bf9..16550e973 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -13,7 +13,6 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer; import org.bukkit.entity.Egg; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -23,7 +22,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerJoinEvent; @@ -56,6 +55,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; 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.tutorial.TutorialManager; @@ -73,6 +73,7 @@ public class HubManager extends MiniClientPlugin private PartyManager _partyManager; private Portal _portal; + private VisibilityManager _visibilityManager; private TutorialManager _tutorialManager; private TextManager _textCreator; private ParkourManager _parkour; @@ -97,26 +98,28 @@ public class HubManager extends MiniClientPlugin _blockRestore = blockRestore; _clientManager = clientManager; _conditionManager = conditionManager; - _donationManager = donationManager; + _donationManager = donationManager; _disguiseManager = disguiseManager; + _portal = portal; _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 74, 0.5); _textCreator = new TextManager(this); _parkour = new ParkourManager(this, donationManager, taskManager); - - new MountManager(this); + new MapManager(this); new WorldManager(this); new JumpManager(this); new NewsManager(this); new GadgetManager(this); + new MountManager(this); _partyManager = partyManager; _tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator); - + _visibilityManager = new VisibilityManager(this); + DragonTextB = GetDragonText(); } @@ -401,6 +404,12 @@ public class HubManager extends MiniClientPlugin player.setFoodLevel(20); } } + + @EventHandler + public void InventoryCancel(InventoryClickEvent event) + { + event.setCancelled(true); + } @EventHandler public void UpdateScoreboard(UpdateEvent event) @@ -567,6 +576,11 @@ public class HubManager extends MiniClientPlugin return _donationManager; } + public DisguiseManager GetDisguise() + { + return _disguiseManager; + } + public ParkourManager GetParkour() { return _parkour; @@ -577,28 +591,13 @@ public class HubManager extends MiniClientPlugin return _spawn.clone(); } - @EventHandler - public void UpdateVisibility(UpdateEvent event) + public TutorialManager GetTutorial() { - if (event.getType() != UpdateType.FAST) - return; + return _tutorialManager; + } - for (Player player : UtilServer.getPlayers()) - { - for (Player other : UtilServer.getPlayers()) - { - if (player.equals(other)) - continue; - - if (UtilMath.offset(player.getLocation(), GetSpawn()) < 4 || _tutorialManager.InTutorial(other) || _tutorialManager.InTutorial(player) || (player.getOpenInventory().getType() != InventoryType.CRAFTING && player.getOpenInventory().getType() != InventoryType.CREATIVE)) - { - ((CraftPlayer)other).hidePlayer(player, true, false); - } - else - { - other.showPlayer(player); - } - } - } + public VisibilityManager GetVisibility() + { + return _visibilityManager; } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/HorseSpawn.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/HorseSpawn.java index a85a81411..d9155039e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/HorseSpawn.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/HorseSpawn.java @@ -4,11 +4,11 @@ import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; -import mineplex.hub.modules.MountManager; +import mineplex.hub.modules.AdminMountManager; -public class HorseSpawn extends CommandBase +public class HorseSpawn extends CommandBase { - public HorseSpawn(MountManager plugin) + public HorseSpawn(AdminMountManager plugin) { super(plugin, Rank.OWNER, new String[] {"horse"}); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/Halloween2013_Helmet.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/Halloween2013_Helmet.java index 71b8b8b36..d86accdaa 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/Halloween2013_Helmet.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/Halloween2013_Helmet.java @@ -2,10 +2,11 @@ package mineplex.hub.gadget.gadgets; import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton.SkeletonType; import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerDropItemEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.disguise.disguises.DisguiseSkeleton; import mineplex.hub.gadget.GadgetManager; import mineplex.hub.gadget.types.ArmorGadget; @@ -13,28 +14,33 @@ public class Halloween2013_Helmet extends ArmorGadget { public Halloween2013_Helmet(GadgetManager manager) { - super(manager, "Halloween2013_Helmet", "Pumpkin Helmet", ArmorSlot.Helmet, Material.PUMPKIN, (byte)0); + super(manager, "Halloween2013_Helmet", "Pumpkin Kings Head", ArmorSlot.Helmet, Material.PUMPKIN, (byte)0); } @Override public void Enable(Player player) { this.ApplyArmor(player); + + DisguiseSkeleton disguise = new DisguiseSkeleton(player); + disguise.SetName(player.getName()); + disguise.SetSkeletonType(SkeletonType.WITHER); + Manager.Manager.GetDisguise().disguise(disguise); } @Override public void Disable(Player player) { this.RemoveArmor(player); + Manager.Manager.GetDisguise().undisguise(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); + @EventHandler + public void TOGGLE(PlayerDropItemEvent event) + { + if (!this.IsActive(event.getPlayer())) + Enable(event.getPlayer()); + else + Disable(event.getPlayer()); } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ArmorGadget.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ArmorGadget.java index 03e55b265..4027d217a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ArmorGadget.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ArmorGadget.java @@ -1,7 +1,5 @@ package mineplex.hub.gadget.types; -import java.util.HashSet; - import org.bukkit.Material; import org.bukkit.entity.Player; @@ -20,8 +18,6 @@ public abstract class ArmorGadget extends Gadget Boots } - private HashSet _active = new HashSet(); - private ArmorSlot _slot; private Material _material; private byte _data; @@ -35,10 +31,7 @@ public abstract class ArmorGadget extends Gadget _data = data; } - public HashSet GetActive() - { - return _active; - } + public ArmorSlot GetSlot() { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/Gadget.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/Gadget.java index dc214577d..fda6fbcfc 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/Gadget.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/Gadget.java @@ -15,6 +15,7 @@ public abstract class Gadget implements Listener public GadgetManager Manager; private HashSet _owners = new HashSet(); + protected HashSet _active = new HashSet(); private String _code; private String _name; @@ -44,6 +45,16 @@ public abstract class Gadget implements Listener return _owners; } + public HashSet GetActive() + { + return _active; + } + + public boolean IsActive(Player player) + { + return _active.contains(player); + } + public boolean HasGadget(Player player) { return _owners.contains(player); @@ -62,6 +73,7 @@ public abstract class Gadget implements Listener public void PlayerQuit(PlayerQuitEvent event) { _owners.remove(event.getPlayer()); + Disable(event.getPlayer()); } public abstract void Enable(Player player); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ItemGadget.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ItemGadget.java index 043ccb00d..85d16b9b6 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ItemGadget.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ItemGadget.java @@ -4,8 +4,6 @@ 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; @@ -15,8 +13,6 @@ import mineplex.hub.gadget.GadgetManager; public abstract class ItemGadget extends Gadget { - private HashSet _active = new HashSet(); - private Material _material; private byte _data; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/MountManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java similarity index 91% rename from Plugins/Mineplex.Hub/src/mineplex/hub/modules/MountManager.java rename to Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java index 8ff72dd00..5b7ef1b65 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/MountManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java @@ -23,13 +23,13 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; -public class MountManager extends MiniPlugin +public class AdminMountManager extends MiniPlugin { private HubManager Manager; private HashMap _mounts = new HashMap(); - public MountManager(HubManager manager) + public AdminMountManager(HubManager manager) { super("Mount Manager", manager.GetPlugin()); @@ -68,22 +68,6 @@ public class MountManager extends MiniPlugin horse.remove(); } - @EventHandler - public void PlayerJoin(PlayerJoinEvent event) - { - if (!Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.OWNER)) - return; - - final Player fPlayer = event.getPlayer(); - Manager.GetPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable() - { - public void run() - { - Spawn(fPlayer, Variant.HORSE).setPassenger(fPlayer); - } - }, 5); - } - public void HorseCommand(Player caller, String[] args) { if (args == null || args.length == 0) @@ -334,10 +318,4 @@ public class MountManager extends MiniPlugin if (event.getEntity().getItemStack().getType() == Material.LEASH) event.setCancelled(true); } - - @EventHandler - public void HangingBreakEvent(org.bukkit.event.hanging.HangingBreakEvent event) - { - event.setCancelled(true); - } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java index 9cb986066..b0194a71d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java @@ -31,9 +31,12 @@ public class NewsManager extends MiniPlugin _news = new String[] { - "New Game: " + C.cRed + C.Bold + "Halloween Horror" + ChatColor.RESET + "! Limited time!", - "Halloween Hub Gadgets! Unlockable for limited time!", - "New Super Smash Mobs Kit: " + C.cYellow + C.Bold + "Witch" + ChatColor.RESET + "!" + "New Game: " + C.cGold + C.Bold + "Halloween Horror" + ChatColor.RESET + "! Limited time!", + "New Super Smash Mobs Kit: " + C.cYellow + C.Bold + "Witch" + ChatColor.RESET + "!", + "New Halloween Hub Items! Limited time to unlock!", + "New Hub Mount: " + C.cYellow + C.Bold + "Horse of Horror" + ChatColor.RESET + "!", + "New Hub Gadget: " + C.cYellow + C.Bold + "Pumpkin Kings Head" + ChatColor.RESET + "!", + "New Hub Gadget: " + C.cYellow + C.Bold + "Bat Cannon" + ChatColor.RESET + "!", }; } @@ -53,7 +56,7 @@ public class NewsManager extends MiniPlugin _mineplexIndex = (_mineplexIndex + 1)%6; //News Change - if (UtilTime.elapsed(_newsTime, 3000)) + if (UtilTime.elapsed(_newsTime, 4500)) { _newsIndex = (_newsIndex + 1)%_news.length; _newsTime = System.currentTimeMillis(); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java index b41088d20..e97c02dbb 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java @@ -141,7 +141,7 @@ public class ParkourManager extends MiniPlugin player.eject(); player.leaveVehicle(); - UtilPlayer.message(player, F.main("Parkour", "You can't run parkours while stacked!")); + UtilPlayer.message(player, F.main("Parkour", "You can't be a passenger near Parkours!")); } } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java index 4dd239381..4e1259a8a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java @@ -25,8 +25,6 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilEvent.ActionType; @@ -43,10 +41,12 @@ public class StackerManager extends MiniPlugin implements IThrown private ProjectileManager _projectileManager; - private HashSet _disabled = new HashSet(); + private HashSet _disabled = new HashSet(); private HashSet _tempStackShift = new HashSet(); private HashMap _portalTime = new HashMap(); + + private int _slot = 7; public StackerManager(HubManager manager) { @@ -56,48 +56,64 @@ public class StackerManager extends MiniPlugin implements IThrown _projectileManager = new ProjectileManager(manager.GetPlugin()); } - + @EventHandler - public void ToggleInvolvement(PlayerInteractEvent event) + public void ToggleVisibility(PlayerInteractEvent event) { Player player = event.getPlayer(); - - if (UtilGear.isMat(player.getItemInHand(), Material.GRILLED_PORK)) + + if (player.getInventory().getHeldItemSlot() != _slot) + return; + + event.setCancelled(true); + + if (_disabled.remove(player)) { - _disabled.add(player.getName()); - UtilPlayer.message(player, F.main("Stacker", "You are no longer stackable... boring...")); - - player.getInventory().setItem(4, ItemStackFactory.Instance.CreateStack(Material.PORK, (byte)0, 1, C.cGreen + "Enable Stacker")); - UtilInv.Update(player); - - event.setCancelled(true); - } - else if (UtilGear.isMat(player.getItemInHand(), Material.PORK)) - { - _disabled.remove(player.getName()); UtilPlayer.message(player, F.main("Stacker", "You are back in the stacking games! Squeeeee!")); - - player.getInventory().setItem(4, ItemStackFactory.Instance.CreateStack(Material.GRILLED_PORK, (byte)0, 1, C.cRed + "Disable Stacker")); - UtilInv.Update(player); - - event.setCancelled(true); + + player.getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(Material.REDSTONE_TORCH_ON, (byte)0, 1, + C.cYellow + "Stacker" + C.cWhite + " - " + C.cGreen + "Enabled")); + } + else + { + _disabled.add(player); + UtilPlayer.message(player, F.main("Stacker", "You are no longer stackable... boring!")); + + player.getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(Material.REDSTONE_TORCH_OFF, (byte)0, 1, + C.cYellow + "Stacker" + C.cWhite + " - " + C.cRed + "Disabled")); } } + @EventHandler public void PlayerJoin(PlayerJoinEvent event) { - event.getPlayer().getInventory().setItem(4, ItemStackFactory.Instance.CreateStack(Material.GRILLED_PORK, (byte)0, 1, C.cRed + "Disable Stacker")); + event.getPlayer().getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(Material.REDSTONE_TORCH_ON, (byte)0, 1, + C.cYellow + "Stacker" + C.cWhite + " - " + C.cGreen + "Enabled")); } @EventHandler public void PlayerQuit(PlayerQuitEvent event) { - _disabled.remove(event.getPlayer().getName()); + _disabled.remove(event.getPlayer()); _tempStackShift.remove(event.getPlayer()); _portalTime.remove(event.getPlayer().getName()); } + public boolean CanStack(LivingEntity ent) + { + if (!(ent instanceof Player)) + return true; + + if (_disabled.contains(ent)) + return false; + + if (Manager.GetVisibility().IsHiding(ent)) + return false; + + return true; + } + @EventHandler public void GrabEntity(PlayerInteractEntityEvent event) { @@ -116,7 +132,7 @@ public class StackerManager extends MiniPlugin implements IThrown return; } - if (_disabled.contains(stacker.getName())) + if (!CanStack(stacker)) { UtilPlayer.message(stacker, F.main("Stacker", "You are not playing stacker.")); return; @@ -141,7 +157,7 @@ public class StackerManager extends MiniPlugin implements IThrown if (stackee instanceof Player && ((Player)stackee).getGameMode() != GameMode.SURVIVAL) return; - if (stackee instanceof Player && _disabled.contains(((Player)stackee).getName())) + if (stackee instanceof Player && !CanStack(((Player)stackee))) { UtilPlayer.message(stacker, F.main("Stacker", F.name(UtilEnt.getName(stackee)) + " is not playing stacker.")); return; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/VisibilityManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/VisibilityManager.java new file mode 100644 index 000000000..f25ef2511 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/VisibilityManager.java @@ -0,0 +1,168 @@ +package mineplex.hub.modules; + +import java.util.HashMap; +import java.util.HashSet; + +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +import mineplex.hub.HubManager; + +public class VisibilityManager extends MiniPlugin +{ + public HubManager Manager; + + private HashSet _hide = new HashSet(); + + private int _slot = 8; + + public VisibilityManager(HubManager manager) + { + super("Visibility Manager", manager.GetPlugin()); + + Manager = manager; + } + + @EventHandler + public void PlayerJoin(PlayerJoinEvent event) + { + event.getPlayer().getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(Material.EYE_OF_ENDER, (byte)0, 1, + C.cYellow + "Show Players" + C.cWhite + " - " + C.cGreen + "Enabled")); + } + + @EventHandler + public void PlayerQuit(PlayerQuitEvent event) + { + _hide.remove(event.getPlayer()); + } + + @EventHandler + public void ToggleVisibility(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (player.getInventory().getHeldItemSlot() != _slot) + return; + + event.setCancelled(true); + + if (_hide.remove(player)) + { + UtilPlayer.message(player, F.main("Visibility", "All players are now visible.")); + + player.getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(Material.EYE_OF_ENDER, (byte)0, 1, + C.cYellow + "Show Players" + C.cWhite + " - " + C.cGreen + "Enabled")); + } + else + { + _hide.add(player); + UtilPlayer.message(player, F.main("Visibility", "All players are now invisible.")); + + player.getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(Material.ENDER_PEARL, (byte)0, 1, + C.cYellow + "Show Players" + C.cWhite + " - " + C.cRed + "Disabled")); + } + } + + @EventHandler + public void UpdateVisibility(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + for (Player player : UtilServer.getPlayers()) + { + for (Player other : UtilServer.getPlayers()) + { + if (player.equals(other)) + continue; + + if (_hide.contains(other) || UtilMath.offset(player.getLocation(), Manager.GetSpawn()) < 4 || + Manager.GetTutorial().InTutorial(other) || Manager.GetTutorial().InTutorial(player) || + (player.getOpenInventory().getType() != InventoryType.CRAFTING && player.getOpenInventory().getType() != InventoryType.CREATIVE)) + { + ((CraftPlayer)other).hidePlayer(player, true, false); + } + else + { + other.showPlayer(player); + } + } + } + } + + public boolean IsHiding(LivingEntity ent) + { + return _hide.contains(ent); + } + + public HashMap _particle = new HashMap(); + + @EventHandler + public void ParticleSwap(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (!player.isOp()) + return; + + if (!UtilGear.isMat(player.getItemInHand(), Material.GOLD_NUGGET)) + return; + + int past = 0; + if (_particle.containsKey(player)) + past = _particle.get(player); + + if (UtilEvent.isAction(event, ActionType.R)) + { + past = (past+1)%ParticleType.values().length; + } + else if (UtilEvent.isAction(event, ActionType.L)) + { + past = past - 1; + if (past < 0) + past = ParticleType.values().length - 1; + } + + _particle.put(player, past); + + player.sendMessage("Particle: " + ParticleType.values()[past]); + } + + @EventHandler + public void Particles(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + for (Player player : _particle.keySet()) + { + for (Player other : UtilServer.getPlayers()) + { + UtilParticle.PlayParticle(other, ParticleType.values()[_particle.get(player)], player.getLocation().add(1, 1, 0), 0f, 0f, 0f, 0, 1); + } + } + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java index 53ba535e9..c81adf267 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java @@ -4,6 +4,7 @@ import java.util.HashSet; import java.util.Iterator; import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; @@ -12,14 +13,12 @@ import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.HubManager; -import net.minecraft.server.v1_6_R3.EntitySkeleton; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_6_R3.entity.CraftSkeleton; import org.bukkit.entity.Chicken; import org.bukkit.entity.Cow; import org.bukkit.entity.Creature; @@ -28,7 +27,6 @@ import org.bukkit.entity.Pig; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton.SkeletonType; -import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; @@ -94,6 +92,8 @@ public class WorldManager extends MiniPlugin ent.getEquipment().setHelmet(ItemStackFactory.Instance.CreateStack(Material.PUMPKIN)); + ent.setCustomName(C.cYellow + "Pumpkin Minion"); + _mobs.add(ent); Manager.GetCondition().Factory().Invisible("Perm", ent, ent, 999999999, 0, false, false, true); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/Mount.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/Mount.java new file mode 100644 index 000000000..5e153ff2c --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/Mount.java @@ -0,0 +1,187 @@ +package mineplex.hub.mount; + + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import net.minecraft.server.v1_6_R3.EntityCreature; +import net.minecraft.server.v1_6_R3.Navigation; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature; +import org.bukkit.entity.Horse.Variant; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Player; +import org.bukkit.entity.Horse.Color; +import org.bukkit.entity.Horse.Style; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; + +public class Mount implements Listener +{ + private HashSet _owners = new HashSet(); + private HashMap _active = new HashMap(); + + public MountManager Manager; + + private String _code; + + private String _name; + + private Color _color; + private Style _style; + private Variant _variant; + private double _jump; + private Material _armor; + + public Mount(MountManager manager, String code, String name, Color color, Style style, Variant variant, double jump, Material armor) + { + Manager = manager; + + _code = code; + _name = name; + _color = color; + _style = style; + _variant = variant; + _jump = jump; + _armor = armor; + + Manager.GetPlugin().getServer().getPluginManager().registerEvents(this, Manager.GetPlugin()); + } + + public String GetName() + { + return _name; + } + + public String GetCode() + { + return _code; + } + + public HashSet GetOwners() + { + return _owners; + } + + public HashMap GetActive() + { + return _active; + } + + public boolean IsActive(Player player) + { + return _active.containsKey(player); + } + + public boolean HasMount(Player player) + { + return _owners.contains(player); + } + + @EventHandler + public void PlayerJoin(PlayerJoinEvent event) + { + if (event.getPlayer().isOp()) + _owners.add(event.getPlayer()); + } + + @EventHandler + public void PlayerQuit(PlayerQuitEvent event) + { + _owners.remove(event.getPlayer()); + Disable(event.getPlayer()); + } + + @EventHandler + public void UpdateHorse(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + Iterator activeIterator = _active.keySet().iterator(); + + while (activeIterator.hasNext()) + { + Player player = activeIterator.next(); + Horse horse = _active.get(player); + + //Invalid (dead) + if (!horse.isValid()) + { + horse.remove(); + activeIterator.remove(); + continue; + } + + //Move + EntityCreature ec = ((CraftCreature)horse).getHandle(); + Navigation nav = ec.getNavigation(); + + Location target = player.getLocation().add(UtilAlg.getTrajectory(player, horse).multiply(2)); + + if (UtilMath.offset(horse.getLocation(), target) > 12) + { + target = horse.getLocation(); + target.add(UtilAlg.getTrajectory(horse, player).multiply(12)); + nav.a(target.getX(), target.getY(), target.getZ(), 1.4f); + } + else if (UtilMath.offset(horse, player) > 43) + { + nav.a(target.getX(), target.getY(), target.getZ(), 1.4f); + } + } + } + + public void Enable(Player player) + { + //Remove other mounts + Manager.DeregisterAll(player); + + Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class); + horse.setAdult(); + horse.setAgeLock(true); + horse.setColor(_color); + horse.setStyle(_style); + horse.setVariant(_variant); + horse.setOwner(player); + horse.setMaxDomestication(1); + horse.setJumpStrength(_jump); + horse.getInventory().setSaddle(new ItemStack(Material.SADDLE)); + + if (_armor != null) + horse.getInventory().setArmor(new ItemStack(_armor)); + + horse.setCustomName(player.getName() + "'s " + _name); + horse.setCustomNameVisible(true); + + //Inform + UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(_name) + ".")); + + //Store + _active.put(player, horse); + } + + public void Disable(Player player) + { + Horse horse = _active.remove(player); + if (horse != null) + { + horse.remove(); + + //Inform + UtilPlayer.message(player, F.main("Mount", "You despawned " + F.elem(_name) + ".")); + } + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/MountManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/MountManager.java new file mode 100644 index 000000000..9d0e93eba --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/MountManager.java @@ -0,0 +1,70 @@ +package mineplex.hub.mount; + +import java.util.HashSet; + +import org.bukkit.Material; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.hub.HubManager; +import mineplex.hub.mount.types.*; + +public class MountManager extends MiniPlugin +{ + public HubManager Manager; + + private HashSet _types; + + public MountManager(HubManager manager) + { + super("Gadget Manager", manager.GetPlugin()); + + Manager = manager; + + CreateGadgets(); + } + + private void CreateGadgets() + { + _types = new HashSet(); + + _types.add(new Undead(this)); + _types.add(new Mule(this)); + } + + //Disallows two mounts active + public void DeregisterAll(Player player) + { + for (Mount mount : _types) + mount.Disable(player); + } + + @EventHandler + public void HorseInteract(PlayerInteractEntityEvent event) + { + if (!(event.getRightClicked() instanceof Horse)) + return; + + Player player = event.getPlayer(); + Horse horse = (Horse)event.getRightClicked(); + + if (horse.getOwner() == null || !horse.getOwner().equals(player)) + { + UtilPlayer.message(player, F.main("Mount", "This is not your Mount!")); + event.setCancelled(true); + } + } + + @EventHandler + public void LeashDropCancel(ItemSpawnEvent event) + { + if (event.getEntity().getItemStack().getType() == Material.LEASH) + event.setCancelled(true); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Mule.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Mule.java new file mode 100644 index 000000000..292552369 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Mule.java @@ -0,0 +1,16 @@ +package mineplex.hub.mount.types; + +import org.bukkit.entity.Horse.Color; +import org.bukkit.entity.Horse.Style; +import org.bukkit.entity.Horse.Variant; + +import mineplex.hub.mount.Mount; +import mineplex.hub.mount.MountManager; + +public class Mule extends Mount +{ + public Mule(MountManager manager) + { + super(manager, "MountMule", "Horse of Horror", Color.BLACK, Style.BLACK_DOTS, Variant.MULE, 1.0, null); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Undead.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Undead.java new file mode 100644 index 000000000..ec3e4b857 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Undead.java @@ -0,0 +1,68 @@ +package mineplex.hub.mount.types; + +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 org.bukkit.event.player.PlayerToggleSneakEvent; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.mount.Mount; +import mineplex.hub.mount.MountManager; + +public class Undead extends Mount +{ + public Undead(MountManager manager) + { + super(manager, "MountHalloween2013", "Horse of Horror", Color.BLACK, Style.BLACK_DOTS, Variant.SKELETON_HORSE, 0.8, null); + } + + @EventHandler + public void Test(PlayerToggleSneakEvent event) + { + if (event.getPlayer().isSneaking()) + this.Enable(event.getPlayer()); + } + + @EventHandler + public void Trail(UpdateEvent event) + { + if (event.getType() == UpdateType.TICK) + { + for (Horse horse : GetActive().values()) + for (Player player : UtilServer.getPlayers()) + { + try + { + UtilParticle.PlayParticle(player, ParticleType.FLAME, horse.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0, 2); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + } + + if (event.getType() == UpdateType.FAST) + { + for (Horse horse : GetActive().values()) + for (Player player : UtilServer.getPlayers()) + { + try + { + UtilParticle.PlayParticle(player, ParticleType.LAVA, horse.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0, 1); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java index 8eab25368..efd29c095 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java @@ -10,14 +10,12 @@ import org.bukkit.Sound; import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityBreakDoorEvent; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.entity.ItemSpawnEvent; -import mineplex.core.common.util.C; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -26,33 +24,31 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.SoloGame; -import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.halloween.creatures.*; -import nautilus.game.arcade.game.games.halloween.kits.KitDefault; -import nautilus.game.arcade.game.games.spleef.kits.*; +import nautilus.game.arcade.game.games.halloween.kits.*; +import nautilus.game.arcade.game.games.halloween.waves.*; import nautilus.game.arcade.kit.Kit; + public class Halloween extends SoloGame { + //Wave Data private ArrayList> _spawns; - private int _spawnWave = 0; - private int _spawnTick = 0; - - private String _waveName = ""; - private int _wave = 0; - private long _waveStart = 0; - private long _waveDuration = 0; - private PumpkinKing _king; - + private ArrayList _waves; + private int _wave = 0; + private HashSet _mobs = new HashSet(); - + private PumpkinKing _king; + public Halloween(ArcadeManager manager) { super(manager, GameType.Halloween, new Kit[] { - new KitDefault(manager) + new KitFinn(manager), + new KitRobinHood(manager), + new KitThor(manager), }, new String[] @@ -66,10 +62,12 @@ public class Halloween extends SoloGame this.WorldTimeSet = 16000; - this.ItemDrop = true; - this.ItemPickup = true; + this.ItemDrop = false; + this.ItemPickup = false; - this.PrepareFreeze = false; + this.PrepareFreeze = false; + + this.HungerSet = 20; } @Override @@ -80,6 +78,16 @@ public class Halloween extends SoloGame _spawns.add(WorldData.GetDataLocs("YELLOW")); _spawns.add(WorldData.GetDataLocs("GREEN")); _spawns.add(WorldData.GetDataLocs("BLUE")); + + _waves = new ArrayList(); + _waves.add(new Wave1(this)); + _waves.add(new Wave2(this)); + _waves.add(new Wave3(this)); + //_waves.add(new Wave4(this)); + //_waves.add(new Wave5(this)); + //_waves.add(new Wave6(this)); + _waves.add(new WaveBoss(this)); + _waves.add(new WaveVictory(this)); } @EventHandler @@ -108,112 +116,41 @@ public class Halloween extends SoloGame } @EventHandler - public void UpdateWave(UpdateEvent event) + public void WaveUpdate(UpdateEvent event) { - if (event.getType() != UpdateType.FAST) + if (event.getType() != UpdateType.TICK) return; if (!IsLive()) return; - //Display Remaining Time - if (_wave > 0) - for (Player player : UtilServer.getPlayers()) - { - player.setExp(Math.min(0.999f, (float)(_waveDuration - (System.currentTimeMillis() - _waveStart)) / (float)_waveDuration)); - player.setLevel(_wave); - } - - if (!UtilTime.elapsed(_waveStart, _waveDuration) || (_wave == 4 && !_king.GetEntity().isValid())) - return; - - _wave = _wave + 1; - _waveStart = System.currentTimeMillis(); - _waveDuration = 60000; - _spawnTick = 0; - - _spawnWave = UtilMath.r(_spawns.size()); - - if (_wave == 1) _waveName = "Zombies, Skeletons and Creepers, OH MY!"; - if (_wave == 2) _waveName = "A Giant? Better kill that guy!"; - if (_wave == 3) _waveName = "SPIDERS SPIDERS SPIDERS!!!!!"; - if (_wave == 4) _waveName = "THE SKELETON KING EMERGES"; - - if (_wave <= 4) - Announce(C.cRed + C.Bold + "Wave " + _wave + ": " + C.cYellow + _waveName); - } - - public Location GetSpawn() - { - return _spawns.get(_spawnWave).get(UtilMath.r(_spawns.get(_spawnWave).size())); + if (_waves.get(_wave).Update(_wave+1)) + { + _wave++; + + EndCheck(); + } } - @EventHandler - public void SpawnCreatures(UpdateEvent event) + public ArrayList GetSpawnSet(int i) { - //Boss Swarm - if (event.getType() == UpdateType.SEC && _wave == 4 && _mobs.size() < 20) - { - Location loc = _spawns.get(UtilMath.r(_spawns.size())).get(UtilMath.r(_spawns.get(_spawnWave).size())); - _mobs.add(new MobZombie(this, loc)); - } + return _spawns.get(i); + } + + public Location GetRandomSpawn() + { + ArrayList locSet = GetSpawnSet(UtilMath.r(_spawns.size())); + return locSet.get(UtilMath.r(locSet.size())); + } - if (event.getType() != UpdateType.FAST) - return; - - if (!IsLive()) - return; - - this.CreatureAllowOverride = true; - - //Plain - if (_wave == 1) - { - if (UtilTime.elapsed(_waveStart, 12000 + (_wave * 2000))) - return; - - _mobs.add(new MobZombie(this, GetSpawn())); - - if (_spawnTick % 3 == 0) - _mobs.add(new MobSkeletonArcher(this, GetSpawn())); - - if (_spawnTick % 5 == 0) - _mobs.add(new MobCreeper(this, GetSpawn())); - } - //Single Giant - if (_wave == 2) - { - _mobs.add(new MobZombie(this, GetSpawn())); - - if (_spawnTick % 3 == 0) - _mobs.add(new MobSkeletonArcher(this, GetSpawn())); - - if (_spawnTick % 5 == 0) - _mobs.add(new MobCreeper(this, GetSpawn())); - - if (_spawnTick == 0) - _mobs.add(new MobGiant(this, GetSpawn())); - } - //Spiders - if (_wave == 3) - { - _mobs.add(new MobSpider(this, GetSpawn())); - _mobs.add(new MobSpider(this, GetSpawn())); - } - //Quad Giant - if (_wave == 4) - { - if (_spawnTick == 0) - { - _waveDuration = 900000; - _king = new PumpkinKing(this, WorldData.GetDataLocs("BLACK").get(0)); - _mobs.add(_king); - } - } - - this.CreatureAllowOverride = false; - - _spawnTick++; + public void AddCreature(CreatureBase mob) + { + _mobs.add(mob); + } + + public HashSet GetCreatures() + { + return _mobs; } @EventHandler @@ -259,7 +196,7 @@ public class Halloween extends SoloGame if (!IsLive()) return; - if (_wave == 5) + if (_wave >= _waves.size()) { SetState(GameState.End); SetCustomWinLine("You defeated the Pumpkin King!!!"); @@ -276,4 +213,10 @@ public class Halloween extends SoloGame return; } } + + @EventHandler + public void Door(EntityBreakDoorEvent event) + { + System.out.println("Door Break"); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/CreatureBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/CreatureBase.java index fc8598ec3..89fe24fe7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/CreatureBase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/CreatureBase.java @@ -91,11 +91,7 @@ public abstract class CreatureBase public boolean Updater(UpdateEvent event) { if (_ent == null || !_ent.isValid()) - { - System.out.println(_ent.getType() + " INVALID"); return true; - } - Update(event); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobCreeper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobCreeper.java index 69e400ef2..cdd92b613 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobCreeper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobCreeper.java @@ -43,7 +43,7 @@ public class MobCreeper extends CreatureBase @Override public void Update(UpdateEvent event) { - if (event.getType() != UpdateType.FAST) + if (event.getType() != UpdateType.SEC) return; //New Target via Distance diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobGiant.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobGiant.java index 005e8c3ed..f080dce43 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobGiant.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobGiant.java @@ -27,12 +27,16 @@ public class MobGiant extends CreatureBase public void SpawnCustom(Giant ent) { _tpLoc = ent.getLocation(); + + ent.setMaxHealth(120); + ent.setHealth(120); } @Override public void Damage(CustomDamageEvent event) { - + if (event.GetDamageeEntity().equals(GetEntity())) + event.SetKnockback(false); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobPigZombie.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobPigZombie.java new file mode 100644 index 000000000..7eb06f5e5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobPigZombie.java @@ -0,0 +1,94 @@ +package nautilus.game.arcade.game.games.halloween.creatures; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.disguise.disguises.DisguisePigZombie; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.Game; +import net.minecraft.server.v1_6_R3.EntityCreature; +import net.minecraft.server.v1_6_R3.Navigation; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature; +import org.bukkit.entity.Zombie; +import org.bukkit.event.entity.EntityTargetEvent; + +public class MobPigZombie extends CreatureBase +{ + public MobPigZombie(Game game, Location loc) + { + super(game, null, Zombie.class, loc); + } + + @Override + public void SpawnCustom(Zombie ent) + { + DisguisePigZombie disguise = new DisguisePigZombie(ent); + Host.Manager.GetDisguise().disguise(disguise); + + Host.Manager.GetCondition().Factory().Speed("Speed", ent, ent, 99999, 1, false, false, false); + } + + @Override + public void Damage(CustomDamageEvent event) + { + + } + + @Override + public void Target(EntityTargetEvent event) + { + + } + + @Override + public void Update(UpdateEvent event) + { + if (event.getType() == UpdateType.FAST) + Move(); + } + + private void Move() + { + //New Target via Distance + if (GetTarget() == null || + UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 10 || + UtilMath.offset2d(GetEntity().getLocation(), GetTarget()) < 6 || + UtilTime.elapsed(GetTargetTime(), 10000)) + { + SetTarget(GetRoamTarget()); + return; + } + + //Untarget + if (GetEntity().getTarget() != null) + { + if (UtilMath.offset2d(GetEntity(), GetEntity().getTarget()) > 10) + { + GetEntity().setTarget(null); + } + } + //Move + else + { + EntityCreature ec = ((CraftCreature)GetEntity()).getHandle(); + Navigation nav = ec.getNavigation(); + + if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) > 12) + { + Location target = GetEntity().getLocation(); + + target.add(UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget()).multiply(12)); + + nav.a(target.getX(), target.getY(), target.getZ(), 1.6f); + } + else + { + nav.a(GetTarget().getX(), GetTarget().getY(), GetTarget().getZ(), 1.2f); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSkeletonArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSkeletonArcher.java index 27c679631..160efa77d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSkeletonArcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSkeletonArcher.java @@ -45,7 +45,7 @@ public class MobSkeletonArcher extends CreatureBase @Override public void Update(UpdateEvent event) { - if (event.getType() != UpdateType.FAST) + if (event.getType() != UpdateType.SEC) return; //New Target via Distance diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSkeletonWarrior.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSkeletonWarrior.java new file mode 100644 index 000000000..30a5f36df --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSkeletonWarrior.java @@ -0,0 +1,89 @@ +package nautilus.game.arcade.game.games.halloween.creatures; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.Game; +import net.minecraft.server.v1_6_R3.EntityCreature; +import net.minecraft.server.v1_6_R3.Navigation; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.inventory.ItemStack; + +public class MobSkeletonWarrior extends CreatureBase +{ + public MobSkeletonWarrior(Game game, Location loc) + { + super(game, null, Skeleton.class, loc); + } + + @Override + public void SpawnCustom(Skeleton ent) + { + ent.getEquipment().setItemInHand(new ItemStack(Material.WOOD_SWORD)); + } + + @Override + public void Damage(CustomDamageEvent event) + { + + } + + @Override + public void Target(EntityTargetEvent event) + { + + } + + @Override + public void Update(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + //New Target via Distance + if (GetTarget() == null || + UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 10 || + UtilMath.offset2d(GetEntity().getLocation(), GetTarget()) < 6 || + UtilTime.elapsed(GetTargetTime(), 10000)) + { + SetTarget(GetRoamTarget()); + return; + } + + //Untarget + if (GetEntity().getTarget() != null) + { + if (UtilMath.offset2d(GetEntity(), GetEntity().getTarget()) > 10) + { + GetEntity().setTarget(null); + } + } + //Move + else + { + EntityCreature ec = ((CraftCreature)GetEntity()).getHandle(); + Navigation nav = ec.getNavigation(); + + if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) > 12) + { + Location target = GetEntity().getLocation(); + + target.add(UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget()).multiply(12)); + + nav.a(target.getX(), target.getY(), target.getZ(), 1f); + } + else + { + nav.a(GetTarget().getX(), GetTarget().getY(), GetTarget().getZ(), 1f); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSpider.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSpiderLeaper.java similarity index 91% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSpider.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSpiderLeaper.java index 99c750b4f..dccbdac8e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSpider.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSpiderLeaper.java @@ -14,18 +14,18 @@ import net.minecraft.server.v1_6_R3.Navigation; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature; -import org.bukkit.entity.Spider; +import org.bukkit.entity.CaveSpider; import org.bukkit.event.entity.EntityTargetEvent; -public class MobSpider extends CreatureBase +public class MobSpiderLeaper extends CreatureBase { - public MobSpider(Game game, Location loc) + public MobSpiderLeaper(Game game, Location loc) { - super(game, null, Spider.class, loc); + super(game, null, CaveSpider.class, loc); } @Override - public void SpawnCustom(Spider ent) + public void SpawnCustom(CaveSpider ent) { } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSpiderWebber.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSpiderWebber.java new file mode 100644 index 000000000..f0a2fb579 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobSpiderWebber.java @@ -0,0 +1,108 @@ +package nautilus.game.arcade.game.games.halloween.creatures; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.disguise.disguises.DisguiseSpider; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.Game; +import net.minecraft.server.v1_6_R3.EntityCreature; +import net.minecraft.server.v1_6_R3.Navigation; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature; +import org.bukkit.entity.Zombie; +import org.bukkit.event.entity.EntityTargetEvent; + +public class MobSpiderWebber extends CreatureBase +{ + public MobSpiderWebber(Game game, Location loc) + { + super(game, null, Zombie.class, loc); + } + + @Override + public void SpawnCustom(Zombie ent) + { + DisguiseSpider spider = new DisguiseSpider(ent); + Host.Manager.GetDisguise().disguise(spider); + } + + @Override + public void Damage(CustomDamageEvent event) + { + + } + + @Override + public void Target(EntityTargetEvent event) + { + + } + + @Override + public void Update(UpdateEvent event) + { + if (event.getType() == UpdateType.FAST) + Move(); + + if (event.getType() == UpdateType.SEC) + Web(); + } + + private void Web() + { + if (GetTarget() == null) + return; + + if (Math.random() > 0.5) + return; + + + } + + private void Move() + { + //New Target via Distance + if (GetTarget() == null || + UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 10 || + UtilMath.offset2d(GetEntity().getLocation(), GetTarget()) < 6 || + UtilTime.elapsed(GetTargetTime(), 10000)) + { + SetTarget(GetRoamTarget()); + return; + } + + //Untarget + if (GetEntity().getTarget() != null) + { + if (UtilMath.offset2d(GetEntity(), GetEntity().getTarget()) > 10) + { + GetEntity().setTarget(null); + } + } + //Move + else + { + EntityCreature ec = ((CraftCreature)GetEntity()).getHandle(); + Navigation nav = ec.getNavigation(); + + if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) > 12) + { + Location target = GetEntity().getLocation(); + + target.add(UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget()).multiply(12)); + + nav.a(target.getX(), target.getY(), target.getZ(), 1.6f); + } + else + { + nav.a(GetTarget().getX(), GetTarget().getY(), GetTarget().getZ(), 1.2f); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobWitch.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobWitch.java new file mode 100644 index 000000000..c1c1c8175 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobWitch.java @@ -0,0 +1,106 @@ +package nautilus.game.arcade.game.games.halloween.creatures; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.Game; +import net.minecraft.server.v1_6_R3.EntityCreature; +import net.minecraft.server.v1_6_R3.Navigation; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature; +import org.bukkit.entity.ThrownPotion; +import org.bukkit.entity.Witch; +import org.bukkit.event.entity.EntityTargetEvent; + +public class MobWitch extends CreatureBase +{ + public MobWitch(Game game, Location loc) + { + super(game, null, Witch.class, loc); + } + + @Override + public void SpawnCustom(Witch ent) + { + Move(); + } + + @Override + public void Damage(CustomDamageEvent event) + { + + } + + @Override + public void Update(UpdateEvent event) + { + if (event.getType() == UpdateType.SEC) + Move(); + + if (event.getType() == UpdateType.SLOW) + Potion(); + } + + private void Potion() + { + if (GetEntity().getTarget() == null) + return; + + ThrownPotion pot = GetEntity().launchProjectile(ThrownPotion.class); + + Host.Announce("THROWN"); + UtilAction.velocity(pot, UtilAlg.getTrajectory(GetEntity(), GetEntity().getTarget()), 1.2, false, 0, 0.3, 10, false); + } + + private void Move() + { + //New Target via Distance + if (GetTarget() == null || + UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 10 || + UtilMath.offset2d(GetEntity().getLocation(), GetTarget()) < 6 || + UtilTime.elapsed(GetTargetTime(), 10000)) + { + SetTarget(GetRoamTarget()); + return; + } + + //Untarget + if (GetEntity().getTarget() != null) + { + if (UtilMath.offset2d(GetEntity(), GetEntity().getTarget()) > 10) + { + GetEntity().setTarget(null); + } + } + //Move + else + { + EntityCreature ec = ((CraftCreature)GetEntity()).getHandle(); + Navigation nav = ec.getNavigation(); + + if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) > 12) + { + Location target = GetEntity().getLocation(); + + target.add(UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget()).multiply(12)); + + nav.a(target.getX(), target.getY(), target.getZ(), 1.6f); + } + else + { + nav.a(GetTarget().getX(), GetTarget().getY(), GetTarget().getZ(), 1.2f); + } + } + } + + @Override + public void Target(EntityTargetEvent event) + { + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobZombie.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobZombie.java index 3c00ea91f..143eb7c36 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobZombie.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/MobZombie.java @@ -21,30 +21,33 @@ public class MobZombie extends CreatureBase { super(game, null, Zombie.class, loc); } - + @Override public void SpawnCustom(Zombie ent) { - + Move(); } - + @Override public void Damage(CustomDamageEvent event) { - + } @Override public void Update(UpdateEvent event) { - if (event.getType() != UpdateType.FAST) - return; - + if (event.getType() == UpdateType.SEC) + Move(); + } + + private void Move() + { //New Target via Distance if (GetTarget() == null || - UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 10 || - UtilMath.offset2d(GetEntity().getLocation(), GetTarget()) < 6 || - UtilTime.elapsed(GetTargetTime(), 10000)) + UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 10 || + UtilMath.offset2d(GetEntity().getLocation(), GetTarget()) < 6 || + UtilTime.elapsed(GetTargetTime(), 10000)) { SetTarget(GetRoamTarget()); return; @@ -82,6 +85,6 @@ public class MobZombie extends CreatureBase @Override public void Target(EntityTargetEvent event) { - + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/PumpkinKing.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/PumpkinKing.java index 09fb6dc53..9ea2ec6f8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/PumpkinKing.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/PumpkinKing.java @@ -129,7 +129,7 @@ public class PumpkinKing extends CreatureBase { event.SetCancelled("Shield Break"); - if (event.GetProjectile() == null) + if (event.GetCause() != DamageCause.PROJECTILE && event.GetCause() != DamageCause.LIGHTNING) return; event.GetProjectile().remove(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitFinn.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitFinn.java new file mode 100644 index 000000000..1f9c5c482 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitFinn.java @@ -0,0 +1,88 @@ +package nautilus.game.arcade.game.games.halloween.kits; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.SmashKit; +import nautilus.game.arcade.kit.perks.*; + +public class KitFinn extends SmashKit +{ + public KitFinn(ArcadeManager manager) + { + super(manager, "Finn the Human", KitAvailability.Free, + + new String[] + { + "Jake is hiding in his pocket.", + "", + }, + + new Perk[] + { + new PerkInfernoFinn(), + new PerkBlizzardFinn(), + new PerkFletcher(4, 4, false), + }, + + EntityType.ZOMBIE, new ItemStack(Material.GOLD_SWORD)); + + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte)0, 1, "Flaming Sword")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, (byte)0, 1, "Icy Sword")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW, (byte)0, 1, "Bow")); + + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + + + player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(Material.JACK_O_LANTERN)); + player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.IRON_CHESTPLATE)); + player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.IRON_LEGGINGS)); + player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.IRON_BOOTS)); + } + + @Override + public void SpawnCustom(LivingEntity ent) + { + ent.getEquipment().setHelmet(new ItemStack(Material.JACK_O_LANTERN)); + ent.getEquipment().setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); + ent.getEquipment().setLeggings(new ItemStack(Material.IRON_LEGGINGS)); + ent.getEquipment().setBoots(new ItemStack(Material.IRON_BOOTS)); + } + + @EventHandler + public void FireItemResist(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (Manager.GetGame() == null) + return; + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!HasKit(player)) + continue; + + Manager.GetCondition().Factory().FireItemImmunity(GetName(), player, player, 1.9, false); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitDefault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitRobinHood.java similarity index 57% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitDefault.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitRobinHood.java index c58b58001..42fc8b142 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitDefault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitRobinHood.java @@ -4,51 +4,62 @@ import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; import org.bukkit.inventory.ItemStack; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.SmashKit; +import nautilus.game.arcade.kit.perks.*; -public class KitDefault extends Kit +public class KitRobinHood extends SmashKit { - public KitDefault(ArcadeManager manager) + public KitRobinHood(ArcadeManager manager) { - super(manager, "Halloween Dude", KitAvailability.Free, + super(manager, "Robin Hood", KitAvailability.Free, new String[] { - "Just a dude, at halloween." + "Trick or treating from the rich...", + "", }, new Perk[] { - + new PerkSpeed(1), + new PerkRegeneration(0), + new PerkFletcher(1, 4, false), + new PerkBarrage(4, 250, false), + new PerkQuickshotRobinHood() }, - EntityType.ZOMBIE, new ItemStack(Material.IRON_SWORD)); + EntityType.ZOMBIE, new ItemStack(Material.BOW)); } - + @Override public void GiveItems(Player player) { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD)); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW)); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.ARROW, 64)); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, (byte)0, 1, "Sword")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW, (byte)0, 1, "Bow")); player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + - player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(Material.JACK_O_LANTERN)); player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE)); player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS)); player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS)); } - + @Override public void SpawnCustom(LivingEntity ent) { @@ -57,4 +68,22 @@ public class KitDefault extends Kit ent.getEquipment().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS)); ent.getEquipment().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS)); } + + @EventHandler + public void FireItemResist(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (Manager.GetGame() == null) + return; + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!HasKit(player)) + continue; + + Manager.GetCondition().Factory().FireItemImmunity(GetName(), player, player, 1.9, false); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitThor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitThor.java new file mode 100644 index 000000000..7f80731a9 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitThor.java @@ -0,0 +1,88 @@ +package nautilus.game.arcade.game.games.halloween.kits; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.SmashKit; +import nautilus.game.arcade.kit.perks.*; + +public class KitThor extends SmashKit +{ + public KitThor(ArcadeManager manager) + { + super(manager, "Thor Costume", KitAvailability.Free, + + new String[] + { + "Dress up as Thor, and smash those monsters!", + "", + }, + + new Perk[] + { + new PerkKnockbackAttack(2), + new PerkFletcher(4, 4, false), + new PerkSeismicHammer(), + new PerkHammerThrow(), + }, + + EntityType.ZOMBIE, new ItemStack(Material.IRON_SWORD)); + + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE, (byte)0, 1, "Seismic Hammer")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_AXE, (byte)0, 1, "Thor Hammer")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW, (byte)0, 1, "Bow")); + + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + + player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(Material.JACK_O_LANTERN)); + player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_CHESTPLATE)); + player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_LEGGINGS)); + player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BOOTS)); + } + + @Override + public void SpawnCustom(LivingEntity ent) + { + ent.getEquipment().setHelmet(new ItemStack(Material.JACK_O_LANTERN)); + ent.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE)); + ent.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS)); + ent.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); + } + + @EventHandler + public void FireItemResist(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (Manager.GetGame() == null) + return; + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!HasKit(player)) + continue; + + Manager.GetCondition().Factory().FireItemImmunity(GetName(), player, player, 1.9, false); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave1.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave1.java new file mode 100644 index 000000000..72b89680d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave1.java @@ -0,0 +1,31 @@ +package nautilus.game.arcade.game.games.halloween.waves; + +import mineplex.core.common.util.UtilTime; +import nautilus.game.arcade.game.games.halloween.Halloween; +import nautilus.game.arcade.game.games.halloween.creatures.MobCreeper; +import nautilus.game.arcade.game.games.halloween.creatures.MobSkeletonArcher; +import nautilus.game.arcade.game.games.halloween.creatures.MobZombie; + +public class Wave1 extends WaveBase +{ + public Wave1(Halloween host) + { + super(host, "Zombies and Skeletons and Creepers! OH MY!", 60000, host.GetSpawnSet(1)); + } + + @Override + public void Spawn(int tick) + { + if (UtilTime.elapsed(_start, 20000)) + return; + + if (tick % 10 == 0) + Host.AddCreature(new MobZombie(Host, GetSpawn())); + + if (tick % 20 == 0) + Host.AddCreature(new MobSkeletonArcher(Host, GetSpawn())); + + if (tick % 30 == 0) + Host.AddCreature(new MobCreeper(Host, GetSpawn())); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave2.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave2.java new file mode 100644 index 000000000..85af16c09 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave2.java @@ -0,0 +1,35 @@ +package nautilus.game.arcade.game.games.halloween.waves; + +import mineplex.core.common.util.UtilTime; +import nautilus.game.arcade.game.games.halloween.Halloween; +import nautilus.game.arcade.game.games.halloween.creatures.MobCreeper; +import nautilus.game.arcade.game.games.halloween.creatures.MobGiant; +import nautilus.game.arcade.game.games.halloween.creatures.MobSkeletonArcher; +import nautilus.game.arcade.game.games.halloween.creatures.MobZombie; + +public class Wave2 extends WaveBase +{ + public Wave2(Halloween host) + { + super(host, "A GIANT!? Better kill that guy fast!", 60000, host.GetSpawnSet(0)); + } + + @Override + public void Spawn(int tick) + { + if (UtilTime.elapsed(_start, 20000)) + return; + + if (tick == 0) + Host.AddCreature(new MobGiant(Host, GetSpawn())); + + if (tick % 10 == 0) + Host.AddCreature(new MobZombie(Host, GetSpawn())); + + if (tick % 20 == 0) + Host.AddCreature(new MobSkeletonArcher(Host, GetSpawn())); + + if (tick % 30 == 0) + Host.AddCreature(new MobCreeper(Host, GetSpawn())); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave3.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave3.java new file mode 100644 index 000000000..36d002c0f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave3.java @@ -0,0 +1,27 @@ +package nautilus.game.arcade.game.games.halloween.waves; + +import mineplex.core.common.util.UtilTime; +import nautilus.game.arcade.game.games.halloween.Halloween; +import nautilus.game.arcade.game.games.halloween.creatures.MobSpiderLeaper; +import nautilus.game.arcade.game.games.halloween.creatures.MobSpiderWebber; + +public class Wave3 extends WaveBase +{ + public Wave3(Halloween host) + { + super(host, "Spiders Spiders Spiders!", 60000, host.GetSpawnSet(2)); + } + + @Override + public void Spawn(int tick) + { + if (UtilTime.elapsed(_start, 20000)) + return; + + if (tick % 10 == 0) + Host.AddCreature(new MobSpiderWebber(Host, GetSpawn())); + + if (tick % 10 == 0) + Host.AddCreature(new MobSpiderLeaper(Host, GetSpawn())); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave4.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave4.java new file mode 100644 index 000000000..db73a5126 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave4.java @@ -0,0 +1,27 @@ +package nautilus.game.arcade.game.games.halloween.waves; + +import mineplex.core.common.util.UtilTime; +import nautilus.game.arcade.game.games.halloween.Halloween; +import nautilus.game.arcade.game.games.halloween.creatures.MobGhast; +import nautilus.game.arcade.game.games.halloween.creatures.MobPigZombie; + +public class Wave4 extends WaveBase +{ + public Wave4(Halloween host) + { + super(host, "Ghasts (and friends)", 60000, host.GetSpawnSet(3)); + } + + @Override + public void Spawn(int tick) + { + if (UtilTime.elapsed(_start, 20000)) + return; + + if (tick % 100 == 0) + Host.AddCreature(new MobGhast(Host, GetSpawn().clone().add(0, 30, 0))); + + if (tick % 20 == 0) + Host.AddCreature(new MobPigZombie(Host, GetSpawn())); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave5.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave5.java new file mode 100644 index 000000000..4a251b3ef --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave5.java @@ -0,0 +1,27 @@ +package nautilus.game.arcade.game.games.halloween.waves; + +import mineplex.core.common.util.UtilTime; +import nautilus.game.arcade.game.games.halloween.Halloween; +import nautilus.game.arcade.game.games.halloween.creatures.MobCreeper; +import nautilus.game.arcade.game.games.halloween.creatures.MobGiant; +import nautilus.game.arcade.game.games.halloween.creatures.MobSkeletonArcher; +import nautilus.game.arcade.game.games.halloween.creatures.MobWitch; +import nautilus.game.arcade.game.games.halloween.creatures.MobZombie; + +public class Wave5 extends WaveBase +{ + public Wave5(Halloween host) + { + super(host, "Witches and Wolves", 60000, host.GetSpawnSet(3)); + } + + @Override + public void Spawn(int tick) + { + if (UtilTime.elapsed(_start, 20000)) + return; + + if (tick == 0) + Host.AddCreature(new MobWitch(Host, GetSpawn())); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave6.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave6.java new file mode 100644 index 000000000..5b22b8e82 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave6.java @@ -0,0 +1,35 @@ +package nautilus.game.arcade.game.games.halloween.waves; + +import mineplex.core.common.util.UtilTime; +import nautilus.game.arcade.game.games.halloween.Halloween; +import nautilus.game.arcade.game.games.halloween.creatures.MobCreeper; +import nautilus.game.arcade.game.games.halloween.creatures.MobGiant; +import nautilus.game.arcade.game.games.halloween.creatures.MobSkeletonArcher; +import nautilus.game.arcade.game.games.halloween.creatures.MobZombie; + +public class Wave6 extends WaveBase +{ + public Wave6(Halloween host) + { + super(host, "Fiery Night", 60000, host.GetSpawnSet(3)); + } + + @Override + public void Spawn(int tick) + { + if (UtilTime.elapsed(_start, 20000)) + return; + + if (tick == 0) + Host.AddCreature(new MobGiant(Host, GetSpawn())); + + if (tick % 10 == 0) + Host.AddCreature(new MobZombie(Host, GetSpawn())); + + if (tick % 20 == 0) + Host.AddCreature(new MobSkeletonArcher(Host, GetSpawn())); + + if (tick % 30 == 0) + Host.AddCreature(new MobCreeper(Host, GetSpawn())); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave7.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave7.java new file mode 100644 index 000000000..04eaf6aae --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/Wave7.java @@ -0,0 +1,35 @@ +package nautilus.game.arcade.game.games.halloween.waves; + +import mineplex.core.common.util.UtilTime; +import nautilus.game.arcade.game.games.halloween.Halloween; +import nautilus.game.arcade.game.games.halloween.creatures.MobCreeper; +import nautilus.game.arcade.game.games.halloween.creatures.MobGiant; +import nautilus.game.arcade.game.games.halloween.creatures.MobSkeletonArcher; +import nautilus.game.arcade.game.games.halloween.creatures.MobZombie; + +public class Wave7 extends WaveBase +{ + public Wave7(Halloween host) + { + super(host, "Giants, Zombies, Witches and Ghasts...", 60000, host.GetSpawnSet(0)); + } + + @Override + public void Spawn(int tick) + { + if (UtilTime.elapsed(_start, 20000)) + return; + + if (tick == 0) + Host.AddCreature(new MobGiant(Host, GetSpawn())); + + if (tick % 10 == 0) + Host.AddCreature(new MobZombie(Host, GetSpawn())); + + if (tick % 20 == 0) + Host.AddCreature(new MobSkeletonArcher(Host, GetSpawn())); + + if (tick % 30 == 0) + Host.AddCreature(new MobCreeper(Host, GetSpawn())); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveBase.java new file mode 100644 index 000000000..49b795e46 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveBase.java @@ -0,0 +1,118 @@ +package nautilus.game.arcade.game.games.halloween.waves; + +import java.util.ArrayList; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import nautilus.game.arcade.game.games.halloween.Halloween; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; + +public abstract class WaveBase +{ + protected Halloween Host; + + protected String _name; + + protected long _start; + protected long _duration; + + private int _tick = 0; + + protected ArrayList _spawns; + + public WaveBase(Halloween host, String name, long duration, ArrayList spawns) + { + Host = host; + + _name = name; + + _start = System.currentTimeMillis(); + _duration = duration; + + _spawns = spawns; + } + + public Location GetSpawn() + { + return _spawns.get(UtilMath.r(_spawns.size())); + } + + public boolean Update(int wave) + { + //End + if (_tick > 0 && UtilTime.elapsed(_start, _duration) && CanEnd()) + { + System.out.println("Wave " + wave + " has ended."); + return true; + } + + //Start + if (_tick == 0) + _start = System.currentTimeMillis(); + + //Announce + if (_tick == 0) + { + System.out.println("Wave " + wave + " has started."); + Host.Announce(C.cRed + C.Bold + "Wave " + wave + ": " + C.cYellow + _name); + } + + //Display + for (Player player : UtilServer.getPlayers()) + player.setExp(Math.min(0.999f, (float)(_duration - (System.currentTimeMillis() - _start)) / (float)_duration)); + + //Spawn Beacons + if (_tick == 0) + SpawnBeacons(_spawns); + + //Spawn + Host.CreatureAllowOverride = true; + Spawn(_tick++); + Host.CreatureAllowOverride = false; + + return false; + } + + public void SpawnBeacons(ArrayList locs) + { + //Average Location + Vector total = new Vector(0,0,0); + for (Location loc : locs) + total.add(loc.toVector()); + total.multiply((double)1/(double)locs.size()); + + //Beacon + Block block = total.toLocation(locs.get(0).getWorld()).getBlock().getRelative(BlockFace.DOWN); + Host.Manager.GetBlockRestore().Add(block, 138, (byte)0, _duration); + + for (int x=-1 ; x<=1 ; x++) + for (int z=-1 ; z<=1 ; z++) + Host.Manager.GetBlockRestore().Add(block.getRelative(x, -1, z), 42, (byte)0, _duration); + + //Lightning + block.getWorld().strikeLightningEffect(block.getLocation()); + + //Clear Laser + while (block.getY() < 250) + { + block = block.getRelative(BlockFace.UP); + if (block.getType() != Material.AIR) + Host.Manager.GetBlockRestore().Add(block, 0, (byte)0, _duration); + } + } + + public boolean CanEnd() + { + return true; + } + + public abstract void Spawn(int tick); +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveBoss.java new file mode 100644 index 000000000..64c5405ba --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveBoss.java @@ -0,0 +1,35 @@ +package nautilus.game.arcade.game.games.halloween.waves; + +import nautilus.game.arcade.game.games.halloween.Halloween; +import nautilus.game.arcade.game.games.halloween.creatures.MobZombie; +import nautilus.game.arcade.game.games.halloween.creatures.PumpkinKing; + +public class WaveBoss extends WaveBase +{ + private PumpkinKing _king; + + public WaveBoss(Halloween host) + { + super(host, "The Pumpkin King", 0, host.GetSpawnSet(3)); + } + + @Override + public void Spawn(int tick) + { + if (tick == 0) + { + _king = new PumpkinKing(Host, Host.WorldData.GetDataLocs("BLACK").get(0)); + Host.AddCreature(_king); + } + + if (Host.GetCreatures().size() < 30) + if (tick % 20 == 0) + Host.AddCreature(new MobZombie(Host, Host.GetRandomSpawn())); + } + + @Override + public boolean CanEnd() + { + return _king == null || !_king.GetEntity().isValid(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveVictory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveVictory.java new file mode 100644 index 000000000..273ce65d5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveVictory.java @@ -0,0 +1,46 @@ +package nautilus.game.arcade.game.games.halloween.waves; + +import org.bukkit.Effect; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import nautilus.game.arcade.game.games.halloween.Halloween; +import nautilus.game.arcade.game.games.halloween.creatures.CreatureBase; + +public class WaveVictory extends WaveBase +{ + public WaveVictory(Halloween host) + { + super(host, "Celebration!", 0, host.GetSpawnSet(3)); + } + + @Override + public void Spawn(int tick) + { + if (UtilTime.elapsed(_start, 20000)) + return; + + //Play + if (tick == 0) + for (Player player : UtilServer.getPlayers()) + player.playEffect(Host.WorldData.GetDataLocs("BLACK").get(0), Effect.RECORD_PLAY, 2259); + + //Mobs + for (CreatureBase mob : Host.GetCreatures()) + mob.GetEntity().damage(1); + + //Time + if (Host.WorldTimeSet != 6000) + { + Host.WorldTimeSet = (Host.WorldTimeSet + 50)%24000; + Host.WorldData.World.setTime(Host.WorldTimeSet); + } + } + + @Override + public boolean CanEnd() + { + return Host.WorldTimeSet == 6000; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlizzardFinn.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlizzardFinn.java new file mode 100644 index 000000000..cb37040e8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlizzardFinn.java @@ -0,0 +1,154 @@ +package nautilus.game.arcade.kit.perks; + +import java.util.HashMap; +import java.util.WeakHashMap; + +import org.bukkit.Sound; +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.Action; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.kit.Perk; + +public class PerkBlizzardFinn extends Perk +{ + private HashMap _active = new HashMap(); + private WeakHashMap _snowball = new WeakHashMap(); + + public PerkBlizzardFinn() + { + super("Blizzard", new String[] + { + C.cYellow + "Block" + C.cGray + " with Diamond Sword to use " + C.cGreen + "Blizzard" + }); + } + + @EventHandler + public void Activate(PlayerInteractEvent event) + { + if (event.isCancelled()) + return; + + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if (UtilBlock.usable(event.getClickedBlock())) + return; + + if (!event.getPlayer().getItemInHand().getType().toString().contains("DIAMOND_SWORD")) + return; + + Player player = event.getPlayer(); + + if (!Kit.HasKit(player)) + return; + + if (!Recharge.Instance.use(player, GetName(), 4000, true)) + return; + + _active.put(player, System.currentTimeMillis()); + } + + @EventHandler + public void Update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + for (Player player : UtilServer.getPlayers()) + { + if (!_active.containsKey(player)) + continue; + + if (!player.isBlocking()) + { + _active.remove(player); + continue; + } + + if (UtilTime.elapsed(_active.get(player), 1500)) + { + _active.remove(player); + continue; + } + + //Snowball + for (int i=0 ; i<4 ; i++) + { + Snowball snow = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), Snowball.class); + double x = 0.1 - (UtilMath.r(20)/100d); + double y = UtilMath.r(20)/100d; + double z = 0.1 - (UtilMath.r(20)/100d); + snow.setVelocity(player.getLocation().getDirection().add(new Vector(x,y,z)).multiply(2)); + _snowball.put(snow, player); + } + + //Effect + player.getWorld().playSound(player.getLocation(), Sound.STEP_SNOW, 0.1f, 0.5f); + } + } + + @EventHandler(priority = EventPriority.LOW) + public void Snowball(CustomDamageEvent event) + { + if (event.GetCause() != DamageCause.PROJECTILE) + return; + + Projectile proj = event.GetProjectile(); + if (proj == null) return; + + if (!(proj instanceof Snowball)) + return; + + if (!_snowball.containsKey(proj)) + return; + + LivingEntity damagee = event.GetDamageeEntity(); + if (damagee == null) return; + + event.SetCancelled("Blizzard"); + + if (damagee instanceof Player) + return; + + damagee.setVelocity(proj.getVelocity().multiply(0.15).add(new Vector(0, 0.15, 0))); + + //Damage Event + if (damagee instanceof Player) + if (Recharge.Instance.use((Player)damagee, GetName(), 250, false)) + Manager.GetDamage().NewDamageEvent(damagee, event.GetDamagerEntity(true), null, + DamageCause.PROJECTILE, 1.5, false, true, false, + UtilEnt.getName(event.GetDamagerEntity(true)), GetName()); + } + + @EventHandler + public void SnowballForm(ProjectileHitEvent event) + { + if (!(event.getEntity() instanceof Snowball)) + return; + + if (_snowball.remove(event.getEntity()) == null) + return; + + Manager.GetBlockRestore().Snow(event.getEntity().getLocation().getBlock(), (byte)1, (byte)7, 2000, 250, 0); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHammerThrow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHammerThrow.java new file mode 100644 index 000000000..3a8b3ede4 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHammerThrow.java @@ -0,0 +1,170 @@ +package nautilus.game.arcade.kit.perks; + +import java.util.HashMap; +import java.util.Iterator; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +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.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkHammerThrow extends Perk implements IThrown +{ + private HashMap _thrown = new HashMap(); + + public PerkHammerThrow() + { + super("Hammer Throw", new String[] + { + C.cYellow + "Right-Click" + C.cGray + " with Diamond Axe to " + C.cGreen + "Hammer Throw" + }); + } + + @EventHandler + public void Skill(PlayerInteractEvent event) + { + if (event.isCancelled()) + return; + + 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().toString().contains("DIAMOND_AXE")) + return; + + Player player = event.getPlayer(); + + if (!Kit.HasKit(player)) + return; + + player.setItemInHand(null); + + //Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); + + //Throw + Item item = player.getWorld().dropItem(player.getEyeLocation(), new ItemStack(Material.DIAMOND_AXE)); + UtilAction.velocity(item, player.getLocation().getDirection(), 1.2, false, 0, 0.2, 10, true); + + //Projectile + Manager.GetProjectile().AddThrow(item, player, this, -1, true, true, true, false, 2.5d); + + //Store + _thrown.put(item, player); + } + + @EventHandler + public void Pickup(PlayerPickupItemEvent event) + { + if (!_thrown.containsKey(event.getItem())) + return; + + event.setCancelled(true); + event.getItem().remove(); + + Player player = _thrown.remove(event.getItem()); + + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_AXE, (byte)0, 1, "Thor Hammer")); + } + + @EventHandler + public void Timeout(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + Iterator itemIterator = _thrown.keySet().iterator(); + + while (itemIterator.hasNext()) + { + Item item = itemIterator.next(); + + if (item.getTicksLived() > 200) + { + _thrown.get(item).getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_AXE, (byte)0, 1, "Thor Hammer")); + item.remove(); + itemIterator.remove(); + } + } + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + Rebound(data.GetThrower(), data.GetThrown()); + + if (target == null) + return; + + //Damage Event + Manager.GetDamage().NewDamageEvent(target, data.GetThrower(), null, + DamageCause.LIGHTNING, 12, true, true, false, + UtilEnt.getName(data.GetThrower()), GetName()); + } + + @Override + public void Idle(ProjectileUser data) + { + Rebound(data.GetThrower(), data.GetThrown()); + } + + @Override + public void Expire(ProjectileUser data) + { + Rebound(data.GetThrower(), data.GetThrown()); + } + + public void Rebound(LivingEntity player, Entity ent) + { + ent.getWorld().playSound(ent.getLocation(), Sound.ZOMBIE_METAL, 0.6f, 0.5f); + + double mult = 0.5 + (0.6 * (UtilMath.offset(player.getLocation(), ent.getLocation())/16d)); + + //Velocity + ent.setVelocity(player.getLocation().toVector().subtract(ent.getLocation().toVector()).normalize().add(new Vector(0, 0.4, 0)).multiply(mult)); + + //Ticks + if (ent instanceof Item) + ((Item)ent).setPickupDelay(5); + } + + @EventHandler + public void Knockback(CustomDamageEvent event) + { + if (event.GetReason() == null || !event.GetReason().contains(GetName())) + return; + + event.AddKnockback(GetName(), 2); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInfernoFinn.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInfernoFinn.java new file mode 100644 index 000000000..75c3ab149 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInfernoFinn.java @@ -0,0 +1,119 @@ +package nautilus.game.arcade.kit.perks; + +import java.util.HashMap; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Item; +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.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkInfernoFinn extends Perk +{ + private HashMap _active = new HashMap(); + + public PerkInfernoFinn() + { + super("Inferno", new String[] + { + C.cYellow + "Block" + C.cGray + " with Gold Sword to use " + C.cGreen + "Inferno" + }); + } + + @EventHandler + public void Activate(PlayerInteractEvent event) + { + if (event.isCancelled()) + return; + + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if (UtilBlock.usable(event.getClickedBlock())) + return; + + if (!event.getPlayer().getItemInHand().getType().toString().contains("GOLD_SWORD")) + return; + + Player player = event.getPlayer(); + + if (!Kit.HasKit(player)) + return; + + if (!Recharge.Instance.use(player, "Inferno", 4000, true)) + return; + + _active.put(player, System.currentTimeMillis()); + } + + @EventHandler + public void Update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + for (Player cur : UtilServer.getPlayers()) + { + if (!_active.containsKey(cur)) + continue; + + if (!cur.isBlocking()) + { + _active.remove(cur); + continue; + } + + if (UtilTime.elapsed(_active.get(cur), 1500)) + { + _active.remove(cur); + continue; + } + + //Fire + Item fire = cur.getWorld().dropItem(cur.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.FIRE)); + Manager.GetFire().Add(fire, cur, 0.7, 0, 0.5, 2, "Inferno"); + + fire.teleport(cur.getEyeLocation()); + double x = 0.07 - (UtilMath.r(14)/100d); + double y = 0.07 - (UtilMath.r(14)/100d); + double z = 0.07 - (UtilMath.r(14)/100d); + fire.setVelocity(cur.getLocation().getDirection().add(new Vector(x,y,z)).multiply(1.6)); + + //Effect + cur.getWorld().playSound(cur.getLocation(), Sound.GHAST_FIREBALL, 0.1f, 1f); + } + } + + @EventHandler + public void Refresh(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOWER) + return; + + for (Player player : UtilServer.getPlayers()) + { + if (_active.containsKey(player)) + continue; + + if (!Kit.HasKit(player)) + continue; + + player.getInventory().remove(Material.GOLD_SWORD); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte)0, 1, "Flaming Sword")); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockbackAttack.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockbackAttack.java new file mode 100644 index 000000000..46c37f928 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockbackAttack.java @@ -0,0 +1,44 @@ +package nautilus.game.arcade.kit.perks; + +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import mineplex.core.common.util.C; +import nautilus.game.arcade.kit.Perk; + +public class PerkKnockbackAttack extends Perk +{ + private double _power; + + public PerkKnockbackAttack(double power) + { + super("Melee Knockback", new String[] + { + C.cGray + "Melee attacks deal " + (int)(power*100) + "% Knockback.", + }); + + _power = power; + } + + @EventHandler(priority = EventPriority.HIGH) + public void Knockback(CustomDamageEvent event) + { + if (event.GetCause() != DamageCause.ENTITY_ATTACK) + return; + + Player damager = event.GetDamagerPlayer(true); + if (damager == null) return; + + if (!Kit.HasKit(damager)) + return; + + if (!Manager.IsAlive(damager)) + return; + + event.AddKnockback("Knockback Melee", _power); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkQuickshot.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkQuickshot.java index 79152bfee..9ef092340 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkQuickshot.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkQuickshot.java @@ -22,7 +22,7 @@ public class PerkQuickshot extends Perk public PerkQuickshot(String name, double power, long recharge) { - super("Leaper", new String[] + super("Quickshot", new String[] { C.cYellow + "Left-Click" + C.cGray + " with Bow to " + C.cGreen + name }); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkQuickshotRobinHood.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkQuickshotRobinHood.java new file mode 100644 index 000000000..62635e06d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkQuickshotRobinHood.java @@ -0,0 +1,56 @@ +package nautilus.game.arcade.kit.perks; + +import org.bukkit.Material; +import org.bukkit.entity.Arrow; +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.common.util.C; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilInv; +import nautilus.game.arcade.kit.Perk; + +public class PerkQuickshotRobinHood extends Perk +{ + public PerkQuickshotRobinHood() + { + super("Quick Shot", new String[] + { + C.cYellow + "Left-Click" + C.cGray + " with Bow to " + C.cGreen + "Quick Shot" + }); + } + + @EventHandler + public void Leap(PlayerInteractEvent event) + { + if (event.isCancelled()) + return; + + if (event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.LEFT_CLICK_BLOCK) + return; + + if (UtilBlock.usable(event.getClickedBlock())) + return; + + if (event.getPlayer().getItemInHand() == null) + return; + + if (event.getPlayer().getItemInHand().getType() != Material.BOW) + return; + + Player player = event.getPlayer(); + + if (!Kit.HasKit(player)) + return; + + if (!player.getInventory().contains(Material.ARROW)) + return; + + UtilInv.remove(player, Material.ARROW, (byte)1, 1); + + Arrow arrow = player.launchProjectile(Arrow.class); + arrow.setVelocity(player.getLocation().getDirection().multiply(2)); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicHammer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicHammer.java new file mode 100644 index 000000000..3db1f85e1 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicHammer.java @@ -0,0 +1,92 @@ +package nautilus.game.arcade.kit.perks; + +import java.util.HashMap; + +import org.bukkit.Effect; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; + +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.UtilPlayer; +import mineplex.core.recharge.Recharge; +import nautilus.game.arcade.kit.Perk; + +public class PerkSeismicHammer extends Perk +{ + public PerkSeismicHammer() + { + super("Seismic Slam", new String[] + { + C.cYellow + "Right-Click" + C.cGray + " with Iron Axe to " + C.cGreen + "Seismic Hammer" + }); + } + + @EventHandler + public void Skill(PlayerInteractEvent event) + { + if (event.isCancelled()) + return; + + 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().toString().contains("IRON_AXE")) + return; + + Player player = event.getPlayer(); + + if (!Kit.HasKit(player)) + return; + + if (!Recharge.Instance.use(player, GetName(), 10000, true)) + return; + + //Action + int damage = 10; + double range = 10; + + HashMap targets = UtilEnt.getInRadius(player.getLocation(), range); + for (LivingEntity cur : targets.keySet()) + { + if (cur instanceof Player) + continue; + + //Damage Event + Manager.GetDamage().NewDamageEvent(cur, player, null, + DamageCause.CUSTOM, damage * targets.get(cur) + 0.5, false, true, false, + player.getName(), GetName()); + + //Velocity + UtilAction.velocity(cur, + UtilAlg.getTrajectory2d(player.getLocation().toVector(), cur.getLocation().toVector()), + 2.2 * targets.get(cur), true, 0, 0.4 + 1.0 * targets.get(cur), 1.6, true); + } + + //Effect + player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_METAL, 2f, 0.2f); + for (Block cur : UtilBlock.getInRadius(player.getLocation(), 4d).keySet()) + if (UtilBlock.airFoliage(cur.getRelative(BlockFace.UP)) && !UtilBlock.airFoliage(cur)) + cur.getWorld().playEffect(cur.getLocation(), Effect.STEP_SOUND, cur.getTypeId()); + + //Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java index 20acd27b1..7bc5af3ab 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java @@ -19,6 +19,7 @@ import nautilus.game.arcade.game.Game; import nautilus.minecraft.core.utils.ZipUtil; import net.minecraft.server.v1_6_R3.ChunkPreLoadEvent; +import org.bukkit.Difficulty; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.WorldCreator; @@ -78,6 +79,7 @@ public class WorldData { //Start World World = WorldUtil.LoadWorld(new WorldCreator(GetFolder())); + World.setDifficulty(Difficulty.HARD); //Load World Data worldData.LoadWorldConfig();