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