Search in sources :

Example 31 with ItemBuilder

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

the class BeeAngry method getDefaultItems.

@Override
public List<ItemBuilder> getDefaultItems() {
    ItemBuilder item = ItemBuilder.getSkull(SkullType.PLAYER).setTexture("http://textures.minecraft.net/texture/e400223f1fa54741d421d7e8046409d5f3e15c7f4364b1b739940208f3b686d4");
    item.withName("&6Angry: &e%value%");
    return new ArrayList<>(Collections.singleton(item));
}
Also used : ItemBuilder(simple.brainsynder.api.ItemBuilder) ArrayList(java.util.ArrayList)

Example 32 with ItemBuilder

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

the class Stung method getDefaultItems.

@Override
public List<ItemBuilder> getDefaultItems() {
    ItemBuilder item = ItemBuilder.getSkull(SkullType.PLAYER).setTexture("http://textures.minecraft.net/texture/fa2cb74c13245d3ce9bacc8b1600af02fd7c91f501feaf97364e1f8b6f04f47f");
    item.withName("&6Has Stinger: &e%value%");
    return new ArrayList<>(Collections.singleton(item));
}
Also used : ItemBuilder(simple.brainsynder.api.ItemBuilder) ArrayList(java.util.ArrayList)

Example 33 with ItemBuilder

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

the class FoxAngry method getItem.

@Override
public ItemBuilder getItem() {
    ItemBuilder builder = type.getDataItemByName(getTargetName(), 0);
    builder.withName(formatName(builder, (entity, name) -> {
        name = name.replace("%value%", String.valueOf(entity.isAggressive()));
        return name;
    }));
    return builder;
}
Also used : ServerVersion(simple.brainsynder.utils.ServerVersion) IEntityFoxPet(simplepets.brainsynder.api.entity.passive.IEntityFoxPet) List(java.util.List) PetDefault(simplepets.brainsynder.pet.PetDefault) ItemBuilder(simple.brainsynder.api.ItemBuilder) IEntityPet(simplepets.brainsynder.api.entity.IEntityPet) ValueType(simplepets.brainsynder.utils.ValueType) MenuItemAbstract(simplepets.brainsynder.menu.menuItems.base.MenuItemAbstract) ArrayList(java.util.ArrayList) ItemBuilder(simple.brainsynder.api.ItemBuilder)

Example 34 with ItemBuilder

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

the class FoxHeadRoll method getItem.

@Override
public ItemBuilder getItem() {
    ItemBuilder builder = type.getDataItemByName(getTargetName(), 0);
    builder.withName(formatName(builder, (entity, name) -> {
        name = name.replace("%value%", String.valueOf(entity.isRollingHead()));
        return name;
    }));
    return builder;
}
Also used : ServerVersion(simple.brainsynder.utils.ServerVersion) IEntityFoxPet(simplepets.brainsynder.api.entity.passive.IEntityFoxPet) List(java.util.List) PetDefault(simplepets.brainsynder.pet.PetDefault) ItemBuilder(simple.brainsynder.api.ItemBuilder) IEntityPet(simplepets.brainsynder.api.entity.IEntityPet) ValueType(simplepets.brainsynder.utils.ValueType) MenuItemAbstract(simplepets.brainsynder.menu.menuItems.base.MenuItemAbstract) ArrayList(java.util.ArrayList) ItemBuilder(simple.brainsynder.api.ItemBuilder)

Example 35 with ItemBuilder

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

the class SavesMenu method open.

@Override
public void open(PetOwner owner, int page) {
    if (!isEnabled())
        return;
    Player player = Bukkit.getPlayer(owner.getUuid());
    pageSave.put(player.getName(), page);
    Inventory inv = Bukkit.createInventory(new SavesHolder(), getSize(), getTitle());
    int placeHolder = inv.getSize();
    int maxPets = 0;
    while (placeHolder > 0) {
        int slot = (placeHolder - 1);
        if (getSlots().containsKey(slot)) {
            Item item = getSlots().get(slot);
            if (item instanceof Air) {
                maxPets++;
            } else {
                inv.setItem(placeHolder - 1, PetCore.get().getItemLoaders().PLACEHOLDER.getItemBuilder().build());
            }
        } else {
            inv.setItem(placeHolder - 1, PetCore.get().getItemLoaders().PLACEHOLDER.getItemBuilder().build());
        }
        placeHolder--;
    }
    ObjectPager<StorageTagCompound> pages = new ObjectPager<>(maxPets, new ArrayList<>(owner.getSavedPets()));
    if (pagerMap.containsKey(player.getName())) {
        pages = pagerMap.get(player.getName());
    } else {
        pagerMap.put(player.getName(), pages);
    }
    getSlots().forEach((slot, item) -> {
        if (item.isEnabled() && item.addItemToInv(owner, this))
            inv.setItem(slot, item.getItemBuilder().build());
    });
    Map<StorageTagCompound, ItemStack> storageMap = itemMap.getOrDefault(player.getName(), new HashMap<>());
    if (!pages.isEmpty()) {
        pages.getPage(page).forEach(compound -> {
            PetDefault type = PetCore.get().getTypeManager().getType(compound.getString("PetType"));
            if (type != null) {
                ItemStack stack;
                if (storageMap.containsKey(compound)) {
                    stack = storageMap.get(compound);
                } else {
                    ItemBuilder builder = type.getItemBuilder().clone();
                    if (builder.getRawMeta().hasLore())
                        builder.clearLore();
                    if (compound.hasKey("name") && (!compound.getString("name").equals("null")))
                        builder.withName(compound.getString("name"));
                    compound.getKeySet().forEach(key -> {
                        if (!key.equals("name")) {
                            StorageBase base = compound.getTag(key);
                            if (base instanceof StorageTagCompound) {
                                builder.addLore("  §e" + key + "§6:");
                                for (String keys : ((StorageTagCompound) base).getKeySet()) {
                                    builder.addLore("  - §e" + keys + "§6: §7" + fetchValue(compound.getTag(keys)));
                                }
                            } else {
                                builder.addLore("  §e" + key + "§6: §7" + fetchValue(base));
                            }
                        }
                    });
                    stack = builder.build();
                    storageMap.put(compound, stack);
                }
                inv.addItem(stack);
            }
        });
    }
    itemMap.put(player.getName(), storageMap);
    player.openInventory(inv);
}
Also used : Player(org.bukkit.entity.Player) PetDefault(simplepets.brainsynder.pet.PetDefault) ObjectPager(simple.brainsynder.utils.ObjectPager) Air(simplepets.brainsynder.menu.items.list.Air) Item(simplepets.brainsynder.menu.items.Item) ItemBuilder(simple.brainsynder.api.ItemBuilder) SavesHolder(simplepets.brainsynder.menu.holders.SavesHolder) ItemStack(org.bukkit.inventory.ItemStack) CustomInventory(simplepets.brainsynder.menu.inventory.CustomInventory) Inventory(org.bukkit.inventory.Inventory)

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