Fixed Y offset for Water Wings and added Flames of Fury and Halo effects

This commit is contained in:
LCastr0 2017-04-28 00:32:29 -03:00
parent 494fd4787c
commit 1000c190a2
4 changed files with 168 additions and 1 deletions

View File

@ -116,6 +116,8 @@ import mineplex.core.gadget.gadgets.item.ItemPaintbrush;
import mineplex.core.gadget.gadgets.item.ItemPartyPopper;
import mineplex.core.gadget.gadgets.item.ItemSnowball;
import mineplex.core.gadget.gadgets.item.ItemTNT;
import mineplex.core.gadget.gadgets.kitselector.FlamesOfFuryKitSelector;
import mineplex.core.gadget.gadgets.kitselector.HaloKitSelector;
import mineplex.core.gadget.gadgets.kitselector.WaterWingsKitSelector;
import mineplex.core.gadget.gadgets.morph.MorphAwkwardRabbit;
import mineplex.core.gadget.gadgets.morph.MorphBat;
@ -599,6 +601,8 @@ public class GadgetManager extends MiniPlugin
// Kit Selectors
addGadget(new WaterWingsKitSelector(this));
addGadget(new FlamesOfFuryKitSelector(this));
addGadget(new HaloKitSelector(this));
// Gem Hunters Mounts
for (MountType mount : MountType.values())

View File

@ -0,0 +1,29 @@
package mineplex.core.gadget.gadgets.kitselector;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
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 FlamesOfFuryKitSelector extends KitSelectorGadget
{
public FlamesOfFuryKitSelector(GadgetManager manager)
{
super(manager, "Flames Of Fury", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE),
0, Material.GLASS, (byte) 0);
}
@Override
public void playParticle(Entity entity, Player playTo)
{
UtilParticle.playParticleFor(playTo, UtilParticle.ParticleType.FLAME, entity.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 1, UtilParticle.ViewDist.NORMAL);
}
}

View File

@ -0,0 +1,102 @@
package mineplex.core.gadget.gadgets.kitselector;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilColor;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.KitSelectorGadget;
import mineplex.core.particleeffects.ColoredCircleEffect;
public class HaloKitSelector extends KitSelectorGadget
{
private Map<Entity, ColoredCircleEffect> _circleEffects = new HashMap<>();
private Map<Player, Entity> _selectedEntity = new HashMap<>();
public HaloKitSelector(GadgetManager manager)
{
super(manager, "Halo", 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);
stopEffect(player);
}
@Override
public void playParticle(Entity entity, Player playTo)
{
if (_circleEffects.containsKey(entity))
return;
if (_selectedEntity.containsValue(playTo))
{
stopEffect(playTo);
}
ColoredCircleEffect coloredCircleEffect = new ColoredCircleEffect(Manager.getPlugin(), entity, 0.6, false);
coloredCircleEffect.addColors(UtilColor.hexToRgb(0xffd700), UtilColor.hexToRgb(0xdaa520));
coloredCircleEffect.setYOffset(getEntityYOffset(entity));
coloredCircleEffect.start();
_selectedEntity.put(playTo, entity);
_circleEffects.put(entity, coloredCircleEffect);
}
private void stopEffect(Player player)
{
if (_selectedEntity.containsKey(player))
{
Entity entity = _selectedEntity.get(player);
if (_circleEffects.containsKey(entity))
{
_circleEffects.get(entity).stop();
_circleEffects.remove(entity);
}
_selectedEntity.remove(player);
}
}
/**
* Gets the right Y offset for that entity based on the type
* @param entity The entity
* @return The correct Y offset
*/
public double getEntityYOffset(Entity entity)
{
EntityType entityType = entity.getType();
switch (entityType)
{
case SHEEP:
case PIG:
case BAT:
case MAGMA_CUBE:
case GUARDIAN:
case CHICKEN:
case SLIME:
case SQUID:
case WOLF:
case OCELOT:
return 1.3;
case SPIDER:
case CAVE_SPIDER:
return 0.75;
case ENDERMAN:
return 3.3;
}
return 2.3;
}
}

View File

@ -3,6 +3,7 @@ package mineplex.core.gadget.gadgets.kitselector;
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;
@ -29,9 +30,40 @@ public class WaterWingsKitSelector extends KitSelectorGadget
@Override
public void playParticle(Entity entity, Player playTo)
{
Location loc = entity.getLocation().add(0, 1.2, 0).add(entity.getLocation().getDirection().multiply(-0.2));
double offsetY = getEntityYOffset(entity);
Location loc = entity.getLocation().add(0, offsetY, 0).add(entity.getLocation().getDirection().multiply(-0.2));
_wings.display(loc, playTo);
_wingsEdge.display(loc, playTo);
}
/**
* Gets the right Y offset for that entity based on the type
* @param entity The entity
* @return The correct Y offset
*/
public double getEntityYOffset(Entity entity)
{
EntityType entityType = entity.getType();
switch (entityType)
{
case SHEEP:
case PIG:
case BAT:
case MAGMA_CUBE:
case GUARDIAN:
case CHICKEN:
case SLIME:
case SQUID:
case WOLF:
case OCELOT:
return 0.75;
case SPIDER:
case CAVE_SPIDER:
return 0.25;
case ENDERMAN:
return 1.5;
}
return 1.2;
}
}