From 1000c190a2741e3996f95e9b25e55f335f4b7784 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Fri, 28 Apr 2017 00:32:29 -0300 Subject: [PATCH] Fixed Y offset for Water Wings and added Flames of Fury and Halo effects --- .../mineplex/core/gadget/GadgetManager.java | 4 + .../kitselector/FlamesOfFuryKitSelector.java | 29 +++++ .../gadgets/kitselector/HaloKitSelector.java | 102 ++++++++++++++++++ .../kitselector/WaterWingsKitSelector.java | 34 +++++- 4 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/FlamesOfFuryKitSelector.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 543925495..b4fe90c99 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -116,6 +116,8 @@ import mineplex.core.gadget.gadgets.item.ItemPaintbrush; import mineplex.core.gadget.gadgets.item.ItemPartyPopper; import mineplex.core.gadget.gadgets.item.ItemSnowball; import mineplex.core.gadget.gadgets.item.ItemTNT; +import mineplex.core.gadget.gadgets.kitselector.FlamesOfFuryKitSelector; +import mineplex.core.gadget.gadgets.kitselector.HaloKitSelector; import mineplex.core.gadget.gadgets.kitselector.WaterWingsKitSelector; import mineplex.core.gadget.gadgets.morph.MorphAwkwardRabbit; import mineplex.core.gadget.gadgets.morph.MorphBat; @@ -599,6 +601,8 @@ public class GadgetManager extends MiniPlugin // Kit Selectors addGadget(new WaterWingsKitSelector(this)); + addGadget(new FlamesOfFuryKitSelector(this)); + addGadget(new HaloKitSelector(this)); // Gem Hunters Mounts for (MountType mount : MountType.values()) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/FlamesOfFuryKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/FlamesOfFuryKitSelector.java new file mode 100644 index 000000000..c01297abb --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/FlamesOfFuryKitSelector.java @@ -0,0 +1,29 @@ +package mineplex.core.gadget.gadgets.kitselector; + +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.KitSelectorGadget; + +public class FlamesOfFuryKitSelector extends KitSelectorGadget +{ + + public FlamesOfFuryKitSelector(GadgetManager manager) + { + super(manager, "Flames Of Fury", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), + 0, Material.GLASS, (byte) 0); + } + + @Override + public void playParticle(Entity entity, Player playTo) + { + UtilParticle.playParticleFor(playTo, UtilParticle.ParticleType.FLAME, entity.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 1, UtilParticle.ViewDist.NORMAL); + } + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java new file mode 100644 index 000000000..4fd7fe89e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java @@ -0,0 +1,102 @@ +package mineplex.core.gadget.gadgets.kitselector; + +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilColor; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.KitSelectorGadget; +import mineplex.core.particleeffects.ColoredCircleEffect; + +public class HaloKitSelector extends KitSelectorGadget +{ + + private Map _circleEffects = new HashMap<>(); + private Map _selectedEntity = new HashMap<>(); + + public HaloKitSelector(GadgetManager manager) + { + super(manager, "Halo", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), + 0, Material.GLASS, (byte) 0); + } + + @Override + public void disableCustom(Player player, boolean message) + { + super.disableCustom(player, message); + stopEffect(player); + } + + @Override + public void playParticle(Entity entity, Player playTo) + { + if (_circleEffects.containsKey(entity)) + return; + + if (_selectedEntity.containsValue(playTo)) + { + stopEffect(playTo); + } + + ColoredCircleEffect coloredCircleEffect = new ColoredCircleEffect(Manager.getPlugin(), entity, 0.6, false); + coloredCircleEffect.addColors(UtilColor.hexToRgb(0xffd700), UtilColor.hexToRgb(0xdaa520)); + coloredCircleEffect.setYOffset(getEntityYOffset(entity)); + coloredCircleEffect.start(); + + _selectedEntity.put(playTo, entity); + _circleEffects.put(entity, coloredCircleEffect); + } + + private void stopEffect(Player player) + { + if (_selectedEntity.containsKey(player)) + { + Entity entity = _selectedEntity.get(player); + if (_circleEffects.containsKey(entity)) + { + _circleEffects.get(entity).stop(); + _circleEffects.remove(entity); + } + _selectedEntity.remove(player); + } + } + + /** + * Gets the right Y offset for that entity based on the type + * @param entity The entity + * @return The correct Y offset + */ + public double getEntityYOffset(Entity entity) + { + EntityType entityType = entity.getType(); + switch (entityType) + { + case SHEEP: + case PIG: + case BAT: + case MAGMA_CUBE: + case GUARDIAN: + case CHICKEN: + case SLIME: + case SQUID: + case WOLF: + case OCELOT: + return 1.3; + case SPIDER: + case CAVE_SPIDER: + return 0.75; + case ENDERMAN: + return 3.3; + } + return 2.3; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/WaterWingsKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/WaterWingsKitSelector.java index 471aa5b2a..a7a68a856 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/WaterWingsKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/WaterWingsKitSelector.java @@ -3,6 +3,7 @@ package mineplex.core.gadget.gadgets.kitselector; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.util.Vector; @@ -29,9 +30,40 @@ public class WaterWingsKitSelector extends KitSelectorGadget @Override public void playParticle(Entity entity, Player playTo) { - Location loc = entity.getLocation().add(0, 1.2, 0).add(entity.getLocation().getDirection().multiply(-0.2)); + double offsetY = getEntityYOffset(entity); + Location loc = entity.getLocation().add(0, offsetY, 0).add(entity.getLocation().getDirection().multiply(-0.2)); _wings.display(loc, playTo); _wingsEdge.display(loc, playTo); } + /** + * Gets the right Y offset for that entity based on the type + * @param entity The entity + * @return The correct Y offset + */ + public double getEntityYOffset(Entity entity) + { + EntityType entityType = entity.getType(); + switch (entityType) + { + case SHEEP: + case PIG: + case BAT: + case MAGMA_CUBE: + case GUARDIAN: + case CHICKEN: + case SLIME: + case SQUID: + case WOLF: + case OCELOT: + return 0.75; + case SPIDER: + case CAVE_SPIDER: + return 0.25; + case ENDERMAN: + return 1.5; + } + return 1.2; + } + }