diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonData.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonData.java index 8335ef029..1203bad95 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonData.java @@ -1,7 +1,7 @@ package mineplex.core.mount; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; +import java.util.ArrayList; +import java.util.List; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -13,12 +13,14 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.util.Vector; -public class DragonData +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; + +public class DragonData extends MountData { DragonMount Host; public EnderDragon Dragon; - public Player Rider; public Entity TargetEntity = null; @@ -31,9 +33,8 @@ public class DragonData public DragonData(DragonMount dragonMount, Player rider) { - Host = dragonMount; - - Rider = rider; + super(rider); + Host = dragonMount; Velocity = rider.getLocation().getDirection().setY(0).normalize(); Pitch = UtilAlg.GetPitch(rider.getLocation().getDirection()); @@ -51,25 +52,34 @@ public class DragonData Chicken = rider.getWorld().spawn(rider.getLocation(), Chicken.class); Dragon.setPassenger(Chicken); - Chicken.setPassenger(Rider); + Chicken.setPassenger(getOwner()); Bukkit.getServer().getScheduler().runTaskLater(Host.Manager.getPlugin(), new Runnable() { public void run() { - Chicken.setPassenger(Rider); + Chicken.setPassenger(getOwner()); } }, 10L); } public void Move() { - Rider.eject(); + getOwner().eject(); ((CraftEnderDragon)Dragon).getHandle().setTargetBlock(GetTarget().getBlockX(), GetTarget().getBlockY(), GetTarget().getBlockZ()); } public Location GetTarget() { - return Rider.getLocation().add(Rider.getLocation().getDirection().multiply(40)); + return getOwner().getLocation().add(getOwner().getLocation().getDirection().multiply(40)); + } + + @Override + public List getEntityParts() + { + List list = new ArrayList(); + list.add(Dragon); + list.add(Chicken); + return list; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonMount.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonMount.java index af1c1831e..9cf933aac 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonMount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonMount.java @@ -5,7 +5,6 @@ import org.bukkit.entity.Player; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.disguise.disguises.DisguiseChicken; public class DragonMount extends Mount { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java index d8ec72939..d4267beec 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java @@ -22,7 +22,7 @@ import org.bukkit.entity.Horse.Style; import org.bukkit.event.EventHandler; import org.bukkit.inventory.ItemStack; -public class HorseMount extends Mount +public class HorseMount extends Mount> { protected Color _color; protected Style _style; @@ -53,7 +53,7 @@ public class HorseMount extends Mount while (activeIterator.hasNext()) { Player player = activeIterator.next(); - Horse horse = _active.get(player); + Horse horse = _active.get(player).getEntity(); //Invalid (dead) if (!horse.isValid()) @@ -113,15 +113,16 @@ public class HorseMount extends Mount UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); //Store - _active.put(player, horse); + SingleEntityMountData mount = new SingleEntityMountData(player, horse); + _active.put(player, mount); } public void Disable(Player player) { - Horse horse = _active.remove(player); - if (horse != null) + SingleEntityMountData mount = _active.remove(player); + if (mount != null) { - horse.remove(); + mount.remove(); //Inform UtilPlayer.message(player, F.main("Mount", "You despawned " + F.elem(GetName()) + ".")); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java index f9731fe6c..9a1f30a21 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java @@ -5,6 +5,7 @@ import java.util.HashSet; import org.bukkit.Bukkit; import org.bukkit.Material; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -18,7 +19,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.mount.event.MountActivateEvent; import mineplex.core.shop.item.SalesPackageBase; -public abstract class Mount extends SalesPackageBase implements Listener +public abstract class Mount extends SalesPackageBase implements Listener { protected HashSet _owners = new HashSet(); protected HashMap _active = new HashMap(); @@ -97,4 +98,13 @@ public abstract class Mount extends SalesPackageBase implements Listener { return _owners.contains(player); } + + public T getMountData(Entity ent) + { + for(T data : GetActive().values()) + { + if(data.isPartOfMount(ent)) return data; + } + return null; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java index 78d19c59a..4de2d6666 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java @@ -3,6 +3,17 @@ package mineplex.core.mount; import java.util.ArrayList; import java.util.List; +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; + import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.blockrestore.BlockRestore; @@ -22,17 +33,6 @@ import mineplex.core.mount.types.MountTitan; import mineplex.core.mount.types.MountUndead; import mineplex.core.mount.types.MountZombie; -import org.bukkit.Material; -import org.bukkit.entity.Entity; -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.entity.PlayerDeathEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.plugin.java.JavaPlugin; - public class MountManager extends MiniPlugin { private CoreClientManager _clientManager; @@ -84,32 +84,30 @@ public class MountManager extends MiniPlugin } @EventHandler - public void HorseInteract(PlayerInteractEntityEvent event) + public void mountInteract(PlayerInteractAtEntityEvent event) + { + MountData mount = getMountData(event.getRightClicked()); + + if(mount == null) return; + + if(mount.ownsMount(event.getPlayer())) return; + + event.setCancelled(true); + + } + + @EventHandler + public void mountInteract(PlayerInteractEntityEvent event) { - if (!(event.getRightClicked() instanceof Horse)) - return; + MountData mount = getMountData(event.getRightClicked()); - boolean found = false; - for (Mount mount : _playerActiveMountMap.values()) - { - if (mount.GetActive().containsValue(event.getRightClicked())) - { - found = true; - break; - } - } + if(mount == null) return; - if (!found) - return; - - Player player = event.getPlayer(); - Horse horse = (Horse)event.getRightClicked(); + if(mount.ownsMount(event.getPlayer())) return; + + UtilPlayer.message(event.getPlayer(), F.main("Mount", "This is not your Mount!")); + event.setCancelled(true); - if (horse.getOwner() == null || !horse.getOwner().equals(player)) - { - UtilPlayer.message(player, F.main("Mount", "This is not your Mount!")); - event.setCancelled(true); - } } @EventHandler @@ -178,16 +176,28 @@ public class MountManager extends MiniPlugin { return _disguiseManager; } - - public boolean isMount(Entity ent) + + public MountData getMountData(Entity ent) { for (Mount mount : _playerActiveMountMap.values()) { - if (mount.GetActive().values().contains(ent)) - { - return true; - } + MountData data = mount.getMountData(ent); + if(data != null) return data; } - return false; + return null; + } + + public Mount getMount(Entity ent) + { + for (Mount mount : _playerActiveMountMap.values()) + { + if(mount.getMountData(ent) != null) return mount; + } + return null; + } + + public boolean isMount(Entity ent) + { + return getMount(ent) != null; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountCart.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountCart.java index c524acb9d..3abbf00e0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountCart.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountCart.java @@ -1,5 +1,6 @@ package mineplex.core.mount.types; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.Sound; @@ -18,23 +19,12 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.mount.Mount; import mineplex.core.mount.MountManager; +import mineplex.core.mount.SingleEntityMountData; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; - -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftMinecart; -import org.bukkit.entity.Minecart; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.vehicle.VehicleDamageEvent; - -public class MountCart extends Mount +public class MountCart extends Mount> { public MountCart(MountManager manager) { @@ -56,7 +46,7 @@ public class MountCart extends Mount //Remove other mounts Manager.DeregisterAll(player); - Minecart mount = player.getWorld().spawn(player.getLocation().add(0, 2, 0), Minecart.class); + SingleEntityMountData mount = new SingleEntityMountData(player, player.getWorld().spawn(player.getLocation().add(0, 2, 0), Minecart.class)); //Inform UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); @@ -67,7 +57,7 @@ public class MountCart extends Mount public void Disable(Player player) { - Minecart mount = _active.remove(player); + SingleEntityMountData mount = _active.remove(player); if (mount != null) { mount.remove(); @@ -85,14 +75,11 @@ public class MountCart extends Mount if (event.getRightClicked() == null) return; - if (!GetActive().containsKey(event.getPlayer())) - return; + SingleEntityMountData mount = GetActive().get(event.getPlayer()); - if (!GetActive().get(event.getPlayer()).equals(event.getRightClicked())) - { - UtilPlayer.message(event.getPlayer(), F.main("Mount", "This is not your Mount!")); - return; - } + if(mount == null) return; + + if(!mount.ownsMount(event.getPlayer())) return; event.getPlayer().leaveVehicle(); event.getPlayer().eject(); @@ -117,8 +104,10 @@ public class MountCart extends Mount return; //Bounce - for (Minecart cart : GetActive().values()) + for (SingleEntityMountData cartData : GetActive().values()) { + Minecart cart = cartData.getEntity(); + if (cart.getPassenger() == null) continue; @@ -137,8 +126,10 @@ public class MountCart extends Mount } //Collide - for (Minecart cart : GetActive().values()) + for (SingleEntityMountData cartData : GetActive().values()) { + Minecart cart = cartData.getEntity(); + if (cart.getPassenger() == null) continue; @@ -150,8 +141,9 @@ public class MountCart extends Mount if (!Recharge.Instance.usable(player, GetName() + " Collide")) continue; - for (Minecart other : GetActive().values()) + for (SingleEntityMountData otherData : GetActive().values()) { + Minecart other = otherData.getEntity(); if (other.equals(cart)) continue; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountFrost.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountFrost.java index e5b2d2bf8..e948ca9e3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountFrost.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountFrost.java @@ -9,11 +9,11 @@ import org.bukkit.event.EventHandler; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.mount.HorseMount; import mineplex.core.mount.MountManager; +import mineplex.core.mount.SingleEntityMountData; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -38,10 +38,12 @@ public class MountFrost extends HorseMount public void Trail(UpdateEvent event) { if (event.getType() == UpdateType.TICK) - for (Horse horse : GetActive().values()) - UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, horse.getLocation().add(0, 1, 0), - 0.25f, 0.25f, 0.25f, 0.1f, 4, - ViewDist.NORMAL, UtilServer.getPlayers()); + for (SingleEntityMountData horseData : GetActive().values()) + { + Horse horse = horseData.getEntity(); + UtilParticle.PlayParticleToAll(ParticleType.SNOW_SHOVEL, horse.getLocation().add(0, 1, 0), + 0.25f, 0.25f, 0.25f, 0.1f, 4, ViewDist.NORMAL); + } } // @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSheep.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSheep.java index e2982d6ab..c2697c771 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSheep.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSheep.java @@ -5,19 +5,19 @@ import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.entity.Horse; import org.bukkit.entity.Horse.Color; -import org.bukkit.entity.Player; 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.inventory.ItemStack; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.disguise.disguises.DisguiseBase; -import mineplex.core.disguise.disguises.DisguisePig; import mineplex.core.disguise.disguises.DisguiseSheep; import mineplex.core.mount.HorseMount; import mineplex.core.mount.MountManager; +import mineplex.core.mount.SingleEntityMountData; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -45,6 +45,7 @@ public class MountSheep extends HorseMount Manager.DeregisterAll(player); Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class); + SingleEntityMountData mount = new SingleEntityMountData(player, horse); horse.setOwner(player); horse.setMaxDomestication(1); @@ -59,7 +60,7 @@ public class MountSheep extends HorseMount UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); //Store - _active.put(player, horse); + _active.put(player, mount); } @EventHandler @@ -68,8 +69,10 @@ public class MountSheep extends HorseMount if (event.getType() != UpdateType.TICK) return; - for (Horse horse : GetActive().values()) + for (SingleEntityMountData horseData : GetActive().values()) { + Horse horse = horseData.getEntity(); + DisguiseBase base = Manager.getDisguiseManager().getDisguise(horse); if (base == null || !(base instanceof DisguiseSheep)) continue; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSlime.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSlime.java index 1dccbdad5..2a0b3831a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSlime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSlime.java @@ -9,6 +9,7 @@ import org.bukkit.entity.Slime; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.util.Vector; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -18,11 +19,12 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.mount.Mount; import mineplex.core.mount.MountManager; +import mineplex.core.mount.SingleEntityMountData; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -public class MountSlime extends Mount +public class MountSlime extends Mount> { public MountSlime(MountManager manager) { @@ -44,10 +46,10 @@ public class MountSlime extends Mount //Remove other mounts Manager.DeregisterAll(player); - Slime mount = player.getWorld().spawn(player.getLocation(), Slime.class); - mount.setSize(2); + SingleEntityMountData mount = new SingleEntityMountData(player, player.getWorld().spawn(player.getLocation(), Slime.class)); + mount.getEntity().setSize(2); - mount.setCustomName(player.getName() + "'s " + GetName()); + mount.getEntity().setCustomName(player.getName() + "'s " + GetName()); //Inform UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); @@ -58,7 +60,7 @@ public class MountSlime extends Mount public void Disable(Player player) { - Slime mount = _active.remove(player); + SingleEntityMountData mount = _active.remove(player); if (mount != null) { mount.remove(); @@ -79,11 +81,8 @@ public class MountSlime extends Mount if (!GetActive().containsKey(event.getPlayer())) return; - if (!GetActive().get(event.getPlayer()).equals(event.getRightClicked())) - { - UtilPlayer.message(event.getPlayer(), F.main("Mount", "This is not your Mount!")); + if(!GetActive().get(event.getPlayer()).ownsMount(event.getPlayer())) return; - } event.getPlayer().leaveVehicle(); event.getPlayer().eject(); @@ -108,10 +107,15 @@ public class MountSlime extends Mount return; //Bounce - for (Slime slime : GetActive().values()) + for (SingleEntityMountData slimeData : GetActive().values()) { + Slime slime = slimeData.getEntity(); + if (slime.getPassenger() == null) + { + UtilEnt.setFakeHead(slime, false); continue; + } if (!UtilEnt.isGrounded(slime)) continue; @@ -124,14 +128,19 @@ public class MountSlime extends Mount if (!Recharge.Instance.use(player, GetName(), 200, false, false)) continue; - UtilAction.velocity(slime, slime.getPassenger().getLocation().getDirection(), 1, true, 0, 0.4, 1, true); + Vector dir = slime.getPassenger().getLocation().getDirection(); + + UtilAction.velocity(slime, dir, 1, true, 0, 0.4, 1, true); + + UtilEnt.CreatureForceLook(slime, 0, UtilAlg.GetYaw(dir)); slime.getWorld().playSound(slime.getLocation(), Sound.SLIME_WALK, 1f, 0.75f); } //Collide - for (Slime slime : GetActive().values()) + for (SingleEntityMountData slimeData : GetActive().values()) { + Slime slime = slimeData.getEntity(); if (slime.getPassenger() == null) continue; @@ -143,8 +152,10 @@ public class MountSlime extends Mount if (!Recharge.Instance.usable(player, GetName() + " Collide")) continue; - for (Slime other : GetActive().values()) + for (SingleEntityMountData otherSlime : GetActive().values()) { + Slime other = otherSlime.getEntity(); + if (other.equals(slime)) continue; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSpider.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSpider.java index 3667a10d1..57ca4045b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSpider.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSpider.java @@ -4,21 +4,6 @@ import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Map.Entry; -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.disguise.disguises.DisguiseSpider; -import mineplex.core.mount.HorseMount; -import mineplex.core.mount.MountManager; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import net.minecraft.server.v1_8_R3.EntityLiving; - import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; @@ -32,6 +17,22 @@ import org.bukkit.event.EventHandler; 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.disguise.disguises.DisguiseSpider; +import mineplex.core.mount.HorseMount; +import mineplex.core.mount.MountManager; +import mineplex.core.mount.SingleEntityMountData; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import net.minecraft.server.v1_8_R3.EntityLiving; + public class MountSpider extends HorseMount { /** @@ -87,7 +88,8 @@ public class MountSpider extends HorseMount UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); //Store - _active.put(player, horse); + SingleEntityMountData mount = new SingleEntityMountData(player, horse); + _active.put(player, mount); DisguiseSpider spider = new DisguiseSpider(horse); spider.setName(player.getName() + "'s Spider Mount"); @@ -105,7 +107,7 @@ public class MountSpider extends HorseMount ArrayList used = new ArrayList(); for (Player player : GetActive().keySet()) { - Horse horse = GetActive().get(player); + Horse horse = GetActive().get(player).getEntity(); used.add(horse); @@ -126,21 +128,24 @@ public class MountSpider extends HorseMount if (event.getType() != UpdateType.TICK) return; - for (Entry horse : GetActive().entrySet()) + for (Entry> entry : GetActive().entrySet()) { - if (horse.getValue().getPassenger() != horse.getKey()) + Player player = entry.getKey(); + Horse horse = entry.getValue().getEntity(); + + if (horse.getPassenger() != player) continue; //If player is looking up - if (horse.getKey().getEyeLocation().getPitch() > -45) + if (player.getEyeLocation().getPitch() > -45) continue; - for (Block block : UtilBlock.getSurrounding(horse.getValue().getLocation().getBlock(), true)) + for (Block block : UtilBlock.getSurrounding(horse.getLocation().getBlock(), true)) { if (UtilBlock.airFoliage(block) || block.isLiquid()) continue; - UtilAction.velocity(horse.getValue(), new Vector(horse.getValue().getVelocity().getX(), 0.2, horse.getValue().getVelocity().getZ())); + UtilAction.velocity(horse, new Vector(horse.getVelocity().getX(), 0.2, horse.getVelocity().getZ())); continue; } } @@ -191,7 +196,7 @@ public class MountSpider extends HorseMount for (Player player : GetActive().keySet()) { - final Horse horse = GetActive().get(player); + final Horse horse = GetActive().get(player).getEntity(); if (horse.getPassenger() != player) continue; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java index e68aaea6a..4001f5184 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java @@ -84,7 +84,7 @@ public class MountTitan extends Mount for(MountTitanData mount : GetActive().values()) { - if(mount.ownsEntity(event.getRightClicked())) + if(mount.isPartOfMount(event.getRightClicked())) { event.setCancelled(true); if(event.getRightClicked().getType() == EntityType.ARMOR_STAND) return; @@ -124,7 +124,7 @@ public class MountTitan extends Mount { for (MountTitanData data : _active.values()) { - if (data.ownsEntity(event.getEntity())) + if (data.isPartOfMount(event.getEntity())) event.setCancelled(true); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java index 249743e70..137ae9bbe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java @@ -3,6 +3,7 @@ package mineplex.core.mount.types; import java.util.ArrayList; +import java.util.List; import org.bukkit.Location; import org.bukkit.Material; @@ -18,10 +19,10 @@ import org.bukkit.util.Vector; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; +import mineplex.core.mount.MountData; -public class MountTitanData +public class MountTitanData extends MountData { - private String _owner; private Slime _head; @@ -29,7 +30,7 @@ public class MountTitanData public MountTitanData(Player player, String name) { - _owner = player.getName(); + super(player); Location loc = player.getLocation(); loc.setPitch(0); @@ -136,14 +137,13 @@ public class MountTitanData for (ArmorStand stand : _nodes) stand.remove(); } - - public boolean ownsMount(Player player) - { - return _owner.equals(player.getName()); - } - public boolean ownsEntity(Entity ent) + @Override + public List getEntityParts() { - return (_head.equals(ent) || _nodes.contains(ent)); + List entities = new ArrayList(); + entities.addAll(_nodes); + entities.add(_head); + return entities; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountUndead.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountUndead.java index ebe2216c5..3bf4bb80e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountUndead.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountUndead.java @@ -1,15 +1,5 @@ package mineplex.core.mount.types; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilServer; -import mineplex.core.mount.HorseMount; -import mineplex.core.mount.MountManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - import org.bukkit.Material; import org.bukkit.entity.Horse; import org.bukkit.entity.Horse.Color; @@ -17,6 +7,16 @@ import org.bukkit.entity.Horse.Style; import org.bukkit.entity.Horse.Variant; import org.bukkit.event.EventHandler; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.mount.HorseMount; +import mineplex.core.mount.MountManager; +import mineplex.core.mount.SingleEntityMountData; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + public class MountUndead extends HorseMount { public MountUndead(MountManager manager) @@ -37,16 +37,20 @@ public class MountUndead extends HorseMount public void Trail(UpdateEvent event) { if (event.getType() == UpdateType.TICK) - for (Horse horse : GetActive().values()) - UtilParticle.PlayParticle(ParticleType.FLAME, horse.getLocation().add(0, 1, 0), - 0.25f, 0.25f, 0.25f, 0, 2, - ViewDist.NORMAL, UtilServer.getPlayers()); + for (SingleEntityMountData horseData : GetActive().values()) + { + Horse horse = horseData.getEntity(); + UtilParticle.PlayParticleToAll(ParticleType.FLAME, horse.getLocation().add(0, 1, 0), + 0.25f, 0.25f, 0.25f, 0, 2,ViewDist.NORMAL); + } if (event.getType() == UpdateType.FAST) - for (Horse horse : GetActive().values()) - UtilParticle.PlayParticle(ParticleType.LAVA, horse.getLocation().add(0, 1, 0), - 0.25f, 0.25f, 0.25f, 0, 1, - ViewDist.NORMAL, UtilServer.getPlayers()); + for (SingleEntityMountData horseData : GetActive().values()) + { + Horse horse = horseData.getEntity(); + UtilParticle.PlayParticleToAll(ParticleType.LAVA, horse.getLocation().add(0, 1, 0), + 0.25f, 0.25f, 0.25f, 0, 1, ViewDist.NORMAL); + } } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java index 094c43bec..bf5b654ea 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java @@ -14,7 +14,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Wither; import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.util.Vector; @@ -24,9 +24,9 @@ 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.UtilEvent.ActionType; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.event.StackerEvent; import mineplex.core.gadget.gadgets.MorphBlock; import mineplex.core.gadget.types.GadgetType; @@ -54,7 +54,7 @@ public class StackerManager extends MiniPlugin implements IThrown } @EventHandler - public void GrabEntity(PlayerInteractEntityEvent event) + public void GrabEntity(PlayerInteractAtEntityEvent event) { if (event.isCancelled()) return; @@ -62,7 +62,10 @@ public class StackerManager extends MiniPlugin implements IThrown Entity stackee = event.getRightClicked(); if (stackee == null) return; - + + if(Manager.GetMount().isMount(stackee)) + return; + if (!(stackee instanceof LivingEntity)) return;