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;
}
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());
}
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));
}
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;
}
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);
}
Aggregations