Gryo Particle
This commit is contained in:
parent
20885bac4e
commit
8429d2f0d1
@ -5,7 +5,14 @@ import java.awt.Color;
|
|||||||
public class DustSpellColor extends ParticleColor
|
public class DustSpellColor extends ParticleColor
|
||||||
{
|
{
|
||||||
|
|
||||||
private int _red, _green, _blue;
|
private final int _red, _green, _blue;
|
||||||
|
|
||||||
|
public DustSpellColor(org.bukkit.Color color)
|
||||||
|
{
|
||||||
|
_red = color.getRed();
|
||||||
|
_green = color.getGreen();
|
||||||
|
_blue = color.getBlue();
|
||||||
|
}
|
||||||
|
|
||||||
public DustSpellColor(Color color)
|
public DustSpellColor(Color color)
|
||||||
{
|
{
|
||||||
|
@ -226,6 +226,7 @@ import mineplex.core.gadget.gadgets.particle.ParticleFairy;
|
|||||||
import mineplex.core.gadget.gadgets.particle.ParticleFireRings;
|
import mineplex.core.gadget.gadgets.particle.ParticleFireRings;
|
||||||
import mineplex.core.gadget.gadgets.particle.ParticleFoot;
|
import mineplex.core.gadget.gadgets.particle.ParticleFoot;
|
||||||
import mineplex.core.gadget.gadgets.particle.ParticleFrostLord;
|
import mineplex.core.gadget.gadgets.particle.ParticleFrostLord;
|
||||||
|
import mineplex.core.gadget.gadgets.particle.ParticleGryo;
|
||||||
import mineplex.core.gadget.gadgets.particle.ParticleHeart;
|
import mineplex.core.gadget.gadgets.particle.ParticleHeart;
|
||||||
import mineplex.core.gadget.gadgets.particle.ParticleLegend;
|
import mineplex.core.gadget.gadgets.particle.ParticleLegend;
|
||||||
import mineplex.core.gadget.gadgets.particle.ParticleMusic;
|
import mineplex.core.gadget.gadgets.particle.ParticleMusic;
|
||||||
@ -637,7 +638,7 @@ public class GadgetManager extends MiniPlugin
|
|||||||
addGadget(new ParticleCanadian(this));
|
addGadget(new ParticleCanadian(this));
|
||||||
|
|
||||||
addGadget(new ParticleHalloween(this));
|
addGadget(new ParticleHalloween(this));
|
||||||
|
addGadget(new ParticleGryo(this, _achievementManager));
|
||||||
|
|
||||||
// Arrow Trails
|
// Arrow Trails
|
||||||
addGadget(new ArrowTrailFrostLord(this));
|
addGadget(new ArrowTrailFrostLord(this));
|
||||||
|
@ -0,0 +1,149 @@
|
|||||||
|
package mineplex.core.gadget.gadgets.particle;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.bukkit.Color;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import mineplex.core.achievement.AchievementManager;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.UtilAlg;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||||
|
import mineplex.core.common.util.particles.ColoredParticle;
|
||||||
|
import mineplex.core.common.util.particles.DustSpellColor;
|
||||||
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
import mineplex.core.gadget.types.ParticleGadget;
|
||||||
|
import mineplex.core.gadget.util.CostConstants;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
|
public class ParticleGryo extends ParticleGadget
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final int RING_PER = 10;
|
||||||
|
private static final DustSpellColor[] COLOURS =
|
||||||
|
{
|
||||||
|
new DustSpellColor(Color.RED),
|
||||||
|
new DustSpellColor(Color.ORANGE),
|
||||||
|
new DustSpellColor(Color.YELLOW),
|
||||||
|
new DustSpellColor(Color.LIME),
|
||||||
|
new DustSpellColor(Color.GREEN),
|
||||||
|
new DustSpellColor(Color.AQUA),
|
||||||
|
new DustSpellColor(Color.TEAL),
|
||||||
|
new DustSpellColor(Color.BLUE),
|
||||||
|
new DustSpellColor(Color.FUCHSIA),
|
||||||
|
new DustSpellColor(Color.PURPLE),
|
||||||
|
};
|
||||||
|
private static final double STARTING_RADIUS = 0.7;
|
||||||
|
private static final double SEPARATING_RADIUS = 0.1;
|
||||||
|
private static final double MAX_THETA = 2 * Math.PI;
|
||||||
|
private static final double DELTA_VECTOR = Math.PI / 10;
|
||||||
|
private static final double VECTOR_THETA = Math.PI / 200;
|
||||||
|
|
||||||
|
private final AchievementManager _achievementManager;
|
||||||
|
private final Map<Player, Integer> _rings;
|
||||||
|
|
||||||
|
private double _vectorTheta;
|
||||||
|
|
||||||
|
public ParticleGryo(GadgetManager manager, AchievementManager achievementManager)
|
||||||
|
{
|
||||||
|
super(manager, "Rainbow Aura", new String[]
|
||||||
|
{
|
||||||
|
C.cWhite + "+1 Ring per " + RING_PER + " Mineplex Levels",
|
||||||
|
C.blankLine,
|
||||||
|
C.cBlue + "Only purchasable during November 2017",
|
||||||
|
}, CostConstants.NO_LORE, Material.WOOL, (byte) (UtilMath.r(14) + 1));
|
||||||
|
|
||||||
|
_achievementManager = achievementManager;
|
||||||
|
_rings = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enableCustom(Player player, boolean message)
|
||||||
|
{
|
||||||
|
super.enableCustom(player, message);
|
||||||
|
|
||||||
|
int size = Math.min(RING_PER, 1 + _achievementManager.getMineplexLevelNumber(player) / RING_PER);
|
||||||
|
|
||||||
|
_rings.put(player, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disableCustom(Player player, boolean message)
|
||||||
|
{
|
||||||
|
super.disableCustom(player, message);
|
||||||
|
|
||||||
|
_rings.remove(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void playParticle(Player player, UpdateEvent event)
|
||||||
|
{
|
||||||
|
Location location = player.getLocation().add(0, 1, 0);
|
||||||
|
int rings = _rings.get(player);
|
||||||
|
|
||||||
|
if (Manager.isMoving(player))
|
||||||
|
{
|
||||||
|
for (int i = 0; i < rings; i++)
|
||||||
|
{
|
||||||
|
DustSpellColor colour = COLOURS[i];
|
||||||
|
double x = Math.random() - 0.5;
|
||||||
|
double y = Math.random() - 0.5;
|
||||||
|
double z = Math.random() - 0.5;
|
||||||
|
|
||||||
|
location.add(x, y, z);
|
||||||
|
|
||||||
|
new ColoredParticle(ParticleType.RED_DUST, colour, location)
|
||||||
|
.display();
|
||||||
|
|
||||||
|
location.subtract(x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < rings; i++)
|
||||||
|
{
|
||||||
|
DustSpellColor colour = COLOURS[i];
|
||||||
|
int j = i + 1;
|
||||||
|
double vectorTheta = _vectorTheta + DELTA_VECTOR * i;
|
||||||
|
double r = STARTING_RADIUS + SEPARATING_RADIUS * j;
|
||||||
|
double d = MAX_THETA / (7 * r);
|
||||||
|
|
||||||
|
for (double theta = 0; theta < MAX_THETA; theta += d)
|
||||||
|
{
|
||||||
|
double x = r * Math.cos(theta);
|
||||||
|
double z = r * Math.sin(theta);
|
||||||
|
Vector vector = new Vector(x, 0, z);
|
||||||
|
vector = UtilAlg.rotateAroundXAxis(vector, vectorTheta);
|
||||||
|
vector = UtilAlg.rotateAroundYAxis(vector, vectorTheta);
|
||||||
|
|
||||||
|
location.add(vector);
|
||||||
|
|
||||||
|
new ColoredParticle(ParticleType.RED_DUST, colour, location)
|
||||||
|
.display();
|
||||||
|
|
||||||
|
location.subtract(vector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@EventHandler
|
||||||
|
public void Caller(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.TICK)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.Caller(event);
|
||||||
|
_vectorTheta += VECTOR_THETA;
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,5 @@
|
|||||||
package mineplex.core.gadget.types;
|
package mineplex.core.gadget.types;
|
||||||
|
|
||||||
import java.time.YearMonth;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -52,15 +50,9 @@ public abstract class ParticleGadget extends Gadget
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldDisplay(Player player)
|
private boolean shouldDisplay(Player player)
|
||||||
{
|
{
|
||||||
if (UtilPlayer.isSpectator(player))
|
return !UtilPlayer.isSpectator(player) && !Manager.hideParticles();
|
||||||
return false;
|
|
||||||
|
|
||||||
if (Manager.hideParticles())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
Loading…
Reference in New Issue
Block a user