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