Shimmering Ring kit selector
This commit is contained in:
parent
89f47d4c6c
commit
1b686a1446
@ -119,6 +119,7 @@ import mineplex.core.gadget.gadgets.item.ItemTNT;
|
||||
import mineplex.core.gadget.gadgets.kitselector.HaloKitSelector;
|
||||
import mineplex.core.gadget.gadgets.kitselector.RainCloudKitSelector;
|
||||
import mineplex.core.gadget.gadgets.kitselector.RainbowDanceKitSelector;
|
||||
import mineplex.core.gadget.gadgets.kitselector.ShimmeringRingKitSelector;
|
||||
import mineplex.core.gadget.gadgets.kitselector.SingleParticleKitSelector;
|
||||
import mineplex.core.gadget.gadgets.kitselector.WaterWingsKitSelector;
|
||||
import mineplex.core.gadget.gadgets.morph.MorphAwkwardRabbit;
|
||||
@ -606,6 +607,7 @@ public class GadgetManager extends MiniPlugin
|
||||
addGadget(new HaloKitSelector(this));
|
||||
addGadget(new RainbowDanceKitSelector(this));
|
||||
addGadget(new RainCloudKitSelector(this));
|
||||
addGadget(new ShimmeringRingKitSelector(this));
|
||||
|
||||
for(SingleParticleKitSelector.SingleParticleSelectors singleParticleSelectors : SingleParticleKitSelector.SingleParticleSelectors.values())
|
||||
{
|
||||
|
@ -0,0 +1,91 @@
|
||||
package mineplex.core.gadget.gadgets.kitselector;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
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 ShimmeringRingKitSelector extends KitSelectorGadget
|
||||
{
|
||||
|
||||
private static final int PARTICLES_PER_CIRCLE = 20;
|
||||
|
||||
private Map<Player, Entity> _selectedEntity = new HashMap<>();
|
||||
private Map<Entity, Double> _circleHeight = new HashMap<>();
|
||||
private Map<Entity, Boolean> _direction = new HashMap<>();
|
||||
|
||||
public ShimmeringRingKitSelector(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Shimmering Ring", 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);
|
||||
if (_selectedEntity.containsKey(player))
|
||||
{
|
||||
Entity selected = _selectedEntity.get(player);
|
||||
_circleHeight.remove(selected);
|
||||
_direction.remove(selected);
|
||||
_selectedEntity.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playParticle(Entity entity, Player playTo)
|
||||
{
|
||||
if (_selectedEntity.containsKey(playTo))
|
||||
{
|
||||
Entity selected = _selectedEntity.get(playTo);
|
||||
if (!selected.equals(entity))
|
||||
{
|
||||
_selectedEntity.remove(playTo);
|
||||
_circleHeight.remove(selected);
|
||||
_direction.remove(selected);
|
||||
_selectedEntity.put(playTo, entity);
|
||||
_circleHeight.put(entity, 0.0);
|
||||
_direction.put(entity, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Updates height and direction of particles
|
||||
double height = _circleHeight.get(entity);
|
||||
boolean up = (height == 0) || ((height == getEntityHeight(entity)) ? false : _direction.get(entity));
|
||||
_direction.put(entity, up);
|
||||
if (up)
|
||||
height += 0.1;
|
||||
else
|
||||
height -= 0.1;
|
||||
_circleHeight.put(entity, height);
|
||||
|
||||
for (int i = 0; i < PARTICLES_PER_CIRCLE; i++)
|
||||
{
|
||||
Location location = entity.getLocation().add(0, height, 0);
|
||||
double increment = (2 * Math.PI) / PARTICLES_PER_CIRCLE;
|
||||
double angle = i * increment;
|
||||
Vector vector = new Vector(Math.cos(angle), 0, Math.sin(angle));
|
||||
UtilParticle.playParticleFor(playTo, UtilParticle.ParticleType.FLAME, location.add(vector), 0, 0, 0, 0, 1, UtilParticle.ViewDist.NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
private double getEntityHeight(Entity entity)
|
||||
{
|
||||
net.minecraft.server.v1_8_R3.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||
return nmsEntity.getBoundingBox().e - nmsEntity.getBoundingBox().b;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user