Search in sources :

Example 36 with ItemBuilder

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

the class PetEventListeners method openMenuSelector.

@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void openMenuSelector(PetInventoryOpenEvent event) {
    if (!PetCore.get().getConfiguration().getBoolean("UseVaultEconomy"))
        return;
    IStorage<ItemStack> items = new StorageList<>();
    IStorage<PetTypeStorage> types = event.getShownPetTypes().copy();
    PetOwner petOwner = PetOwner.getPetOwner(event.getPlayer());
    JSONArray petArray = petOwner.getOwnedPets();
    List<String> lore = economyFile.getStringList((economyFile.getBoolean("Pay-Per-Use.Enabled") ? "Pay-Per-Use.Lore-Lines" : "Lore-Lines"));
    while (types.hasNext()) {
        PetTypeStorage storage = types.next();
        PetDefault type = storage.getType();
        ItemBuilder maker = ItemBuilder.fromJSON(storage.getType().getItemBuilder().toJSON());
        String price = String.valueOf(economyFile.getPrice(type));
        if (price.equals("-1"))
            price = economyFile.getString("Price-Free");
        try {
            if (price.isEmpty()) {
                PetCore.get().debug("Price is empty for: 'Pet." + type.getConfigName() + ".Price'");
                items.add(maker.build());
                continue;
            }
            Double.parseDouble(price);
        } catch (Exception e) {
            PetCore.get().debug("Price is invalid for: 'Pet." + type.getConfigName() + ".Price'");
            items.add(maker.build());
            continue;
        }
        if (economyFile.getBoolean("Bypass.Hide-Price-If-Bypassed") && event.getPlayer().hasPermission("Pet.economy.bypass"))
            price = economyFile.getString("Bypass.Price");
        boolean contains = petArray.contains(type.getConfigName());
        for (String line : lore) maker.addLore(line.replace("%cost%", price).replace("%contains%", String.valueOf(contains)));
        items.add(maker.build());
        storage.setItem(maker);
    }
    event.setItems(items);
}
Also used : PetOwner(simplepets.brainsynder.player.PetOwner) PetDefault(simplepets.brainsynder.pet.PetDefault) JSONArray(org.json.simple.JSONArray) StorageList(simple.brainsynder.storage.StorageList) PetTypeStorage(simplepets.brainsynder.storage.PetTypeStorage) ItemBuilder(simple.brainsynder.api.ItemBuilder) ItemStack(org.bukkit.inventory.ItemStack) EventHandler(org.bukkit.event.EventHandler)

Example 37 with ItemBuilder

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

the class Angry method getItem.

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

Example 38 with ItemBuilder

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

the class Arms method getItem.

@Override
public ItemBuilder getItem() {
    ItemBuilder item = type.getDataItemByName("arms", 0);
    if (entityPet instanceof IEntityZombiePet) {
        IEntityZombiePet var = (IEntityZombiePet) entityPet;
        item.withName(item.getName().replace("%value%", String.valueOf(var.isArmsRaised())));
    } else if (entityPet instanceof ISkeletonAbstract) {
        ISkeletonAbstract var = (ISkeletonAbstract) entityPet;
        item.withName(item.getName().replace("%value%", String.valueOf(var.isArmsRaised())));
    }
    return item;
}
Also used : ItemBuilder(simple.brainsynder.api.ItemBuilder) IEntityZombiePet(simplepets.brainsynder.api.entity.hostile.IEntityZombiePet) ISkeletonAbstract(simplepets.brainsynder.api.entity.misc.ISkeletonAbstract)

Example 39 with ItemBuilder

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

the class Arms method getDefaultItems.

@Override
public List<ItemBuilder> getDefaultItems() {
    ItemBuilder item = new ItemBuilder(Material.STICK);
    item.withName("&6Arms Raised: &e%value%");
    return new ArrayList<>(Collections.singleton(item));
}
Also used : ItemBuilder(simple.brainsynder.api.ItemBuilder) ArrayList(java.util.ArrayList)

Example 40 with ItemBuilder

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

the class Color method getDefaultItems.

@Override
public List<ItemBuilder> getDefaultItems() {
    List<ItemBuilder> items = new ArrayList<>();
    for (DyeColorWrapper color : DyeColorWrapper.values()) {
        ItemBuilder item = ItemBuilder.getColored(simple.brainsynder.utils.MatType.WOOL, color.getWoolData());
        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)

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