Added spring halo particle

This commit is contained in:
LCastr0 2017-03-17 19:39:41 -03:00
parent b464cab213
commit 92f5214c91
4 changed files with 90 additions and 3 deletions

View File

@ -164,6 +164,7 @@ import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes;
import mineplex.core.gadget.gadgets.particle.ParticleFairy;
import mineplex.core.gadget.gadgets.particle.ParticleFireRings;
import mineplex.core.gadget.gadgets.particle.ParticleLegend;
import mineplex.core.gadget.gadgets.particle.ParticleSpringHalo;
import mineplex.core.gadget.gadgets.particle.ParticleWingsAngel;
import mineplex.core.gadget.gadgets.particle.ParticleWingsDemons;
import mineplex.core.gadget.gadgets.particle.ParticleWingsInfernal;
@ -447,6 +448,7 @@ public class GadgetManager extends MiniPlugin
addGadget(new ParticleFreedom(this));
addGadget(new ParticleChristmasTree(this));
addGadget(new ParticleWingsLove(this));
addGadget(new ParticleSpringHalo(this));
// Arrow Trails
addGadget(new ArrowTrailFrostLord(this));

View File

@ -0,0 +1,63 @@
package mineplex.core.gadget.gadgets.particle;
import java.awt.Color;
import java.time.Month;
import java.time.YearMonth;
import java.util.HashMap;
import java.util.Map;
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.ParticleGadget;
import mineplex.core.particleeffects.CircleEffect;
import mineplex.core.updater.event.UpdateEvent;
public class ParticleSpringHalo extends ParticleGadget
{
private Map<Player, CircleEffect> _effects = new HashMap<>();
public ParticleSpringHalo(GadgetManager manager)
{
// TODO CHANGE LORE BEFORE RELEASE
super(manager, "Spring Halo", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), -14, Material.GLASS, (byte) 0, YearMonth.of(2017, Month.APRIL));
}
@Override
public void enableCustom(Player player, boolean message)
{
super.enableCustom(player, message);
CircleEffect circleEffect = new CircleEffect(Manager.getPlugin(), player, 0.7d, Color.RED, false);
circleEffect.addRandomColor(Color.YELLOW);
circleEffect.addRandomColor(Color.BLUE);
circleEffect.addRandomColor(Color.GREEN);
circleEffect.setYOffset(2.3d);
circleEffect.start();
_effects.put(player, circleEffect);
}
@Override
public void disableCustom(Player player, boolean message)
{
super.disableCustom(player, message);
if (_effects.containsKey(player))
{
CircleEffect circleEffect = _effects.get(player);
if (circleEffect != null)
{
circleEffect.stop();
}
}
_effects.remove(player);
}
@Override
public void playParticle(Player player, UpdateEvent event)
{}
}

View File

@ -1,5 +1,7 @@
package mineplex.core.gadget.types;
import java.time.YearMonth;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -28,7 +30,12 @@ public abstract class ParticleGadget extends Gadget
public ParticleGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, String...altNames)
{
super(manager, GadgetType.PARTICLE, name, desc, cost, mat, data, 1, altNames);
}
}
public ParticleGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, YearMonth yearMonth, String... altNames)
{
super(manager, GadgetType.PARTICLE, name, desc, cost, mat, data, yearMonth, 1, altNames);
}
@Override
public void enableCustom(Player player, boolean message)

View File

@ -5,6 +5,7 @@ import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
@ -23,6 +24,7 @@ public class CircleEffect extends Effect
private List<Color> _randomColors = new ArrayList<>();
private int _maxCircles = -1;
private int _totalCircles = 0;
private double _yOffset = 0.0;
private static final double RANDOM_COLOR_CHANCE = 0.5;
private static final int PARTICLES_PER_CIRCLE = 20;
@ -40,6 +42,14 @@ public class CircleEffect extends Effect
_instantly = instantly;
}
public CircleEffect(JavaPlugin plugin, Entity entity, double radius, Color color, boolean instantly)
{
super(-1, new EffectLocation(entity), plugin);
_radius = radius;
_color = color;
_instantly = instantly;
}
public void addRandomColor(Color color)
{
_randomColors.add(color);
@ -50,6 +60,11 @@ public class CircleEffect extends Effect
_maxCircles = circles;
}
public void setYOffset(double yOffset)
{
_yOffset = yOffset;
}
@Override
public void runEffect()
{
@ -57,7 +72,7 @@ public class CircleEffect extends Effect
{
for (int i = 0; i < PARTICLES_PER_CIRCLE; i++)
{
Location location = getEffectLocation().getFixedLocation();
Location location = getEffectLocation().getLocation().add(0, _yOffset, 0);
double increment = (2 * Math.PI) / PARTICLES_PER_CIRCLE;
double angle = _steps * increment;
Vector vector = new Vector(Math.cos(angle) * _radius, 0, Math.sin(angle) * _radius);
@ -86,7 +101,7 @@ public class CircleEffect extends Effect
return;
}
}
Location location = getEffectLocation().getFixedLocation();
Location location = getEffectLocation().getLocation().add(0, _yOffset, 0);
double increment = (2 * Math.PI) / PARTICLES_PER_CIRCLE;
double angle = _steps * increment;
Vector vector = new Vector(Math.cos(angle) * _radius, 0, Math.sin(angle) * _radius);