Added sheep mount to index.

This commit is contained in:
Mysticate 2016-02-04 13:13:22 -05:00
parent c0d6cbbb85
commit e94222a68e

View File

@ -0,0 +1,95 @@
package mineplex.core.mount.types;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilText;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseSheep;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class MountValentinesSheep extends HorseMount
{
/**
* Created by: Mysticate
* Timestamp: February 4, 2016
*/
public MountValentinesSheep(MountManager manager)
{
super(manager, "Loving Sheeples",
UtilText.splitLineToArray(C.cGray + "This symbol of love will live on with you forever! Mainly because we couldn't attach the cupid wings to it. I guess duct tape can't fix everything!", LineFormat.LORE),
Material.WOOL, (byte) 6, -6, Horse.Color.BLACK, Horse.Style.NONE, Horse.Variant.HORSE, 1.0, null);
}
@Override
public void EnableCustom(Player player)
{
super.EnableCustom(player);
Horse horse = GetActive().get(player).getEntity();
horse.setCustomName(C.cRed + player.getName() + "'s " + GetName());
UtilEnt.silence(horse, true);
DisguiseSheep disguise = new DisguiseSheep(horse);
disguise.setColor(DyeColor.PINK);
disguise.setName("");
Manager.getDisguiseManager().disguise(disguise);
}
@EventHandler
public void doAnimations(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (SingleEntityMountData<Horse> ent : GetActive().values())
{
if (!ent.getEntity().isValid())
continue;
if (event.getType() == UpdateType.TICK)
{
UtilParticle.PlayParticleToAll(ParticleType.HEART, ent.getEntity().getLocation().clone().add(0, .5, 0), new Vector(), 0F, 1, ViewDist.NORMAL);
}
else if (event.getType() == UpdateType.FAST)
{
DisguiseBase disguise = Manager.getDisguiseManager().getDisguise(ent.getEntity());
if (disguise instanceof DisguiseSheep)
{
DisguiseSheep sheep = (DisguiseSheep) disguise;
if (sheep.getColor() == 6) // Pink
{
sheep.setColor(DyeColor.RED);
}
else if (sheep.getColor() == 14) // Red
{
sheep.setColor(DyeColor.MAGENTA);
}
else if (sheep.getColor() == 2) // Magenta
{
sheep.setColor(DyeColor.PINK);
}
}
}
}
}
}