Search in sources :

Example 1 with IEntityArmorStandPet

use of simplepets.brainsynder.api.entity.ambient.IEntityArmorStandPet in project SimplePets by brainsynder-Dev.

the class Stand method getItem.

@Override
public ItemBuilder getItem() {
    ItemBuilder item = type.getDataItemByName("stand", 0);
    if (entityPet instanceof IEntityArmorStandPet) {
        IEntityArmorStandPet var = (IEntityArmorStandPet) entityPet;
        item.withName(item.getName().replace("%value%", String.valueOf(var.isSmall())));
    } else if (entityPet instanceof IEntityPolarBearPet) {
        IEntityPolarBearPet var = (IEntityPolarBearPet) entityPet;
        item.withName(item.getName().replace("%value%", String.valueOf(var.isStanding())));
    }
    return item;
}
Also used : ItemBuilder(simple.brainsynder.api.ItemBuilder) IEntityArmorStandPet(simplepets.brainsynder.api.entity.ambient.IEntityArmorStandPet) IEntityPolarBearPet(simplepets.brainsynder.api.entity.passive.IEntityPolarBearPet)

Example 2 with IEntityArmorStandPet

use of simplepets.brainsynder.api.entity.ambient.IEntityArmorStandPet in project SimplePets by brainsynder-Dev.

the class ArmorMenu method update.

public void update(PetOwner owner) {
    if (!isEnabled())
        return;
    if (owner == null)
        return;
    Player player = Bukkit.getPlayer(owner.getUuid());
    if (player.getOpenInventory() == null)
        return;
    Inventory inv = player.getOpenInventory().getTopInventory();
    if (inv.getHolder() == null)
        return;
    if (!(inv.getHolder() instanceof ArmorHolder))
        return;
    getSlots().forEach((slot, item) -> {
        if (item instanceof Air)
            if (item.isEnabled() && item.addItemToInv(owner, this))
                inv.setItem(slot, item.getItemBuilder().build());
    });
    IEntityPet pet = owner.getPet().getEntity();
    if (!(pet instanceof IEntityArmorStandPet))
        return;
    IEntityArmorStandPet stand = (IEntityArmorStandPet) pet;
    inv.setItem(13, stand.getHeadItem());
    inv.setItem(21, stand.getLeftArmItem());
    inv.setItem(22, stand.getBodyItem());
    inv.setItem(23, stand.getRightArmItem());
    inv.setItem(31, stand.getLegItem());
    inv.setItem(40, stand.getFootItem());
}
Also used : Player(org.bukkit.entity.Player) ArmorHolder(simplepets.brainsynder.menu.holders.ArmorHolder) Air(simplepets.brainsynder.menu.items.list.Air) IEntityArmorStandPet(simplepets.brainsynder.api.entity.ambient.IEntityArmorStandPet) IEntityPet(simplepets.brainsynder.api.entity.IEntityPet) CustomInventory(simplepets.brainsynder.menu.inventory.CustomInventory) Inventory(org.bukkit.inventory.Inventory)

Example 3 with IEntityArmorStandPet

use of simplepets.brainsynder.api.entity.ambient.IEntityArmorStandPet in project SimplePets by brainsynder-Dev.

the class Update method onClick.

@Override
public void onClick(PetOwner owner, CustomInventory inventory) {
    if (!(inventory instanceof ArmorMenu))
        return;
    if (!owner.hasPet())
        return;
    Player player = owner.getPlayer();
    IEntityArmorStandPet stand = (IEntityArmorStandPet) owner.getPet().getVisableEntity();
    if (player.getOpenInventory() == null)
        return;
    Inventory open = player.getOpenInventory().getTopInventory();
    if (open.getHolder() == null)
        return;
    if (!(open.getHolder() instanceof ArmorHolder))
        return;
    stand.setHeadItem(open.getItem(13));
    stand.setLeftArmItem(open.getItem(21));
    stand.setBodyItem(open.getItem(22));
    stand.setRightArmItem(open.getItem(23));
    stand.setLegItem(open.getItem(31));
    stand.setFootItem(open.getItem(40));
}
Also used : Player(org.bukkit.entity.Player) ArmorHolder(simplepets.brainsynder.menu.holders.ArmorHolder) IEntityArmorStandPet(simplepets.brainsynder.api.entity.ambient.IEntityArmorStandPet) ArmorMenu(simplepets.brainsynder.menu.inventory.list.ArmorMenu) CustomInventory(simplepets.brainsynder.menu.inventory.CustomInventory) Inventory(org.bukkit.inventory.Inventory)

Example 4 with IEntityArmorStandPet

use of simplepets.brainsynder.api.entity.ambient.IEntityArmorStandPet in project SimplePets by brainsynder-Dev.

the class Clone method getItem.

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

Example 5 with IEntityArmorStandPet

use of simplepets.brainsynder.api.entity.ambient.IEntityArmorStandPet in project SimplePets by brainsynder-Dev.

the class ArmorMenu method open.

@Override
public void open(PetOwner owner) {
    if (owner == null)
        return;
    if (!owner.hasPet())
        return;
    Player player = Bukkit.getPlayer(owner.getUuid());
    Inventory inv = Bukkit.createInventory(new ArmorHolder(), 54, getTitle());
    int placeHolder = inv.getSize();
    while (placeHolder > 0) {
        inv.setItem(placeHolder - 1, PetCore.get().getItemLoaders().RED_PLACEHOLDER.getItemBuilder().build());
        placeHolder--;
    }
    getSlots().forEach((slot, item) -> {
        if (item.isEnabled() && item.addItemToInv(owner, this))
            inv.setItem(slot, item.getItemBuilder().build());
    });
    IEntityPet pet = owner.getPet().getVisableEntity();
    IEntityArmorStandPet stand = (IEntityArmorStandPet) pet;
    inv.setItem(13, stand.getHeadItem());
    inv.setItem(21, stand.getLeftArmItem());
    inv.setItem(22, stand.getBodyItem());
    inv.setItem(23, stand.getRightArmItem());
    inv.setItem(31, stand.getLegItem());
    inv.setItem(40, stand.getFootItem());
    player.openInventory(inv);
}
Also used : Player(org.bukkit.entity.Player) ArmorHolder(simplepets.brainsynder.menu.holders.ArmorHolder) IEntityArmorStandPet(simplepets.brainsynder.api.entity.ambient.IEntityArmorStandPet) IEntityPet(simplepets.brainsynder.api.entity.IEntityPet) CustomInventory(simplepets.brainsynder.menu.inventory.CustomInventory) Inventory(org.bukkit.inventory.Inventory)

Aggregations

IEntityArmorStandPet (simplepets.brainsynder.api.entity.ambient.IEntityArmorStandPet)5 Player (org.bukkit.entity.Player)3 Inventory (org.bukkit.inventory.Inventory)3 ArmorHolder (simplepets.brainsynder.menu.holders.ArmorHolder)3 CustomInventory (simplepets.brainsynder.menu.inventory.CustomInventory)3 ItemBuilder (simple.brainsynder.api.ItemBuilder)2 IEntityPet (simplepets.brainsynder.api.entity.IEntityPet)2 IEntityPolarBearPet (simplepets.brainsynder.api.entity.passive.IEntityPolarBearPet)1 ArmorMenu (simplepets.brainsynder.menu.inventory.list.ArmorMenu)1 Air (simplepets.brainsynder.menu.items.list.Air)1