Rainbow taunt

This commit is contained in:
LCastr0 2017-02-24 22:06:18 -03:00
parent a32cb6ab2f
commit b2fd8ac748
3 changed files with 126 additions and 1 deletions

View File

@ -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)
{
}
}

View File

@ -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;
}
}
}
}

View File

@ -21,7 +21,6 @@ public class RainbowTrailEffect extends Effect
private HashSet<Item> _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<Item> items)
{
super(-1, new EffectLocation(entity), javaPlugin);