Search in sources :

Example 1 with ItemBuilder

use of simple.brainsynder.api.ItemBuilder in project SimplePets by brainsynder-Dev.

the class EntityArmorStandPet method setOwner.

@Override
public void setOwner(boolean flag) {
    minime = flag;
    if (flag) {
        ItemBuilder builder = ItemBuilder.getSkull(simple.brainsynder.utils.SkullType.PLAYER);
        getEntity().setChestplate(new ItemBuilder(Material.DIAMOND_CHESTPLATE).build());
        getEntity().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).build());
        getEntity().setBoots(new ItemBuilder(Material.GOLDEN_BOOTS).build());
        WebAPI.findTexture(getOwner().getUniqueId().toString(), PetCore.get(), texture -> {
            builder.setTexture(texture);
            if (isOwner())
                getEntity().setHelmet(builder.build());
        });
    } else {
        ItemStack air = new ItemStack(Material.AIR);
        getEntity().setHelmet(air);
        getEntity().setChestplate(air);
        getEntity().setLeggings(air);
        getEntity().setBoots(air);
        org.bukkit.inventory.PlayerInventory inventory = getOwner().getInventory();
        if (!getItems(EnumItemSlot.HEAD).isSimilar(checkItem(inventory.getHelmet())))
            setSlot(EnumItemSlot.HEAD, checkItem(inventory.getHelmet()));
        if (!getItems(EnumItemSlot.CHEST).isSimilar(checkItem(inventory.getChestplate())))
            setSlot(EnumItemSlot.CHEST, checkItem(inventory.getChestplate()));
        if (!getItems(EnumItemSlot.LEGS).isSimilar(checkItem(inventory.getLeggings())))
            setSlot(EnumItemSlot.LEGS, checkItem(inventory.getLeggings()));
        if (!getItems(EnumItemSlot.FEET).isSimilar(checkItem(inventory.getBoots())))
            setSlot(EnumItemSlot.FEET, checkItem(inventory.getBoots()));
    }
}
Also used : ItemBuilder(simple.brainsynder.api.ItemBuilder) ItemStack(org.bukkit.inventory.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack)

Example 2 with ItemBuilder

use of simple.brainsynder.api.ItemBuilder in project SimplePets by brainsynder-Dev.

the class ShulkerColor method getItem.

@Override
public ItemBuilder getItem() {
    ItemBuilder item = null;
    if (getEntityPet() instanceof IColorable) {
        IColorable var = (IColorable) getEntityPet();
        DyeColorWrapper typeID = DyeColorWrapper.PURPLE;
        if (var.getColor() != null)
            typeID = var.getColor();
        item = type.getDataItemByName("shulkercolor", typeID.getWoolData());
        DyeColorWrapper prev = DyeColorWrapper.getPrevious(typeID);
        DyeColorWrapper next = DyeColorWrapper.getNext(typeID);
        List<String> lore = new ArrayList<>();
        for (Object s : (JSONArray) item.toJSON().get("lore")) {
            String str = String.valueOf(s);
            lore.add(str.replace("%prev_color%", "§" + prev.getChatChar()).replace("%prev_name%", WordUtils.capitalize(prev.name().toLowerCase())).replace("%curr_color%", "§" + typeID.getChatChar()).replace("%curr_name%", WordUtils.capitalize(typeID.name().toLowerCase())).replace("%next_color%", "§" + next.getChatChar()).replace("%next_name%", WordUtils.capitalize(next.name().toLowerCase())));
        }
        item.withLore(lore);
    }
    return item;
}
Also used : ItemBuilder(simple.brainsynder.api.ItemBuilder) DyeColorWrapper(simplepets.brainsynder.wrapper.DyeColorWrapper) ArrayList(java.util.ArrayList) JSONArray(org.json.simple.JSONArray) IColorable(simplepets.brainsynder.api.entity.misc.IColorable)

Example 3 with ItemBuilder

use of simple.brainsynder.api.ItemBuilder in project SimplePets by brainsynder-Dev.

the class ShulkerColor method getDefaultItems.

@Override
public List<ItemBuilder> getDefaultItems() {
    List<ItemBuilder> items = new ArrayList<>();
    for (DyeColorWrapper color : DyeColorWrapper.values()) {
        String name = color.name();
        if (name.equalsIgnoreCase("SILVER") && (ServerVersion.getVersion() == ServerVersion.v1_13_R1 || ServerVersion.getVersion() == ServerVersion.v1_13_R2)) {
            name = "LIGHT_GRAY";
        }
        ItemBuilder item = new ItemBuilder(Utilities.findMaterial(name + "_SHULKER_BOX"));
        item.withName(" ");
        item.addLore("&6Previous: %prev_color%%prev_name%", "&6Current: %curr_color%%curr_name%", "&6Next: %next_color%%next_name%");
        items.add(item);
    }
    return items;
}
Also used : ItemBuilder(simple.brainsynder.api.ItemBuilder) DyeColorWrapper(simplepets.brainsynder.wrapper.DyeColorWrapper) ArrayList(java.util.ArrayList)

Example 4 with ItemBuilder

use of simple.brainsynder.api.ItemBuilder 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 5 with ItemBuilder

use of simple.brainsynder.api.ItemBuilder 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)

Aggregations

ItemBuilder (simple.brainsynder.api.ItemBuilder)108 ArrayList (java.util.ArrayList)65 PetDefault (simplepets.brainsynder.pet.PetDefault)13 List (java.util.List)11 IEntityPet (simplepets.brainsynder.api.entity.IEntityPet)11 MenuItemAbstract (simplepets.brainsynder.menu.menuItems.base.MenuItemAbstract)11 ValueType (simplepets.brainsynder.utils.ValueType)11 ServerVersion (simple.brainsynder.utils.ServerVersion)10 DyeColorWrapper (simplepets.brainsynder.wrapper.DyeColorWrapper)8 JSONArray (org.json.simple.JSONArray)7 IEntityPandaPet (simplepets.brainsynder.api.entity.passive.IEntityPandaPet)6 IEntityFoxPet (simplepets.brainsynder.api.entity.passive.IEntityFoxPet)5 Utilities (simplepets.brainsynder.utils.Utilities)5 ItemStack (org.bukkit.inventory.ItemStack)4 IEntityHorsePet (simplepets.brainsynder.api.entity.passive.IEntityHorsePet)3 IEntityTropicalFishPet (simplepets.brainsynder.api.entity.passive.IEntityTropicalFishPet)3 SkullType (simple.brainsynder.utils.SkullType)2 IEntityArmorStandPet (simplepets.brainsynder.api.entity.ambient.IEntityArmorStandPet)2 IEntityWitherPet (simplepets.brainsynder.api.entity.hostile.IEntityWitherPet)2 IEntityZombiePet (simplepets.brainsynder.api.entity.hostile.IEntityZombiePet)2