Search in sources :

Example 1 with IHorseAbstract

use of simplepets.brainsynder.api.entity.misc.IHorseAbstract in project SimplePets by brainsynder-Dev.

the class Eating method onLeftClick.

@Override
public void onLeftClick() {
    if (entityPet instanceof IHorseAbstract) {
        IHorseAbstract var = (IHorseAbstract) entityPet;
        var.setEating(!var.isEating());
    }
}
Also used : IHorseAbstract(simplepets.brainsynder.api.entity.misc.IHorseAbstract)

Example 2 with IHorseAbstract

use of simplepets.brainsynder.api.entity.misc.IHorseAbstract in project SimplePets by brainsynder-Dev.

the class Eating method getItem.

@Override
public ItemBuilder getItem() {
    ItemBuilder item = type.getDataItemByName(getTargetName(), 0);
    if (item != null) {
        if (entityPet instanceof IHorseAbstract) {
            IHorseAbstract var = (IHorseAbstract) entityPet;
            item.withName(item.getName().replace("%value%", String.valueOf(var.isEating())));
        }
    }
    return item;
}
Also used : ItemBuilder(simple.brainsynder.api.ItemBuilder) IHorseAbstract(simplepets.brainsynder.api.entity.misc.IHorseAbstract)

Example 3 with IHorseAbstract

use of simplepets.brainsynder.api.entity.misc.IHorseAbstract in project SimplePets by brainsynder-Dev.

the class Saddle method getItem.

@Override
public ItemBuilder getItem() {
    ItemBuilder item = type.getDataItemByName("saddle", 0);
    try {
        if (entityPet instanceof IEntityPigPet) {
            IEntityPigPet pig = (IEntityPigPet) entityPet;
            item.withName(item.getName().replace("%value%", String.valueOf(pig.hasSaddle())));
        } else if (entityPet instanceof IHorseAbstract) {
            IHorseAbstract var = (IHorseAbstract) entityPet;
            item.withName(item.getName().replace("%value%", String.valueOf(var.isSaddled())));
        }
    } catch (Exception e) {
        item.withName("&6Has Saddle: &cERROR");
    }
    return item;
}
Also used : ItemBuilder(simple.brainsynder.api.ItemBuilder) IEntityPigPet(simplepets.brainsynder.api.entity.passive.IEntityPigPet) IHorseAbstract(simplepets.brainsynder.api.entity.misc.IHorseAbstract)

Example 4 with IHorseAbstract

use of simplepets.brainsynder.api.entity.misc.IHorseAbstract in project SimplePets by brainsynder-Dev.

the class Saddle method onLeftClick.

@Override
public void onLeftClick() {
    if (entityPet instanceof IEntityPigPet) {
        IEntityPigPet pig = (IEntityPigPet) entityPet;
        pig.setSaddled(!pig.hasSaddle());
    } else if (entityPet instanceof IHorseAbstract) {
        IHorseAbstract var = (IHorseAbstract) entityPet;
        var.setSaddled(!var.isSaddled());
    }
}
Also used : IEntityPigPet(simplepets.brainsynder.api.entity.passive.IEntityPigPet) IHorseAbstract(simplepets.brainsynder.api.entity.misc.IHorseAbstract)

Example 5 with IHorseAbstract

use of simplepets.brainsynder.api.entity.misc.IHorseAbstract in project SimplePets by brainsynder-Dev.

the class Pet method setVehicle.

public void setVehicle(boolean value, boolean byEvent) {
    if (!byEvent) {
        if (type.canMount(owner)) {
            if (ent instanceof IHorseAbstract) {
                IHorseAbstract horse = (IHorseAbstract) ent;
                if (!horse.isSaddled())
                    horse.setSaddled(true);
            }
            if (getPet().getPassenger() != null) {
                PetVehicleEvent event = new PetVehicleEvent(this, PetVehicleEvent.Type.DISMOUNT);
                Bukkit.getServer().getPluginManager().callEvent(event);
                if (event.isCancelled())
                    return;
                if (ent instanceof IEntityControllerPet) {
                    ((IEntityControllerPet) ent).getDisplayEntity().eject();
                } else {
                    ent.getEntity().eject();
                }
                value = false;
            } else if (isVehicle()) {
                value = false;
            }
            if (value && (vehicle != value)) {
                if (isHat) {
                    PetHatEvent event = new PetHatEvent(this, PetHatEvent.Type.REMOVE);
                    Bukkit.getServer().getPluginManager().callEvent(event);
                    if (event.isCancelled())
                        return;
                    instance.getUtilities().removePassenger(owner, ent.getEntity());
                    setHat(false);
                }
                PetVehicleEvent event = new PetVehicleEvent(this, PetVehicleEvent.Type.MOUNT);
                Bukkit.getServer().getPluginManager().callEvent(event);
                if (event.isCancelled())
                    return;
                value = true;
                if (owner.getLocation().getBlock() != null) {
                    List<Material> blocks = Utilities.getBlacklistedMaterials();
                    if (!blocks.contains(owner.getLocation().getBlock().getType()) && !blocks.contains(owner.getEyeLocation().getBlock().getType())) {
                        getPet().teleport(owner);
                    }
                } else {
                    getPet().teleport(owner);
                }
                new BukkitRunnable() {

                    @Override
                    public void run() {
                        if (ent instanceof IEntityControllerPet) {
                            ((IEntityControllerPet) ent).getDisplayEntity().setPassenger(owner);
                        } else {
                            ent.getEntity().setPassenger(owner);
                        }
                    }
                }.runTaskLater(PetCore.get(), 2L);
            }
        }
    }
    vehicle = value;
}
Also used : PetHatEvent(simplepets.brainsynder.api.event.pet.PetHatEvent) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Material(org.bukkit.Material) IHorseAbstract(simplepets.brainsynder.api.entity.misc.IHorseAbstract) PetVehicleEvent(simplepets.brainsynder.api.event.pet.PetVehicleEvent) IEntityControllerPet(simplepets.brainsynder.api.entity.IEntityControllerPet)

Aggregations

IHorseAbstract (simplepets.brainsynder.api.entity.misc.IHorseAbstract)5 ItemBuilder (simple.brainsynder.api.ItemBuilder)2 IEntityPigPet (simplepets.brainsynder.api.entity.passive.IEntityPigPet)2 Material (org.bukkit.Material)1 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)1 IEntityControllerPet (simplepets.brainsynder.api.entity.IEntityControllerPet)1 PetHatEvent (simplepets.brainsynder.api.event.pet.PetHatEvent)1 PetVehicleEvent (simplepets.brainsynder.api.event.pet.PetVehicleEvent)1