From b2fd8ac748ca45f591c46290ab5389385f970acf Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Fri, 24 Feb 2017 22:06:18 -0300 Subject: [PATCH] Rainbow taunt --- .../gadget/gadgets/taunts/RainbowTaunt.java | 48 ++++++++++++ .../particleeffects/RainbowTauntEffect.java | 76 +++++++++++++++++++ .../particleeffects/RainbowTrailEffect.java | 3 +- 3 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/particleeffects/RainbowTauntEffect.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java new file mode 100644 index 000000000..c506fd575 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java @@ -0,0 +1,48 @@ +package mineplex.core.gadget.gadgets.taunts; + +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.TauntGadget; +import mineplex.core.recharge.Recharge; + +public class RainbowTaunt extends TauntGadget +{ + + private static final int COOLDOWN = 30000; + private static final int PVP_COOLDOWN = 10000; + + public RainbowTaunt(GadgetManager manager) + { + super(manager, "Rainbow Taunt", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, + LineFormat.LORE), -18, Material.GLASS, (byte) 0); + setCanPlayWithPvp(false); + setPvpCooldown(PVP_COOLDOWN); + } + + @Override + public void onStart(Player player) + { + if (!Recharge.Instance.use(player, getName(), COOLDOWN, true, false, "Cosmetics")) + return; + + + } + + @Override + public void onPlay(Player player) + { + + } + + @Override + public void onFinish(Player player) + { + + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/RainbowTauntEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/RainbowTauntEffect.java new file mode 100644 index 000000000..8af6585b0 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/RainbowTauntEffect.java @@ -0,0 +1,76 @@ +package mineplex.core.particleeffects; + +import java.awt.Color; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; + +public class RainbowTauntEffect extends Effect +{ + + private static final int PARTICLES = 100; + private static final int HEIGHT = 5; + + private int _step = 0; + + private Color _red = new Color(255, 0, 0); + private Color _orange = new Color(255, 127, 0); + private Color _yellow = new Color(255, 255, 0); + private Color _green = new Color(0, 255, 0); + private Color _blue = new Color(0, 0, 255); + private Color _indigo = new Color(75, 0, 130); + private Color _violet = new Color(143, 0, 255); + + private Color _color = _red; + + public RainbowTauntEffect(Player player, JavaPlugin javaPlugin) + { + super(-1, new EffectLocation(player), javaPlugin); + } + + @Override + public void runEffect() + { + Location location = getEffectLocation().getLocation(); + Location target = getTargetLocation().getLocation(); + Vector link = target.toVector().subtract(location.toVector()); + float length = (float) link.length(); + float pitch = (float) (4 * HEIGHT / Math.pow(length, 2)); + for (int i = 0; i < PARTICLES; i++) { + Vector v = link.clone().normalize().multiply(length * i / PARTICLES); + float x = ((float) i / PARTICLES) * length - length / 2; + float y = (float) (-pitch * Math.pow(x, 2) + HEIGHT); + location.add(v).add(0, y, 0); + ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, + new DustSpellColor(_color), _effectLocation.getLocation().clone().add(0, .5, 0)); + coloredParticle.display(); + location.subtract(0, y, 0).subtract(v); + + _step++; + if (_step % 5 == 0) + { + if (_color.equals(_red)) + _color = _orange; + else if (_color.equals(_orange)) + _color = _yellow; + else if (_color.equals(_yellow)) + _color = _green; + else if (_color.equals(_green)) + _color = _blue; + else if (_color.equals(_blue)) + _color = _indigo; + else if (_color.equals(_indigo)) + _color = _violet; + else + _color = _red; + } + } + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/RainbowTrailEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/RainbowTrailEffect.java index f707165b7..04652f71e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/RainbowTrailEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/RainbowTrailEffect.java @@ -21,7 +21,6 @@ public class RainbowTrailEffect extends Effect private HashSet _items; - private Color _color = Color.RED; private long _count, _jumpingTimer = 0; private boolean _isJumping = false; private Entity _entity; @@ -34,6 +33,8 @@ public class RainbowTrailEffect extends Effect private Color _indigo = new Color(75, 0, 130); private Color _violet = new Color(143, 0, 255); + private Color _color = _red; + public RainbowTrailEffect(Entity entity, JavaPlugin javaPlugin, HashSet items) { super(-1, new EffectLocation(entity), javaPlugin);