Fixed kit selectors
This commit is contained in:
parent
bcd60d325b
commit
9018a3cc50
@ -1,17 +1,27 @@
|
||||
package mineplex.core.gadget.gadgets.kitselector;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
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.RGBData;
|
||||
import mineplex.core.common.util.UtilColor;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.common.util.particles.ColoredParticle;
|
||||
import mineplex.core.common.util.particles.DustSpellColor;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.types.KitSelectorGadget;
|
||||
import mineplex.core.particleeffects.ColoredCircleEffect;
|
||||
@ -22,10 +32,17 @@ public class HaloKitSelector extends KitSelectorGadget
|
||||
private Map<Entity, ColoredCircleEffect> _circleEffects = new HashMap<>();
|
||||
private Map<Player, Entity> _selectedEntity = new HashMap<>();
|
||||
|
||||
private static final int PARTICLES_PER_CIRCLE = 20;
|
||||
private static final double RADIUS = 0.6;
|
||||
|
||||
private List<Color> _colors;
|
||||
private int _steps = 0;
|
||||
|
||||
public HaloKitSelector(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Halo", UtilText.splitLinesToArray(new String[]{C.cGray + "Fight like an Angel."}, LineFormat.LORE),
|
||||
0, Material.GOLD_HELMET, (byte) 0);
|
||||
_colors = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -38,7 +55,7 @@ public class HaloKitSelector extends KitSelectorGadget
|
||||
@Override
|
||||
public void playParticle(Entity entity, Player playTo)
|
||||
{
|
||||
if (_circleEffects.containsKey(entity))
|
||||
/*if (_circleEffects.containsKey(entity))
|
||||
return;
|
||||
|
||||
if (_selectedEntity.containsValue(playTo))
|
||||
@ -53,12 +70,28 @@ public class HaloKitSelector extends KitSelectorGadget
|
||||
coloredCircleEffect.start();
|
||||
|
||||
_selectedEntity.put(playTo, entity);
|
||||
_circleEffects.put(entity, coloredCircleEffect);
|
||||
_circleEffects.put(entity, coloredCircleEffect);*/
|
||||
|
||||
if (_colors.isEmpty())
|
||||
{
|
||||
RGBData rgbData = UtilColor.hexToRgb(0xffd700);
|
||||
_colors.add(new Color(rgbData.getFullRed(), rgbData.getFullGreen(), rgbData.getFullBlue()));
|
||||
rgbData = UtilColor.hexToRgb(0xdaa520);
|
||||
_colors.add(new Color(rgbData.getFullRed(), rgbData.getFullGreen(), rgbData.getFullBlue()));
|
||||
}
|
||||
|
||||
Location location = entity.getLocation().add(0, getEntityYOffset(entity), 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);
|
||||
ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(getNextColor()), location.add(vector));
|
||||
coloredParticle.display(UtilParticle.ViewDist.NORMAL, playTo);
|
||||
_steps++;
|
||||
}
|
||||
|
||||
private void stopEffect(Player player)
|
||||
{
|
||||
if (_selectedEntity.containsKey(player))
|
||||
/*if (_selectedEntity.containsKey(player))
|
||||
{
|
||||
Entity entity = _selectedEntity.get(player);
|
||||
if (_circleEffects.containsKey(entity))
|
||||
@ -67,7 +100,13 @@ public class HaloKitSelector extends KitSelectorGadget
|
||||
_circleEffects.remove(entity);
|
||||
}
|
||||
_selectedEntity.remove(player);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private Color getNextColor()
|
||||
{
|
||||
int r = UtilMath.random.nextInt(_colors.size());
|
||||
return _colors.get(r);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,8 +1,5 @@
|
||||
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.entity.Entity;
|
||||
@ -21,9 +18,8 @@ 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<>();
|
||||
private double _circleHeight = 0.0;
|
||||
private boolean _direction = true;
|
||||
|
||||
public ShimmeringRingKitSelector(GadgetManager manager)
|
||||
{
|
||||
@ -31,61 +27,27 @@ public class ShimmeringRingKitSelector extends KitSelectorGadget
|
||||
0, Material.WOOL, (byte) 4);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_selectedEntity.put(playTo, entity);
|
||||
_circleHeight.put(entity, 0.0);
|
||||
_direction.put(entity, true);
|
||||
}
|
||||
|
||||
// Updates height and direction of particles
|
||||
double height = _circleHeight.get(entity);
|
||||
if (height <= 0)
|
||||
if (_circleHeight <= 0)
|
||||
{
|
||||
_direction.put(entity, true);
|
||||
_direction = true;
|
||||
}
|
||||
else if (height >= getEntityHeight(entity))
|
||||
else if (_circleHeight >= getEntityHeight(entity))
|
||||
{
|
||||
_direction.put(entity, false);
|
||||
_direction = false;
|
||||
}
|
||||
if (_direction.get(entity))
|
||||
height += 0.2;
|
||||
if (_direction)
|
||||
_circleHeight += 0.2;
|
||||
else
|
||||
height -= 0.2;
|
||||
_circleHeight.put(entity, height);
|
||||
_circleHeight -= 0.2;
|
||||
|
||||
for (int i = 0; i < PARTICLES_PER_CIRCLE; i++)
|
||||
{
|
||||
Location location = entity.getLocation().add(0, height, 0);
|
||||
Location location = entity.getLocation().add(0, _circleHeight, 0);
|
||||
double increment = (2 * Math.PI) / PARTICLES_PER_CIRCLE;
|
||||
double angle = i * increment;
|
||||
Vector vector = new Vector(Math.cos(angle), 0, Math.sin(angle));
|
||||
|
Loading…
Reference in New Issue
Block a user