From 0585116e78088a749b053f971429bb8f4e7c7d61 Mon Sep 17 00:00:00 2001 From: Chiss Date: Sat, 21 Dec 2013 20:05:42 +1100 Subject: [PATCH] Hub Gadgets Hub Dragon (Hero Only) XMAS block efficiency --- .../src/mineplex/hub/HubManager.java | 17 +- .../mineplex/hub/gadget/GadgetManager.java | 6 +- .../hub/gadget/ui/ActivateMountButton.java | 1 + .../hub/gadget/ui/DeactivateMountButton.java | 1 + .../mineplex/hub/gadget/ui/GadgetPage.java | 13 +- .../mineplex/hub/gadget/ui/MountButton.java | 1 + .../src/mineplex/hub/modules/NewsManager.java | 11 +- .../mineplex/hub/modules/ParkourManager.java | 3 +- .../mineplex/hub/modules/StackerManager.java | 4 + .../src/mineplex/hub/mount/DragonData.java | 58 ++++++ .../src/mineplex/hub/mount/DragonMount.java | 46 +++++ .../src/mineplex/hub/mount/HorseMount.java | 142 ++++++++++++++ .../src/mineplex/hub/mount/Mount.java | 177 +++--------------- .../src/mineplex/hub/mount/MountManager.java | 5 +- .../src/mineplex/hub/mount/types/Dragon.java | 78 ++++++++ .../src/mineplex/hub/mount/types/Frost.java | 4 +- .../src/mineplex/hub/mount/types/Mule.java | 4 +- .../src/mineplex/hub/mount/types/Undead.java | 4 +- .../games/christmas/content/BossFloor.java | 2 +- 19 files changed, 401 insertions(+), 176 deletions(-) create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/mount/DragonData.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/mount/DragonMount.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/mount/HorseMount.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Dragon.java diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index d5a333b6e..a8879a434 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -78,6 +78,8 @@ public class HubManager extends MiniClientPlugin private PartyManager _partyManager; private Portal _portal; private StatsManager _statsManager; + private GadgetManager _gadgetManager; + private MountManager _mountManager; private VisibilityManager _visibilityManager; private TutorialManager _tutorialManager; @@ -120,7 +122,8 @@ public class HubManager extends MiniClientPlugin new JumpManager(this); new NewsManager(this); - new GadgetManager(this, new MountManager(this)); + _mountManager = new MountManager(this); + _gadgetManager = new GadgetManager(this, _mountManager); _partyManager = partyManager; _tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator); @@ -672,6 +675,16 @@ public class HubManager extends MiniClientPlugin return _disguiseManager; } + public GadgetManager GetGadget() + { + return _gadgetManager; + } + + public MountManager GetMount() + { + return _mountManager; + } + public ParkourManager GetParkour() { return _parkour; @@ -746,6 +759,4 @@ public class HubManager extends MiniClientPlugin } } } - - } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java index 737a0d9bf..17b313ca3 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java @@ -22,11 +22,7 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.itemstack.ItemStackFactory; import mineplex.hub.HubManager; -import mineplex.hub.gadget.gadgets.Christmas2013_Helmet; -import mineplex.hub.gadget.gadgets.Christmas2013_SnowCannon; -import mineplex.hub.gadget.gadgets.Halloween2013_BatGun; -import mineplex.hub.gadget.gadgets.Halloween2013_Helmet; -import mineplex.hub.gadget.gadgets.PaintballGun; +import mineplex.hub.gadget.gadgets.*; import mineplex.hub.gadget.types.ArmorGadget; import mineplex.hub.gadget.types.ArmorGadget.ArmorSlot; import mineplex.hub.gadget.types.Gadget; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivateMountButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivateMountButton.java index 6aac6db6e..cc89ff3c8 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivateMountButton.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivateMountButton.java @@ -3,6 +3,7 @@ package mineplex.hub.gadget.ui; import org.bukkit.entity.Player; import mineplex.core.shop.item.IButton; +import mineplex.hub.mount.HorseMount; import mineplex.hub.mount.Mount; public class ActivateMountButton implements IButton diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivateMountButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivateMountButton.java index f9eeb8ecf..7f5d17c7b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivateMountButton.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivateMountButton.java @@ -3,6 +3,7 @@ package mineplex.hub.gadget.ui; import org.bukkit.entity.Player; import mineplex.core.shop.item.IButton; +import mineplex.hub.mount.HorseMount; import mineplex.hub.mount.Mount; public class DeactivateMountButton implements IButton diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetPage.java index e73e9be00..f284311de 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetPage.java @@ -20,6 +20,7 @@ import mineplex.hub.gadget.GadgetManager; import mineplex.hub.gadget.types.ArmorGadget; import mineplex.hub.gadget.types.Gadget; import mineplex.hub.gadget.types.ItemGadget; +import mineplex.hub.mount.HorseMount; import mineplex.hub.mount.Mount; import mineplex.hub.mount.MountManager; @@ -204,7 +205,7 @@ public class GadgetPage extends ShopPageBase Player.closeInventory(); } - public void PurchaseMount(final Player player, final Mount mount) + public void PurchaseMount(final Player player, final Mount _mount) { Shop.OpenPageForPlayer(Player, new ConfirmationPage(Plugin, Shop, ClientManager, DonationManager, new Runnable() { @@ -212,20 +213,20 @@ public class GadgetPage extends ShopPageBase { Player.closeInventory(); } - }, null, mount, CurrencyType.Gems, Player)); + }, null, _mount, CurrencyType.Gems, Player)); } - public void ActivateMount(Player player, Mount mount) + public void ActivateMount(Player player, Mount _mount) { PlayAcceptSound(player); - mount.Enable(player); + _mount.Enable(player); Player.closeInventory(); } - public void DeactivateMount(Player player, Mount mount) + public void DeactivateMount(Player player, Mount _mount) { PlayAcceptSound(player); - mount.Disable(player); + _mount.Disable(player); Player.closeInventory(); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/MountButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/MountButton.java index 1f29b7387..14befd2db 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/MountButton.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/MountButton.java @@ -3,6 +3,7 @@ package mineplex.hub.gadget.ui; import org.bukkit.entity.Player; import mineplex.core.shop.item.IButton; +import mineplex.hub.mount.HorseMount; import mineplex.hub.mount.Mount; public class MountButton implements IButton diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java index 7c3bd6113..377290c3b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java @@ -12,6 +12,8 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.HubManager; +import mineplex.hub.mount.Mount; +import mineplex.hub.mount.types.Dragon; public class NewsManager extends MiniPlugin { @@ -65,6 +67,13 @@ public class NewsManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) UtilDisplay.displayTextBar(Manager.GetPlugin(), player, (double)_newsIndex/(double)(_news.length-1), text); + + for (Mount mount : Manager.GetMount().getMounts()) + { + if (mount instanceof Dragon) + { + ((Dragon)mount).SetName(text); + } + } } - } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java index 1b300d34f..01bd79d7c 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java @@ -8,6 +8,7 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.entity.EnderDragon; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -137,7 +138,7 @@ public class ParkourManager extends MiniPlugin { if (InParkour(player)) { - if (player.getVehicle() != null || player.getPassenger() != null) + if ((player.getVehicle() != null && !(player.getVehicle() instanceof EnderDragon)) || player.getPassenger() != null) { player.eject(); player.leaveVehicle(); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java index 3058b636b..7ae6375ac 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java @@ -8,6 +8,7 @@ import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; +import org.bukkit.entity.EnderDragon; import org.bukkit.entity.Entity; import org.bukkit.entity.Horse; import org.bukkit.entity.LivingEntity; @@ -121,6 +122,9 @@ public class StackerManager extends MiniPlugin implements IThrown if (stackee instanceof Horse) return; + + if (stackee instanceof EnderDragon) + return; if (stackee instanceof Player && ((Player)stackee).getGameMode() != GameMode.SURVIVAL) return; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/DragonData.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/DragonData.java new file mode 100644 index 000000000..e0f6ebb4d --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/DragonData.java @@ -0,0 +1,58 @@ +package mineplex.hub.mount; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; + +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEnderDragon; +import org.bukkit.entity.EnderDragon; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +public class DragonData +{ + DragonMount Host; + + public EnderDragon Dragon; + public Player Rider; + + public Entity TargetEntity = null; + + public Location Location = null; + + public float Pitch = 0; + public Vector Velocity = new Vector(0,0,0); + + public DragonData(DragonMount dragonMount, Player rider) + { + Host = dragonMount; + + Rider = rider; + + Velocity = rider.getLocation().getDirection().setY(0).normalize(); + Pitch = UtilAlg.GetPitch(rider.getLocation().getDirection()); + + Location = rider.getLocation(); + + //Spawn Dragon + Dragon = rider.getWorld().spawn(rider.getLocation(), EnderDragon.class); + UtilEnt.Vegetate(Dragon); + UtilEnt.ghost(Dragon, true, false); + + rider.getWorld().playSound(rider.getLocation(), Sound.ENDERDRAGON_GROWL, 20f, 1f); + + Dragon.setPassenger(Rider); + } + + public void Move() + { + ((CraftEnderDragon)Dragon).getHandle().setTargetBlock(GetTarget().getBlockX(), GetTarget().getBlockY(), GetTarget().getBlockZ()); + } + + public Location GetTarget() + { + return Rider.getLocation().add(Rider.getLocation().getDirection().multiply(40)); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/DragonMount.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/DragonMount.java new file mode 100644 index 000000000..766db0ba9 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/DragonMount.java @@ -0,0 +1,46 @@ +package mineplex.hub.mount; + +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; + +public class DragonMount extends Mount +{ + public DragonMount(MountManager manager, String name, String[] desc, Material displayMaterial, byte displayData, int cost) + { + super (manager, name, displayMaterial, displayData, desc, cost); + + KnownPackage = false; + + Manager.GetPlugin().getServer().getPluginManager().registerEvents(this, Manager.GetPlugin()); + } + + @Override + public void Enable(final Player player) + { + //Remove other mounts + Manager.DeregisterAll(player); + + //Inform + UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); + + //Store + _active.put(player, new DragonData(this, player)); + + } + + @Override + public void Disable(Player player) + { + DragonData data = _active.remove(player); + if (data != null) + { + data.Dragon.remove(); + + //Inform + UtilPlayer.message(player, F.main("Mount", "You despawned " + F.elem(GetName()) + ".")); + } + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/HorseMount.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/HorseMount.java new file mode 100644 index 000000000..6a798fda8 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/HorseMount.java @@ -0,0 +1,142 @@ +package mineplex.hub.mount; + +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.inventory.ItemStack; + +public class HorseMount extends Mount +{ + private Color _color; + private Style _style; + private Variant _variant; + private double _jump; + private Material _armor; + + public HorseMount(MountManager manager, String name, String[] desc, Material displayMaterial, byte displayData, int cost, Color color, Style style, Variant variant, double jump, Material armor) + { + super (manager, name, displayMaterial, displayData, desc, cost); + KnownPackage = false; + + _color = color; + _style = style; + _variant = variant; + _jump = jump; + _armor = armor; + + Manager.GetPlugin().getServer().getPluginManager().registerEvents(this, Manager.GetPlugin()); + } + + @EventHandler + public void UpdateHorse(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + 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; + } + + //Parkour + if (Manager.Manager.GetParkour().InParkour(horse)) + { + 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) > 4) + { + nav.a(target.getX(), target.getY(), target.getZ(), 1.4f); + } + } + } + + public void Enable(Player player) + { + //Parkour + if (Manager.Manager.GetParkour().InParkour(player)) + { + UtilPlayer.message(player, F.main("Mount", "You cannot use Mounts near Parkour.")); + return; + } + + //Remove other mounts + Manager.DeregisterAll(player); + + 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 " + GetName()); + horse.setCustomNameVisible(true); + + //Inform + UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); + + //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(GetName()) + ".")); + } + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/Mount.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/Mount.java index 2217b7cea..4fce2a407 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/Mount.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/Mount.java @@ -1,84 +1,41 @@ package mineplex.hub.mount; - import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; -import mineplex.core.common.CurrencyType; -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.shop.item.SalesPackageBase; -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 extends SalesPackageBase implements Listener +import mineplex.core.common.CurrencyType; +import mineplex.core.shop.item.SalesPackageBase; + +public abstract class Mount extends SalesPackageBase implements Listener { - private HashSet _owners = new HashSet(); - private HashMap _active = new HashMap(); + protected HashSet _owners = new HashSet(); + protected HashMap _active = new HashMap(); public MountManager Manager; - private Color _color; - private Style _style; - private Variant _variant; - private double _jump; - private Material _armor; - - public Mount(MountManager manager, String name, String[] desc, Material displayMaterial, byte displayData, int cost, Color color, Style style, Variant variant, double jump, Material armor) + public Mount(MountManager manager, String name, Material material, byte displayData, String[] description, int gems) { - super (name, displayMaterial, displayData, desc, cost); - KnownPackage = false; + super(name, material, displayData, description, gems); Manager = manager; + } + + @Override + public void Sold(Player player, CurrencyType currencyType) + { - _color = color; - _style = style; - _variant = variant; - _jump = jump; - _armor = armor; - - Manager.GetPlugin().getServer().getPluginManager().registerEvents(this, Manager.GetPlugin()); } - - 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); - } - + + public abstract void Enable(Player player); + public abstract void Disable(Player player); + @EventHandler public void PlayerJoin(PlayerJoinEvent event) { @@ -93,105 +50,23 @@ public class Mount extends SalesPackageBase implements Listener Disable(event.getPlayer()); } - @EventHandler - public void UpdateHorse(UpdateEvent event) + public HashSet GetOwners() { - if (event.getType() != UpdateType.SEC) - 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; - } - - //Parkour - if (Manager.Manager.GetParkour().InParkour(horse)) - { - 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) > 4) - { - nav.a(target.getX(), target.getY(), target.getZ(), 1.4f); - } - } + return _owners; } - public void Enable(Player player) + public HashMap GetActive() { - //Parkour - if (Manager.Manager.GetParkour().InParkour(player)) - { - UtilPlayer.message(player, F.main("Mount", "You cannot use Mounts near Parkour.")); - return; - } - - //Remove other mounts - Manager.DeregisterAll(player); - - 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 " + GetName()); - horse.setCustomNameVisible(true); - - //Inform - UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); - - //Store - _active.put(player, horse); + return _active; } - public void Disable(Player player) + public boolean IsActive(Player player) { - Horse horse = _active.remove(player); - if (horse != null) - { - horse.remove(); - - //Inform - UtilPlayer.message(player, F.main("Mount", "You despawned " + F.elem(GetName()) + ".")); - } + return _active.containsKey(player); } - - @Override - public void Sold(Player player, CurrencyType currencyType) + + public boolean HasMount(Player player) { - + return _owners.contains(player); } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/MountManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/MountManager.java index 77b2a7227..fea855243 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/MountManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/MountManager.java @@ -39,6 +39,7 @@ public class MountManager extends MiniPlugin _types.add(new Undead(this)); _types.add(new Frost(this)); _types.add(new Mule(this)); + _types.add(new Dragon(this)); } public HashSet getMounts() @@ -51,9 +52,9 @@ public class MountManager extends MiniPlugin { if (Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.MODERATOR)) { - for (Mount gadget : _types) + for (Mount mount : _types) { - Manager.GetDonation().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(gadget.GetName()); + Manager.GetDonation().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(mount.GetName()); } } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Dragon.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Dragon.java new file mode 100644 index 000000000..0545234e2 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Dragon.java @@ -0,0 +1,78 @@ +package mineplex.hub.mount.types; + +import java.util.HashSet; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityTargetEvent; + +import mineplex.core.common.util.C; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.mount.DragonData; +import mineplex.hub.mount.DragonMount; +import mineplex.hub.mount.MountManager; + +public class Dragon extends DragonMount +{ + + public Dragon(MountManager manager) + { + super(manager, "Ethereal Dragon", new String[] + { + C.cWhite + "From the distant ether realm,", + C.cWhite + "this prized dragon is said to", + C.cWhite + "obey only true Heroes!", + " ", + C.cDPurple + "Unlocked with Hero Rank", + }, + Material.DRAGON_EGG, + (byte)0, + -1); + } + + @EventHandler + public void DragonLocation(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + for (DragonData data : GetActive().values()) + data.Move(); + + HashSet toRemove = new HashSet(); + + for (Player player : GetActive().keySet()) + { + DragonData data = GetActive().get(player); + if (data == null) + { + toRemove.add(player); + continue; + } + + if (!data.Dragon.isValid() || data.Dragon.getPassenger() == null) + { + data.Dragon.remove(); + toRemove.add(player); + continue; + } + } + + for (Player player : toRemove) + Disable(player); + } + + @EventHandler + public void DragonTargetCancel(EntityTargetEvent event) + { + event.setCancelled(true); + } + + public void SetName(String news) + { + for (DragonData dragon : GetActive().values()) + dragon.Dragon.setCustomName(news); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Frost.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Frost.java index 5c9947266..23ecff088 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Frost.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Frost.java @@ -18,10 +18,10 @@ 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.HorseMount; import mineplex.hub.mount.MountManager; -public class Frost extends Mount +public class Frost extends HorseMount { public Frost(MountManager manager) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Mule.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Mule.java index 02365e363..7ed45129c 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Mule.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Mule.java @@ -6,10 +6,10 @@ 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.HorseMount; import mineplex.hub.mount.MountManager; -public class Mule extends Mount +public class Mule extends HorseMount { public Mule(MountManager manager) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Undead.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Undead.java index c5e72efd2..0d48d623a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Undead.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Undead.java @@ -14,10 +14,10 @@ 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.HorseMount; import mineplex.hub.mount.MountManager; -public class Undead extends Mount +public class Undead extends HorseMount { public Undead(MountManager manager) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/content/BossFloor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/content/BossFloor.java index 9bd22b1e3..25fb64e05 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/content/BossFloor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/content/BossFloor.java @@ -72,7 +72,7 @@ public class BossFloor for (Location loc : _floor.keySet()) { if (loc.getBlock().getType() == Material.AIR) - loc.getBlock().setTypeIdAndData(35, _floor.get(loc), false); + MapUtil.QuickChangeBlockAt(loc, 35, _floor.get(loc)); } }