use of com.wynntils.core.framework.enums.SpellType in project Wynntils by Wynntils.
the class ConsumableTimerOverlay method verifyIdentification.
private static void verifyIdentification(Matcher m, ConsumableContainer consumable) {
String idName = m.group("ID");
String suffix = m.group("Suffix");
boolean isRaw = suffix == null;
SpellType spell = SpellType.fromName(idName);
if (spell != null)
idName = spell.getGenericName();
String shortIdName = ItemIdentificationOverlay.toShortIdName(idName, isRaw);
IdentificationModifier modifier = IdentificationModifier.INTEGER;
if (!isRaw) {
// loop through all modifier options to find a valid one
for (IdentificationModifier mod : IdentificationModifier.values()) {
if (mod.getInGame(shortIdName).isEmpty() || !suffix.contains(mod.getInGame(shortIdName)))
continue;
modifier = mod;
break;
}
}
// finish by adding the effect to the container
consumable.addEffect(shortIdName, Integer.parseInt(m.group("Value")), modifier);
}
use of com.wynntils.core.framework.enums.SpellType in project Wynntils by Wynntils.
the class ItemIdentificationOverlay method generateData.
public static NBTTagCompound generateData(ItemStack stack, IdentificationType idType) {
if (stack.hasTagCompound() && stack.getTagCompound().hasKey("wynntils")) {
NBTTagCompound compound = stack.getTagCompound().getCompoundTag("wynntils");
// check for updates
if (!compound.getString("currentType").equals(idType.toString())) {
compound.setBoolean("shouldUpdate", true);
compound.setString("currentType", idType.toString());
stack.getTagCompound().setTag("wynntils", compound);
}
return compound;
}
NBTTagCompound mainTag = new NBTTagCompound();
{
// main data
// this replace allow market items to be scanned
mainTag.setString("originName", StringUtils.normalizeBadString(getTextWithoutFormattingCodes(stack.getDisplayName())));
mainTag.setString("currentType", idType.toString());
mainTag.setBoolean("shouldUpdate", true);
}
NBTTagCompound idTag = new NBTTagCompound();
NBTTagCompound setBonus = new NBTTagCompound();
NBTTagList purchaseInfo = new NBTTagList();
{
// lore data
boolean isBonus = false;
for (String loreLine : ItemUtils.getLore(stack)) {
String lColor = getTextWithoutFormattingCodes(loreLine);
if (lColor.isEmpty())
continue;
// set bonus detection
if (lColor.contains("Set Bonus:")) {
isBonus = true;
continue;
}
// ids and set bonus
{
Matcher idMatcher = ID_PATTERN.matcher(lColor);
if (idMatcher.find()) {
String idName = idMatcher.group("ID");
boolean isRaw = idMatcher.group("Suffix") == null;
int stars = idMatcher.group("Stars").length();
SpellType spell = SpellType.fromName(idName);
if (spell != null) {
idName = spell.getGenericName() + " Cost";
}
String shortIdName = toShortIdName(idName, isRaw);
if (stars != 0) {
idTag.setInteger(shortIdName + "*", stars);
}
if (isBonus) {
setBonus.setString(shortIdName, loreLine);
continue;
}
idTag.setInteger(shortIdName, Integer.parseInt(idMatcher.group("Value")));
continue;
}
}
// rerolls
{
Matcher rerollMatcher = ITEM_QUALITY.matcher(lColor);
if (rerollMatcher.find()) {
if (rerollMatcher.group("Rolls") == null)
continue;
mainTag.setInteger("rerollAmount", Integer.parseInt(rerollMatcher.group("Rolls")));
continue;
}
}
// powders
if (lColor.contains("] Powder Slots"))
mainTag.setString("powderSlots", loreLine);
// dungeon and merchant prices
if (lColor.startsWith(" - ✔") || lColor.startsWith(" - ✖")) {
purchaseInfo.appendTag(new NBTTagString(loreLine));
continue;
}
// market
{
Matcher market = MARKET_PRICE.matcher(lColor);
if (!market.find())
continue;
NBTTagCompound marketTag = new NBTTagCompound();
if (market.group("Quantity") != null)
marketTag.setInteger("quantity", Integer.parseInt(market.group("Quantity").replace(",", "").replace(" x ", "")));
marketTag.setInteger("price", Integer.parseInt(market.group("Value").replace(",", "")));
mainTag.setTag("marketInfo", marketTag);
}
}
if (idTag.getSize() > 0)
mainTag.setTag("ids", idTag);
if (setBonus.getSize() > 0)
mainTag.setTag("setBonus", setBonus);
if (purchaseInfo.tagCount() > 0)
mainTag.setTag("purchaseInfo", purchaseInfo);
}
// update compound
NBTTagCompound stackCompound = stack.getTagCompound();
stackCompound.setTag("wynntils", mainTag);
stack.setTagCompound(stackCompound);
return mainTag;
}
use of com.wynntils.core.framework.enums.SpellType in project Wynntils by Wynntils.
the class SkillPointOverlay method addManaTables.
public void addManaTables(ChestReplacer gui) {
ItemStack stack = gui.getLowerInv().getStackInSlot(11);
// display name also checks for tag compound
if (stack.isEmpty() || !stack.hasDisplayName())
return;
int intelligencePoints = getIntelligencePoints(stack);
if (stack.getTagCompound().hasKey("wynntilsAnalyzed"))
return;
int closestUpgradeLevel = Integer.MAX_VALUE;
int level = PlayerInfo.get(CharacterData.class).getLevel();
List<String> newLore = new LinkedList<>();
for (int j = 0; j < 4; j++) {
SpellType spell = SpellType.forClass(PlayerInfo.get(CharacterData.class).getCurrentClass(), j + 1);
if (spell.getUnlockLevel(1) <= level) {
int nextUpgrade = spell.getNextManaReduction(level, intelligencePoints);
if (nextUpgrade < closestUpgradeLevel) {
closestUpgradeLevel = nextUpgrade;
}
int manaCost = spell.getManaCost(level, intelligencePoints);
String spellName = PlayerInfo.get(CharacterData.class).isReskinned() ? spell.getReskinned() : spell.getName();
String spellInfo = TextFormatting.LIGHT_PURPLE + spellName + " Spell: " + TextFormatting.AQUA + "-" + manaCost + " ✺";
if (nextUpgrade < Integer.MAX_VALUE) {
spellInfo += TextFormatting.GRAY + " (-" + (manaCost - 1) + " ✺ in " + remainingLevelsDescription(nextUpgrade - intelligencePoints) + ")";
}
newLore.add(spellInfo);
}
}
List<String> loreTag = new LinkedList<>(ItemUtils.getLore(stack));
if (closestUpgradeLevel < Integer.MAX_VALUE) {
loreTag.add("");
loreTag.add(TextFormatting.GRAY + "Next upgrade: At " + TextFormatting.WHITE + closestUpgradeLevel + TextFormatting.GRAY + " points (in " + remainingLevelsDescription(closestUpgradeLevel - intelligencePoints) + ")");
}
loreTag.add("");
loreTag.addAll(newLore);
ItemUtils.replaceLore(stack, loreTag);
stack.getTagCompound().setBoolean("wynntilsAnalyzed", true);
}
use of com.wynntils.core.framework.enums.SpellType in project Wynntils by Wynntils.
the class ItemIdentificationOverlay method replaceLore.
public static void replaceLore(ItemStack stack, IdentificationType forcedIdType) {
if (!UtilitiesConfig.Identifications.INSTANCE.enabled || !stack.hasDisplayName() || !stack.hasTagCompound())
return;
NBTTagCompound nbt = stack.getTagCompound();
if (nbt.hasKey("wynntilsIgnore"))
return;
String itemName = StringUtils.normalizeBadString(getTextWithoutFormattingCodes(stack.getDisplayName()));
// Check if unidentified item.
if (itemName.contains("Unidentified") && UtilitiesConfig.Identifications.INSTANCE.showItemGuesses) {
nbt.setBoolean("wynntilsIgnore", true);
// add possible items
addItemGuesses(stack);
return;
}
// Check if item is a valid item if not ignore it
if (!nbt.hasKey("wynntils") && WebManager.getItems().get(itemName) == null) {
nbt.setBoolean("wynntilsIgnore", true);
return;
}
NBTTagCompound wynntils = generateData(stack, forcedIdType);
ItemProfile item = WebManager.getItems().get(wynntils.getString("originName"));
// Block if the item is not the real item
if (!wynntils.hasKey("isPerfect") && !wynntils.hasKey("isDefective") && !stack.getDisplayName().startsWith(item.getTier().getTextColor())) {
nbt.setBoolean("wynntilsIgnore", true);
nbt.removeTag("wynntils");
return;
}
// Perfect name
if (wynntils.hasKey("isPerfect")) {
stack.setStackDisplayName(AnimatedText.makeRainbow("Perfect " + wynntils.getString("originName"), true));
}
// Defective name
if (wynntils.hasKey("isDefective")) {
stack.setStackDisplayName(AnimatedText.makeDefective(wynntils.getString("originName"), true));
}
// Update only if should update, this is decided on generateDate
if (!wynntils.getBoolean("shouldUpdate"))
return;
wynntils.setBoolean("shouldUpdate", false);
// Objects
IdentificationType idType = IdentificationType.valueOf(wynntils.getString("currentType"));
List<String> newLore = new ArrayList<>();
// Generating id lores
Map<String, String> idLore = new HashMap<>();
double relativeTotal = 0;
int idAmount = 0;
boolean hasNewId = false;
if (wynntils.hasKey("ids")) {
NBTTagCompound ids = wynntils.getCompoundTag("ids");
for (String idName : ids.getKeySet()) {
// star data, ignore
if (idName.contains("*"))
continue;
IdentificationContainer id = item.getStatuses().get(idName);
IdentificationModifier type = id != null ? id.getType() : IdentificationContainer.getTypeFromName(idName);
// not a valid id
if (type == null)
continue;
int currentValue = ids.getInteger(idName);
boolean isInverted = IdentificationOrderer.INSTANCE.isInverted(idName);
// id color
String longName = IdentificationContainer.getAsLongName(idName);
SpellType spell = SpellType.fromName(longName);
if (spell != null) {
ClassType requiredClass = item.getClassNeeded();
if (requiredClass != null) {
longName = spell.forOtherClass(requiredClass).getName() + " Spell Cost";
} else {
longName = spell.forOtherClass(PlayerInfo.get(CharacterData.class).getCurrentClass()).getGenericAndSpecificName() + " Cost";
}
}
String lore;
if (isInverted)
lore = (currentValue < 0 ? GREEN.toString() : currentValue > 0 ? RED + "+" : GRAY.toString()) + currentValue + type.getInGame(idName);
else
lore = (currentValue < 0 ? RED.toString() : currentValue > 0 ? GREEN + "+" : GRAY.toString()) + currentValue + type.getInGame(idName);
if (UtilitiesConfig.Identifications.INSTANCE.addStars && ids.hasKey(idName + "*")) {
lore += DARK_GREEN + "***".substring(0, ids.getInteger(idName + "*"));
}
lore += " " + GRAY + longName;
if (id == null) {
// id not in api
idLore.put(idName, lore + GOLD + " NEW");
hasNewId = true;
continue;
}
if (id.hasConstantValue()) {
if (id.getBaseValue() != currentValue) {
idLore.put(idName, lore + GOLD + " NEW");
hasNewId = true;
continue;
}
idLore.put(idName, lore);
continue;
}
IdentificationResult result = idType.identify(id, currentValue, isInverted);
idLore.put(idName, lore + " " + result.getLore());
if (result.getAmount() > 1d || result.getAmount() < 0d) {
hasNewId = true;
continue;
}
relativeTotal += result.getAmount();
idAmount++;
}
}
// Copying some parts of the old lore (stops on ids, powder or quality)
boolean ignoreNext = false;
for (String oldLore : ItemUtils.getLore(stack)) {
if (ignoreNext) {
ignoreNext = false;
continue;
}
String rawLore = getTextWithoutFormattingCodes(oldLore);
// market stuff
if (rawLore.contains("Price:")) {
ignoreNext = true;
NBTTagCompound market = wynntils.getCompoundTag("marketInfo");
newLore.add(GOLD + "Price:");
String mLore = GOLD + " - " + GRAY;
if (market.hasKey("quantity")) {
mLore += market.getInteger("quantity") + " x ";
}
int[] money = calculateMoneyAmount(market.getInteger("price"));
String price = "";
if (money[3] != 0)
price += money[3] + "stx ";
if (money[2] != 0)
price += money[2] + EmeraldSymbols.LE + " ";
if (money[1] != 0)
price += money[1] + EmeraldSymbols.BLOCKS + " ";
if (money[0] != 0)
price += money[0] + EmeraldSymbols.EMERALDS + " ";
price = price.trim();
mLore += "" + WHITE + decimalFormat.format(market.getInteger("price")) + EmeraldSymbols.EMERALDS;
mLore += DARK_GRAY + " (" + price + ")";
newLore.add(mLore);
continue;
}
// Stop on id if the item has ids
if (idLore.size() > 0) {
if (rawLore.startsWith("+") || rawLore.startsWith("-"))
break;
newLore.add(oldLore);
continue;
}
// Stop on powders if the item has powders
if (wynntils.hasKey("powderSlots") && oldLore.contains("] Powder Slots")) {
break;
}
// Stop on quality if there's no other
Matcher m = ITEM_QUALITY.matcher(rawLore);
if (m.matches())
break;
newLore.add(oldLore);
}
// Add id lores
if (idLore.size() > 0) {
newLore.addAll(IdentificationOrderer.INSTANCE.order(idLore, UtilitiesConfig.Identifications.INSTANCE.addSpacing));
newLore.add(" ");
}
// Major ids
if (item.getMajorIds() != null && item.getMajorIds().size() > 0) {
for (MajorIdentification majorId : item.getMajorIds()) {
if (majorId == null)
continue;
Stream.of(StringUtils.wrapTextBySize(majorId.asLore(), 150)).forEach(c -> newLore.add(DARK_AQUA + c));
}
newLore.add(" ");
}
// Powder lore
if (wynntils.hasKey("powderSlots"))
newLore.add(wynntils.getString("powderSlots"));
// Set Bonus
if (wynntils.hasKey("setBonus")) {
if (wynntils.hasKey("powderSlots"))
newLore.add(" ");
newLore.add(GREEN + "Set Bonus:");
NBTTagCompound ids = wynntils.getCompoundTag("setBonus");
Map<String, String> bonusOrder = new HashMap<>();
for (String idName : ids.getKeySet()) {
bonusOrder.put(idName, ids.getString(idName));
}
newLore.addAll(IdentificationOrderer.INSTANCE.order(bonusOrder, UtilitiesConfig.Identifications.INSTANCE.addSetBonusSpacing));
newLore.add(" ");
}
// Quality lore
String quality = item.getTier().asLore();
int rollAmount = (wynntils.hasKey("rerollAmount") ? wynntils.getInteger("rerollAmount") : 0);
if (rollAmount != 0)
quality += " [" + rollAmount + "]";
// adds reroll price if the item
if (UtilitiesConfig.Identifications.INSTANCE.showRerollPrice && !item.isIdentified()) {
quality += GREEN + " [" + decimalFormat.format(item.getTier().getRerollPrice(item.getRequirements().getLevel(), rollAmount)) + EmeraldSymbols.E + "]";
}
newLore.add(quality);
if (item.getRestriction() != null)
newLore.add(RED + "Untradable Item");
// Merchant & dungeon purchase offers
if (wynntils.hasKey("purchaseInfo")) {
newLore.add(" ");
newLore.add(GOLD + "Price:");
NBTTagList purchaseInfo = wynntils.getTagList("purchaseInfo", 8);
for (NBTBase nbtBase : purchaseInfo) {
newLore.add(((NBTTagString) nbtBase).getString());
}
}
// Item lore
if (item.getLore() != null && !item.getLore().isEmpty()) {
if (wynntils.hasKey("purchaseInfo"))
newLore.add(" ");
newLore.addAll(McIf.mc().fontRenderer.listFormattedStringToWidth(DARK_GRAY + item.getLore(), 150));
}
// Special displayname
String specialDisplay = "";
if (hasNewId) {
specialDisplay = GOLD + " NEW";
} else if (idAmount > 0 && relativeTotal > 0) {
specialDisplay = " " + idType.getTitle(relativeTotal / (double) idAmount);
}
// check for item perfection
if (relativeTotal / idAmount >= 1d && idType == IdentificationType.PERCENTAGES && !hasNewId && UtilitiesConfig.Identifications.INSTANCE.rainbowPerfect) {
wynntils.setBoolean("isPerfect", true);
}
// check for 0% item
if (relativeTotal / idAmount == 0 && idType == IdentificationType.PERCENTAGES && !hasNewId && UtilitiesConfig.Identifications.INSTANCE.rainbowPerfect) {
wynntils.setBoolean("isDefective", true);
}
stack.setStackDisplayName(item.getTier().getTextColor() + item.getDisplayName() + specialDisplay);
// Applying lore
NBTTagCompound compound = nbt.getCompoundTag("display");
NBTTagList list = new NBTTagList();
newLore.forEach(c -> list.appendTag(new NBTTagString(c)));
compound.setTag("Lore", list);
nbt.setTag("wynntils", wynntils);
nbt.setTag("display", compound);
}
use of com.wynntils.core.framework.enums.SpellType in project Wynntils by Wynntils.
the class GearViewerUI method createLore.
private void createLore(ItemStack stack) {
String itemName = WebManager.getTranslatedItemName(getTextWithoutFormattingCodes(stack.getDisplayName())).replace("֎", "");
// can't create lore on crafted items
if (itemName.startsWith("Crafted")) {
stack.setStackDisplayName(DARK_AQUA + itemName);
return;
}
// disable viewing unidentified items
if (stack.getItem() == Items.STONE_SHOVEL && stack.getItemDamage() >= 1 && stack.getItemDamage() <= 6) {
stack.setStackDisplayName(ItemTier.fromBoxDamage(stack.getItemDamage()).getTextColor() + "Unidentified Item");
return;
}
// get item from name
if (WebManager.getItems().get(itemName) == null) {
// empty the lore if the item isn't recognized
ItemUtils.replaceLore(stack, new ArrayList<>());
return;
}
ItemProfile item = WebManager.getItems().get(itemName);
// attempt to parse item data
JsonObject data;
// remove extra unnecessary info
String rawLore = org.apache.commons.lang3.StringUtils.substringBeforeLast(ItemUtils.getStringLore(stack), "}") + "}";
try {
data = new JsonParser().parse(rawLore).getAsJsonObject();
} catch (JsonSyntaxException e) {
// invalid or empty data on item
data = new JsonObject();
}
List<String> itemLore = new ArrayList<>();
// attack speed
if (item.getAttackSpeed() != null) {
itemLore.add(item.getAttackSpeed().asLore());
itemLore.add(" ");
}
// damages
Map<String, String> damageTypes = item.getDamageTypes();
if (damageTypes.size() > 0) {
if (damageTypes.containsKey("neutral"))
itemLore.add(GOLD + "✣ Neutral Damage: " + damageTypes.get("neutral"));
if (damageTypes.containsKey("fire"))
itemLore.add(RED + "✹ Fire" + GRAY + " Damage: " + damageTypes.get("fire"));
if (damageTypes.containsKey("water"))
itemLore.add(AQUA + "❉ Water" + GRAY + " Damage: " + damageTypes.get("water"));
if (damageTypes.containsKey("air"))
itemLore.add(WHITE + "❋ Air" + GRAY + " Damage: " + damageTypes.get("air"));
if (damageTypes.containsKey("thunder"))
itemLore.add(YELLOW + "✦ Thunder" + GRAY + " Damage: " + damageTypes.get("thunder"));
if (damageTypes.containsKey("earth"))
itemLore.add(DARK_GREEN + "✤ Earth" + GRAY + " Damage: " + damageTypes.get("earth"));
itemLore.add(" ");
}
// defenses
Map<String, Integer> defenseTypes = item.getDefenseTypes();
if (defenseTypes.size() > 0) {
if (defenseTypes.containsKey("health"))
itemLore.add(DARK_RED + "❤ Health: " + (defenseTypes.get("health") > 0 ? "+" : "") + defenseTypes.get("health"));
if (defenseTypes.containsKey("fire"))
itemLore.add(RED + "✹ Fire" + GRAY + " Defence: " + (defenseTypes.get("fire") > 0 ? "+" : "") + defenseTypes.get("fire"));
if (defenseTypes.containsKey("water"))
itemLore.add(AQUA + "❉ Water" + GRAY + " Defence: " + (defenseTypes.get("water") > 0 ? "+" : "") + defenseTypes.get("water"));
if (defenseTypes.containsKey("air"))
itemLore.add(WHITE + "❋ Air" + GRAY + " Defence: " + (defenseTypes.get("air") > 0 ? "+" : "") + defenseTypes.get("air"));
if (defenseTypes.containsKey("thunder"))
itemLore.add(YELLOW + "✦ Thunder" + GRAY + " Defence: " + (defenseTypes.get("thunder") > 0 ? "+" : "") + defenseTypes.get("thunder"));
if (defenseTypes.containsKey("earth"))
itemLore.add(DARK_GREEN + "✤ Earth" + GRAY + " Defence: " + (defenseTypes.get("earth") > 0 ? "+" : "") + defenseTypes.get("earth"));
itemLore.add(" ");
}
// requirements
ItemRequirementsContainer requirements = item.getRequirements();
if (requirements.hasRequirements(item.getItemInfo().getType())) {
if (requirements.requiresQuest())
itemLore.add(GREEN + "✔ " + GRAY + "Quest Req: " + requirements.getQuest());
if (requirements.requiresClass(item.getItemInfo().getType()))
itemLore.add(GREEN + "✔ " + GRAY + "Class Req: " + requirements.getRealClass(item.getItemInfo().getType()).getDisplayName());
if (requirements.getLevel() != 0)
itemLore.add(GREEN + "✔ " + GRAY + "Combat Lv. Min: " + requirements.getLevel());
if (requirements.getStrength() != 0)
itemLore.add(GREEN + "✔ " + GRAY + "Strength Min: " + requirements.getStrength());
if (requirements.getAgility() != 0)
itemLore.add(GREEN + "✔ " + GRAY + "Agility Min: " + requirements.getAgility());
if (requirements.getDefense() != 0)
itemLore.add(GREEN + "✔ " + GRAY + "Defense Min: " + requirements.getDefense());
if (requirements.getIntelligence() != 0)
itemLore.add(GREEN + "✔ " + GRAY + "Intelligence Min: " + requirements.getIntelligence());
if (requirements.getDexterity() != 0)
itemLore.add(GREEN + "✔ " + GRAY + "Dexterity Min: " + requirements.getDexterity());
itemLore.add(" ");
}
// ids
if (data.has("identifications")) {
JsonArray ids = data.getAsJsonArray("identifications");
for (int i = 0; i < ids.size(); i++) {
JsonObject idInfo = ids.get(i).getAsJsonObject();
String id = idInfo.get("type").getAsString();
float pct = idInfo.get("percent").getAsInt() / 100F;
// get wynntils name from internal wynncraft name
String translatedId = WebManager.getIDFromInternal(id);
if (translatedId == null || !item.getStatuses().containsKey(translatedId))
continue;
// calculate value
IdentificationContainer idContainer = item.getStatuses().get(translatedId);
int value = (int) ((idContainer.isFixed()) ? idContainer.getBaseValue() : Math.round(idContainer.getBaseValue() * pct));
// account for mistaken rounding
if (value == 0)
value = 1;
boolean isInverted = IdentificationOrderer.INSTANCE.isInverted(translatedId);
// determine lore name
String longName = IdentificationContainer.getAsLongName(translatedId);
SpellType spell = SpellType.fromName(longName);
if (spell != null) {
ClassType requiredClass = item.getClassNeeded();
if (requiredClass != null) {
longName = spell.forOtherClass(requiredClass).getName() + " Spell Cost";
} else {
longName = spell.forOtherClass(PlayerInfo.get(CharacterData.class).getCurrentClass()).getGenericAndSpecificName() + " Cost";
}
}
// determine lore value
String lore;
if (isInverted)
lore = (value < 0 ? GREEN.toString() : value > 0 ? RED + "+" : GRAY.toString()) + value + idContainer.getType().getInGame(translatedId);
else
lore = (value < 0 ? RED.toString() : value > 0 ? GREEN + "+" : GRAY.toString()) + value + idContainer.getType().getInGame(translatedId);
// set stars
if ((!isInverted && value > 0) || (isInverted && value < 0)) {
if (pct > 1)
lore += DARK_GREEN + "*";
if (pct > 1.24)
lore += "*";
if (pct > 1.29)
lore += "*";
}
lore += " " + GRAY + longName;
itemLore.add(lore);
}
itemLore.add(" ");
}
// major ids
if (item.getMajorIds() != null && item.getMajorIds().size() > 0) {
for (MajorIdentification majorId : item.getMajorIds()) {
Stream.of(StringUtils.wrapTextBySize(majorId.asLore(), 150)).forEach(c -> itemLore.add(DARK_AQUA + c));
}
itemLore.add(" ");
}
// powders
if (item.getPowderAmount() > 0) {
int powderCount = 0;
String powderList = "";
if (data.has("powders")) {
JsonArray powders = data.getAsJsonArray("powders");
for (int i = 0; i < powders.size(); i++) {
powderCount++;
String type = powders.get(i).getAsJsonObject().get("type").getAsString();
switch(type) {
case "EARTH":
powderList += DARK_GREEN + "✤ ";
break;
case "THUNDER":
powderList += YELLOW + "✦ ";
break;
case "WATER":
powderList += AQUA + "❉ ";
break;
case "FIRE":
powderList += RED + "✹ ";
break;
case "AIR":
powderList += WHITE + "❋ ";
break;
}
}
}
String powderString = TextFormatting.GRAY + "[" + powderCount + "/" + item.getPowderAmount() + "] Powder Slots ";
if (powderCount > 0)
powderString += "[" + powderList.trim() + TextFormatting.GRAY + "]";
itemLore.add(powderString);
}
// tier & rerolls
String tierString = item.getTier().asLore();
if (data.has("identification_rolls") && data.get("identification_rolls").getAsInt() > 1)
tierString += " [" + data.get("identification_rolls").getAsInt() + "]";
itemLore.add(tierString);
// untradable
if (item.getRestriction() != null)
itemLore.add(RED + StringUtils.capitalizeFirst(item.getRestriction()) + " Item");
// item lore
if (item.getLore() != null && !item.getLore().isEmpty()) {
itemLore.addAll(McIf.mc().fontRenderer.listFormattedStringToWidth(DARK_GRAY + item.getLore(), 150));
}
ItemUtils.replaceLore(stack, itemLore);
stack.setStackDisplayName(item.getTier().getTextColor() + item.getDisplayName());
}
Aggregations