From 08716634986e00954187d63491cb0757a8099bc3 Mon Sep 17 00:00:00 2001 From: Cheese Date: Sat, 28 Nov 2015 15:57:07 +1100 Subject: [PATCH] titan stuff I HATE YOU SNAKE. --- .../mineplex/core/common/util/UtilAlg.java | 7 +- .../core/gadget/gadgets/MorphTitan.java | 12 +-- .../mineplex/core/mount/types/MountTitan.java | 21 +++++- .../core/mount/types/MountTitanData.java | 73 +++++++++++++------ .../src/mineplex/core/pet/PetManager.java | 4 +- 5 files changed, 83 insertions(+), 34 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java index 71916c921..4085e074e 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java @@ -443,6 +443,11 @@ public class UtilAlg public static EulerAngle vectorToEuler(Vector vector) { - return new EulerAngle(Math.toRadians(GetPitch(vector)), Math.toRadians(GetYaw(vector)), 0); + //JUST MAKE SURE THE ARMOR STAND ISNT ROTATED. + + return new EulerAngle( + Math.toRadians(UtilAlg.GetPitch(vector)), + Math.toRadians(UtilAlg.GetYaw(vector)), + 0); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphTitan.java index eb50cc32e..a4554c372 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphTitan.java @@ -46,7 +46,9 @@ public class MorphTitan extends MorphGadget { super(manager, "Elder Guardian Morph", new String[] { - C.cWhite + "From deep withinsdngsg", + C.cWhite + "From the depths of the sea, the", + C.cWhite + "Elder Guardian posseses powers", + C.cWhite + "more amazing than any seen before!", " ", C.cRed + "Unlocked with Titan Rank", }, @@ -208,9 +210,9 @@ public class MorphTitan extends MorphGadget @EventHandler public void titanOwner(PlayerJoinEvent event) { -// if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) -// { -// Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName()); -// } + if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) + { + Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName()); + } } } 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 4c95237c6..e3fb011bc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java @@ -10,7 +10,10 @@ 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.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerJoinEvent; @@ -115,12 +118,22 @@ public class MountTitan extends Mount event.setCancelled(true); } + @EventHandler(priority = EventPriority.LOWEST) + public void target(EntityDamageEvent event) + { + for (MountTitanData data : _active.values()) + { + if (data.ownsEntity(event.getEntity())) + event.setCancelled(true); + } + } + @EventHandler public void titanOwner(PlayerJoinEvent event) { -// if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) -// { -// Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName()); -// } + if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) + { + Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName()); + } } } 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 7f73ac764..a5bffc410 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java @@ -5,7 +5,9 @@ package mineplex.core.mount.types; import java.util.ArrayList; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; import org.bukkit.Location; import org.bukkit.Material; @@ -15,6 +17,7 @@ import org.bukkit.entity.MagmaCube; import org.bukkit.entity.Player; import org.bukkit.entity.Slime; import org.bukkit.inventory.ItemStack; +import org.bukkit.util.EulerAngle; import org.bukkit.util.Vector; public class MountTitanData @@ -22,32 +25,40 @@ public class MountTitanData private String _owner; private Slime _head; - + private ArrayList _nodes; public MountTitanData(Player player, String name) { _owner = player.getName(); + Location loc = player.getLocation(); + loc.setPitch(0); + loc.setYaw(0); + //Nodes _nodes = new ArrayList(); for (int i=0 ; i<30 ; i++) { - ArmorStand node = player.getWorld().spawn(player.getLocation(), ArmorStand.class); + ArmorStand node = loc.getWorld().spawn(loc, ArmorStand.class); node.setVisible(false); node.setGravity(false); + node.setGhost(true); - node.setHelmet(new ItemStack(Material.REDSTONE_BLOCK)); - + node.setHelmet(new ItemStack(Material.NETHERRACK)); + + UtilEnt.setFakeHead(node, true); + _nodes.add(node); } - + //Head - _head = player.getWorld().spawn(player.getLocation(), MagmaCube.class); + _head = player.getWorld().spawn(loc, MagmaCube.class); _head.setSize(2); - + UtilEnt.ghost(_head, true, false); + _head.setCustomName(player.getName() + "'s " + name); } @@ -58,10 +69,10 @@ public class MountTitanData } public void update() - { + { //Head if (_head.getPassenger() != null) - _head.setVelocity(_head.getPassenger().getLocation().getDirection().add(new Vector(0,0.2,0))); + _head.setVelocity(_head.getPassenger().getLocation().getDirection().multiply(0.5).add(new Vector(0,0.2,0))); Location infront = _head.getLocation().add(0, -1.5, 0); @@ -70,42 +81,55 @@ public class MountTitanData { ArmorStand node = _nodes.get(i); + Location old = node.getLocation(); + + infront.setPitch(node.getLocation().getPitch()); + infront.setYaw(node.getLocation().getYaw()); + //Move if (i == 0) node.teleport(infront); - else if (UtilMath.offset(node.getLocation(), infront) > 0.5) - node.teleport(infront.add(UtilAlg.getTrajectory(infront, node.getLocation()).multiply(0.5))); + else if (UtilMath.offset(node.getLocation(), infront) > 0.6) + node.teleport(infront.add(UtilAlg.getTrajectory(infront, node.getLocation()).multiply(0.6))); + + //Rotation + Vector vector = UtilAlg.getTrajectory(old, node.getLocation()); + + node.setHeadPose(new EulerAngle( + Math.toRadians(UtilAlg.GetPitch(vector)), + Math.toRadians(UtilAlg.GetYaw(vector)), + 0)); infront = node.getLocation(); - - //Rotation - node.setHeadPose(UtilAlg.vectorToEuler(UtilAlg.getTrajectory(infront, node.getLocation()))); } - - + + //Shuffle In - if (_head.getPassenger() == null) + if (_head.getPassenger() == null) { for (int i=_nodes.size()-1 ; i>=0 ; i--) { ArmorStand node = _nodes.get(i); - + if (i>0) - infront = _nodes.get(i-1).getLocation(); + infront = _nodes.get(i-1).getLocation(); else infront = _head.getLocation().add(0, -1.5, 0); + infront.setPitch(node.getLocation().getPitch()); + infront.setYaw(node.getLocation().getYaw()); + node.teleport(infront); } } } - - + + public void clean() { _head.remove(); - + for (ArmorStand stand : _nodes) stand.remove(); } @@ -114,4 +138,9 @@ public class MountTitanData { return _owner.equals(player.getName()); } + + public boolean ownsEntity(Entity ent) + { + return (_head.equals(ent) || _nodes.contains(ent)); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java index 572919566..d111bc6a7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java @@ -167,8 +167,8 @@ public class PetManager extends MiniClientPlugin if (rank.has(Rank.TITAN)) { -// if (!Get(p).GetPets().containsKey(EntityType.SKELETON)) -// Get(p).GetPets().put(EntityType.SKELETON, "Guardian"); + if (!Get(p).GetPets().containsKey(EntityType.SKELETON)) + Get(p).GetPets().put(EntityType.SKELETON, "Guardian"); } }