Extra display options for abilities in lore

This commit is contained in:
Jules 2023-10-14 23:41:28 +02:00
parent 4a38952310
commit c4ded8355c
26 changed files with 900 additions and 779 deletions

View File

@ -79,18 +79,16 @@ public class ConfigFile {
public void registerTemplateEdition(ItemReference ref) { public void registerTemplateEdition(ItemReference ref) {
/* // Saves the changes before asking for a template update
* saves the changes before asking for a template update
*/
save(); save();
/* /*
* goes for a template update once the change has been saved. this * Goes for a template update once the change has been saved. this
* simply unloads the currently saved template and reloads it * simply unloads the currently saved template and reloads it
*/ */
MMOItems.plugin.getTemplates().requestTemplateUpdate(ref.getType(), ref.getId()); MMOItems.plugin.getTemplates().requestTemplateUpdate(ref.getType(), ref.getId());
/* update the database UUID for the dynamic item updater /* Update the database UUID for the dynamic item updater
if (MMOItems.plugin.getUpdater().hasData(ref)) if (MMOItems.plugin.getUpdater().hasData(ref))
MMOItems.plugin.getUpdater().getData(ref).setUniqueId(UUID.randomUUID());*/ MMOItems.plugin.getUpdater().getData(ref).setUniqueId(UUID.randomUUID());*/
} }

View File

@ -88,7 +88,7 @@ public class Consumable extends UseItem {
/** /**
* This dynamically updates the item lore * This dynamically updates the item lore
*/ */
final String format = MythicLib.inst().parseColors(MMOItems.plugin.getLanguage().getStatFormat("max-consume")); final String format = MythicLib.inst().parseColors(ItemStats.MAX_CONSUME.getGeneralStatFormat());
final String old = format.replace("{value}", String.valueOf(usesLeft + 1)); final String old = format.replace("{value}", String.valueOf(usesLeft + 1));
final String replaced = format.replace("{value}", String.valueOf(usesLeft)); final String replaced = format.replace("{value}", String.valueOf(usesLeft));
ItemStack newItem = new LoreUpdate(nbtItem.toItem(), old, replaced).updateLore(); ItemStack newItem = new LoreUpdate(nbtItem.toItem(), old, replaced).updateLore();

View File

@ -243,7 +243,7 @@ public class DurabilityItem {
ItemStack item = nbtItem.toItem(); ItemStack item = nbtItem.toItem();
// Item lore update // Item lore update
final String format = MythicLib.inst().parseColors(MMOItems.plugin.getLanguage().getStatFormat("durability").replace("{max}", String.valueOf(maxDurability))); final String format = MythicLib.inst().parseColors(ItemStats.ITEM_DAMAGE.getGeneralStatFormat().replace("{max}", String.valueOf(maxDurability)));
final String old = format.replace("{current}", String.valueOf(initialDurability)); final String old = format.replace("{current}", String.valueOf(initialDurability));
final String replaced = format.replace("{current}", String.valueOf(durability)); final String replaced = format.replace("{current}", String.valueOf(durability));
return new LoreUpdate(item, old, replaced).updateLore(); return new LoreUpdate(item, old, replaced).updateLore();

View File

@ -11,6 +11,7 @@ import net.Indyuce.mmoitems.api.event.GenerateLoreEvent;
import net.Indyuce.mmoitems.api.event.ItemBuildEvent; import net.Indyuce.mmoitems.api.event.ItemBuildEvent;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate; import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.stat.data.MaterialData; import net.Indyuce.mmoitems.stat.data.MaterialData;
import net.Indyuce.mmoitems.stat.data.StringListData; import net.Indyuce.mmoitems.stat.data.StringListData;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
@ -203,10 +204,10 @@ public class ItemStackBuilder {
// Display gem stone lore hint thing // Display gem stone lore hint thing
if (builtMMOItem.getType() == Type.GEM_STONE) if (builtMMOItem.getType() == Type.GEM_STONE)
lore.insert("gem-stone-lore", ItemStat.translate("gem-stone-lore")); lore.insert("gem-stone-lore", Message.GEM_STONE_TAG.getUpdated());
// Display item type // Display item type
lore.insert("item-type", ItemStat.translate("item-type").replace("{type}", lore.insert("item-type", Message.ITEM_TYPE_TAG.getUpdated().replace("{type}",
builtMMOItem.getStats().contains(ItemStats.DISPLAYED_TYPE) ? builtMMOItem.getData(ItemStats.DISPLAYED_TYPE) builtMMOItem.getStats().contains(ItemStats.DISPLAYED_TYPE) ? builtMMOItem.getData(ItemStats.DISPLAYED_TYPE)
.toString() : builtMMOItem.getType().getName())); .toString() : builtMMOItem.getType().getName()));

View File

@ -16,6 +16,10 @@ public enum Message {
ITEM_ON_COOLDOWN("This item is on cooldown! Please wait #left# second#s#.", "item-cooldown"), ITEM_ON_COOLDOWN("This item is on cooldown! Please wait #left# second#s#.", "item-cooldown"),
NOT_ENOUGH_PERMS_COMMAND("You don't have enough permissions."), NOT_ENOUGH_PERMS_COMMAND("You don't have enough permissions."),
// Item lore tags
GEM_STONE_TAG("&8&l[&2&l*&8&l] &aDrag onto an item &7to apply!"),
ITEM_TYPE_TAG("&c{type}"),
// Item restrictions // Item restrictions
NOT_ENOUGH_LEVELS("You don't have enough levels to use this item!", "cant-use-item"), NOT_ENOUGH_LEVELS("You don't have enough levels to use this item!", "cant-use-item"),
SOULBOUND_RESTRICTION("This item is linked to another player, you can't use it!", "cant-use-item"), SOULBOUND_RESTRICTION("This item is linked to another player, you can't use it!", "cant-use-item"),

View File

@ -35,7 +35,7 @@ import java.util.logging.Level;
public class ConfigManager implements Reloadable { public class ConfigManager implements Reloadable {
// cached config files // cached config files
private ConfigFile loreFormat, stats, dynLore; private ConfigFile loreFormat, dynLore;
// Language // Language
private final Map<TriggerType, String> triggerTypeNames = new HashMap<>(); private final Map<TriggerType, String> triggerTypeNames = new HashMap<>();
@ -43,7 +43,6 @@ public class ConfigManager implements Reloadable {
// Cached config options // Cached config options
public boolean replaceMushroomDrops, worldGenEnabled, upgradeRequirementsCheck, keepSoulboundOnDeath, rerollOnItemUpdate, opStatsEnabled, disableRemovedItems; public boolean replaceMushroomDrops, worldGenEnabled, upgradeRequirementsCheck, keepSoulboundOnDeath, rerollOnItemUpdate, opStatsEnabled, disableRemovedItems;
public String abilitySplitter;
public double soulboundBaseDamage, soulboundPerLvlDamage, levelSpread; public double soulboundBaseDamage, soulboundPerLvlDamage, levelSpread;
public NumericStatFormula defaultItemCapacity; public NumericStatFormula defaultItemCapacity;
public ReforgeOptions revisionOptions, gemRevisionOptions, phatLootsOptions; public ReforgeOptions revisionOptions, gemRevisionOptions, phatLootsOptions;
@ -124,6 +123,11 @@ public class ConfigManager implements Reloadable {
} }
messages.save(); messages.save();
// LEGACY CODE
final ConfigurationSection statsConfig = new ConfigFile("stats").getConfig();
if (statsConfig.contains("gem-stone-lore")) Message.GEM_STONE_TAG.setCurrent(statsConfig.getString("gem-stone-lore"));
if (statsConfig.contains("item-type")) Message.ITEM_TYPE_TAG.setCurrent(statsConfig.getString("item-type"));
// Potion effects // Potion effects
final LanguageFile potionEffects = new LanguageFile("potion-effects"); final LanguageFile potionEffects = new LanguageFile("potion-effects");
for (PotionEffectType effect : PotionEffectType.values()) for (PotionEffectType effect : PotionEffectType.values())
@ -154,7 +158,7 @@ public class ConfigManager implements Reloadable {
MMOItems.plugin.reloadConfig(); MMOItems.plugin.reloadConfig();
loreFormat = new ConfigFile("/language", "lore-format"); loreFormat = new ConfigFile("/language", "lore-format");
stats = new ConfigFile("/language", "stats");
dynLore = new ConfigFile("/language", "dynamic-lore"); dynLore = new ConfigFile("/language", "dynamic-lore");
loadTranslations(); loadTranslations();
@ -166,7 +170,6 @@ public class ConfigManager implements Reloadable {
replaceMushroomDrops = MMOItems.plugin.getConfig().getBoolean("custom-blocks.replace-mushroom-drops"); replaceMushroomDrops = MMOItems.plugin.getConfig().getBoolean("custom-blocks.replace-mushroom-drops");
worldGenEnabled = MMOItems.plugin.getConfig().getBoolean("custom-blocks.enable-world-gen"); worldGenEnabled = MMOItems.plugin.getConfig().getBoolean("custom-blocks.enable-world-gen");
abilitySplitter = getStatFormat("ability-splitter");
soulboundBaseDamage = MMOItems.plugin.getConfig().getDouble("soulbound.damage.base"); soulboundBaseDamage = MMOItems.plugin.getConfig().getDouble("soulbound.damage.base");
soulboundPerLvlDamage = MMOItems.plugin.getConfig().getDouble("soulbound.damage.per-lvl"); soulboundPerLvlDamage = MMOItems.plugin.getConfig().getDouble("soulbound.damage.per-lvl");
upgradeRequirementsCheck = MMOItems.plugin.getConfig().getBoolean("item-upgrade-requirements-check"); upgradeRequirementsCheck = MMOItems.plugin.getConfig().getBoolean("item-upgrade-requirements-check");
@ -211,13 +214,18 @@ public class ConfigManager implements Reloadable {
* @return Can this block material be broken by tool mechanics * @return Can this block material be broken by tool mechanics
* like 'Bouncing Crack' * like 'Bouncing Crack'
*/ */
public boolean isBlacklisted(Material material) { public boolean isBlacklisted(@NotNull Material material) {
return MMOItems.plugin.getConfig().getStringList("block-blacklist").contains(material.name()); return MMOItems.plugin.getConfig().getStringList("block-blacklist").contains(material.name());
} }
/**
* @deprecated Will be removed in the future.
*/
@NotNull @NotNull
@Deprecated
public String getStatFormat(String path) { public String getStatFormat(String path) {
String found = stats.getConfig().getString(path); final ConfigurationSection config = new ConfigFile("/language", "stats").getConfig();
final String found = config.getString(path);
return found == null ? "<TranslationNotFound:" + path + ">" : found; return found == null ? "<TranslationNotFound:" + path + ">" : found;
} }

View File

@ -26,7 +26,6 @@ public class PluginUpdateManager {
*/ */
private final Map<Integer, PluginUpdate> updates = new HashMap<>(); private final Map<Integer, PluginUpdate> updates = new HashMap<>();
public PluginUpdateManager() { public PluginUpdateManager() {
register(new PluginUpdate(1, register(new PluginUpdate(1,
new String[]{"Applies a fix for skull textures values in 4.7.1.", "Texture values data storage changed in 4.7.1 due to the UUID change."}, new String[]{"Applies a fix for skull textures values in 4.7.1.", "Texture values data storage changed in 4.7.1 due to the UUID change."},

View File

@ -65,6 +65,17 @@ public class StatManager {
// Register custom stats // Register custom stats
loadCustom(); loadCustom();
// Load stat translation objects
final ConfigurationSection statOptions = new ConfigFile("/language", "stats").getConfig();
for (ItemStat stat : getAll())
try {
@Nullable Object object = statOptions.get(stat.getPath());
if (object == null) object = statOptions.get(stat.getLegacyTranslationPath());
stat.loadConfiguration(statOptions, object != null ? object : "<TranslationNotFound:" + stat.getPath() + ">");
} catch (RuntimeException exception) {
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not load options for stat '" + stat.getId() + "': " + exception.getMessage());
}
} }
/** /**

View File

@ -50,30 +50,94 @@ public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData>
return list; return list;
} }
private String generalFormat, modifierForEach, modifierSplitter, abilitySplitter;
private boolean legacyFormat, useAbilitySplitter;
private int modifiersPerLine;
@Deprecated
@Override
public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) {
// MI <7 config
if (configObject instanceof ConfigurationSection) {
legacyFormat = false;
final ConfigurationSection config = (ConfigurationSection) configObject;
generalFormat = config.getString("general-format");
modifierForEach = config.getString("modifier-foreach");
modifierSplitter = config.getString("modifier-splitter");
abilitySplitter = config.getString("ability-splitter.format");
useAbilitySplitter = config.getBoolean("ability-splitter.enabled");
modifiersPerLine = config.getInt("modifiers-per-line");
} else {
legacyFormat = true;
generalFormat = legacyLanguageFile.getString("ability-format");
modifierForEach = legacyLanguageFile.getString("ability-modifier");
abilitySplitter = legacyLanguageFile.getString("ability-splitter");
useAbilitySplitter = abilitySplitter != null && !abilitySplitter.isEmpty();
}
}
@Override @Override
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull AbilityListData data) { public void whenApplied(@NotNull ItemStackBuilder item, @NotNull AbilityListData data) {
// Modify Lore // Modify Lore
List<String> abilityLore = new ArrayList<>(); List<String> abilityLore = new ArrayList<>();
boolean splitter = !MMOItems.plugin.getLanguage().abilitySplitter.equals("");
String modifierFormat = ItemStat.translate("ability-modifier"), abilityFormat = ItemStat.translate("ability-format");
// DEPRECATED CODE which supports old versions of the stats.yml config
if (legacyFormat) {
data.getAbilities().forEach(ability -> { data.getAbilities().forEach(ability -> {
abilityLore.add(abilityFormat.replace("{trigger}", MMOItems.plugin.getLanguage().getCastingModeName(ability.getTrigger())).replace("{ability}", ability.getAbility().getName())); abilityLore.add(generalFormat
.replace("{trigger}", MMOItems.plugin.getLanguage().getCastingModeName(ability.getTrigger()))
.replace("{ability}", ability.getAbility().getName()));
for (String modifier : ability.getModifiers()) { for (String modifier : ability.getModifiers()) {
item.getLore().registerPlaceholder("ability_" + ability.getAbility().getHandler().getId().toLowerCase() + "_" + modifier, item.getLore().registerPlaceholder("ability_" + ability.getAbility().getHandler().getId().toLowerCase() + "_" + modifier,
MythicLib.plugin.getMMOConfig().decimals.format(ability.getParameter(modifier))); MythicLib.plugin.getMMOConfig().decimals.format(ability.getParameter(modifier)));
abilityLore.add(modifierFormat.replace("{modifier}", ability.getAbility().getParameterName(modifier)).replace("{value}", abilityLore.add(modifierForEach.replace("{modifier}", ability.getAbility().getParameterName(modifier)).replace("{value}",
MythicLib.plugin.getMMOConfig().decimals.format(ability.getParameter(modifier)))); MythicLib.plugin.getMMOConfig().decimals.format(ability.getParameter(modifier))));
} }
if (splitter) if (useAbilitySplitter)
abilityLore.add(MMOItems.plugin.getLanguage().abilitySplitter); abilityLore.add(abilitySplitter);
}); });
}
if (splitter && abilityLore.size() > 0) // Up to date code
else {
data.getAbilities().forEach(ability -> {
final StringBuilder builder = new StringBuilder(generalFormat
.replace("{trigger}", MMOItems.plugin.getLanguage().getCastingModeName(ability.getTrigger()))
.replace("{ability}", ability.getAbility().getName()));
boolean modifierAppened = false;
int lineCounter = 0;
for (String modifier : ability.getModifiers()) {
final String formattedValue = MythicLib.plugin.getMMOConfig().decimals.format(ability.getParameter(modifier));
item.getLore().registerPlaceholder("ability_" + ability.getAbility().getHandler().getId().toLowerCase() + "_" + modifier, formattedValue);
if (modifierAppened) builder.append(modifierSplitter);
builder.append(modifierForEach
.replace("{modifier}", ability.getAbility().getParameterName(modifier))
.replace("{value}", formattedValue));
modifierAppened = true;
lineCounter++;
if (modifiersPerLine > 0 && lineCounter >= modifiersPerLine) {
lineCounter = 0;
modifierAppened = false;
abilityLore.add(builder.toString());
builder.setLength(0);
}
}
if (modifierAppened) abilityLore.add(builder.toString());
if (useAbilitySplitter)
abilityLore.add(abilitySplitter);
});
}
if (useAbilitySplitter && abilityLore.size() > 0)
abilityLore.remove(abilityLore.size() - 1); abilityLore.remove(abilityLore.size() - 1);
// Modify tags // Modify tags
@ -81,6 +145,11 @@ public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData>
item.addItemTag(getAppliedNBT(data)); item.addItemTag(getAppliedNBT(data));
} }
@Override
public String getLegacyTranslationPath() {
return "ability-format";
}
@NotNull @NotNull
@Override @Override
public ArrayList<ItemTag> getAppliedNBT(@NotNull AbilityListData data) { public ArrayList<ItemTag> getAppliedNBT(@NotNull AbilityListData data) {
@ -90,7 +159,9 @@ public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData>
// Convert to JSON // Convert to JSON
JsonArray jsonArray = new JsonArray(); JsonArray jsonArray = new JsonArray();
for (AbilityData ab : data.getAbilities()) { jsonArray.add(ab.toJson()); } for (AbilityData ab : data.getAbilities()) {
jsonArray.add(ab.toJson());
}
// Put // Put
ret.add(new ItemTag(getNBTPath(), jsonArray.toString())); ret.add(new ItemTag(getNBTPath(), jsonArray.toString()));
@ -144,7 +215,7 @@ public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData>
@Override @Override
public void whenDisplayed(List<String> lore, Optional<RandomAbilityListData> statData) { public void whenDisplayed(List<String> lore, Optional<RandomAbilityListData> statData) {
lore.add(ChatColor.GRAY + "Current Abilities: " + ChatColor.GOLD lore.add(ChatColor.GRAY + "Current Abilities: " + ChatColor.GOLD
+ (statData.isPresent() ? ((RandomAbilityListData) statData.get()).getAbilities().size() : 0)); + (statData.isPresent() ? statData.get().getAbilities().size() : 0));
lore.add(""); lore.add("");
lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to edit the item abilities."); lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to edit the item abilities.");
} }
@ -164,7 +235,7 @@ public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData>
if (mmoitem.getNBT().hasTag(getNBTPath())) if (mmoitem.getNBT().hasTag(getNBTPath()))
relevantTags.add(ItemTag.getTagAtPath(getNBTPath(), mmoitem.getNBT(), SupportedNBTTagValues.STRING)); relevantTags.add(ItemTag.getTagAtPath(getNBTPath(), mmoitem.getNBT(), SupportedNBTTagValues.STRING));
AbilityListData data = (AbilityListData) getLoadedNBT(relevantTags); AbilityListData data = getLoadedNBT(relevantTags);
// Valid? // Valid?
if (data != null) { if (data != null) {

View File

@ -118,13 +118,13 @@ public class ArrowPotionEffects extends ItemStat<RandomPotionEffectListData, Pot
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull PotionEffectListData data) { public void whenApplied(@NotNull ItemStackBuilder item, @NotNull PotionEffectListData data) {
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
String permEffectFormat = ItemStat.translate("arrow-potion-effects"); String permEffectFormat = getGeneralStatFormat();
data.getEffects().forEach(effect -> { data.getEffects().forEach(effect -> {
lore.add(permEffectFormat.replace("{effect}", MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType()) lore.add(permEffectFormat.replace("{effect}", MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType())
+ " " + MMOUtils.intToRoman(effect.getLevel()) + "(" + MythicLib.plugin.getMMOConfig().decimal.format(effect.getDuration()) + "s)")); + " " + MMOUtils.intToRoman(effect.getLevel()) + "(" + MythicLib.plugin.getMMOConfig().decimal.format(effect.getDuration()) + "s)"));
}); });
item.getLore().insert("arrow-potion-effects", lore); item.getLore().insert(getPath(), lore);
// Add tags // Add tags
item.addItemTag(getAppliedNBT(data)); item.addItemTag(getAppliedNBT(data));

View File

@ -124,14 +124,18 @@ public class Commands extends ItemStat<CommandListData, CommandListData> {
// Addlore // Addlore
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
String commandFormat = ItemStat.translate("command"); String commandFormat = getGeneralStatFormat();
((CommandListData) data).getCommands().forEach(command -> { data.getCommands().forEach(command -> lore.add(commandFormat
.replace("{format}", "/" + command.getCommand())
lore.add(commandFormat.replace("{format}", "/" + command.getCommand()).replace("{cooldown}", String.valueOf(command.getDelay()))); .replace("{cooldown}", String.valueOf(command.getDelay()))));
});
item.getLore().insert("commands", lore); item.getLore().insert("commands", lore);
} }
@Override
public String getLegacyTranslationPath() {
return "command";
}
@NotNull @NotNull
@Override @Override
public ArrayList<ItemTag> getAppliedNBT(@NotNull CommandListData data) { public ArrayList<ItemTag> getAppliedNBT(@NotNull CommandListData data) {

View File

@ -109,7 +109,7 @@ public class Effects extends ItemStat<RandomPotionEffectListData, PotionEffectLi
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull PotionEffectListData data) { public void whenApplied(@NotNull ItemStackBuilder item, @NotNull PotionEffectListData data) {
// Process Lore // Process Lore
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
String effectFormat = ItemStat.translate("effect"); String effectFormat = getGeneralStatFormat();
data.getEffects().forEach(effect -> lore.add(effectFormat data.getEffects().forEach(effect -> lore.add(effectFormat
.replace("{effect}", .replace("{effect}",
MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType()) MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType())
@ -121,6 +121,11 @@ public class Effects extends ItemStat<RandomPotionEffectListData, PotionEffectLi
item.addItemTag(getAppliedNBT(data)); item.addItemTag(getAppliedNBT(data));
} }
@Override
public String getLegacyTranslationPath() {
return "effect";
}
@NotNull @NotNull
@Override @Override
public ArrayList<ItemTag> getAppliedNBT(@NotNull PotionEffectListData data) { public ArrayList<ItemTag> getAppliedNBT(@NotNull PotionEffectListData data) {

View File

@ -29,9 +29,7 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Optional;
public class Elements extends ItemStat<RandomElementListData, ElementListData> implements Previewable<RandomElementListData, ElementListData> { public class Elements extends ItemStat<RandomElementListData, ElementListData> implements Previewable<RandomElementListData, ElementListData> {
public Elements() { public Elements() {
@ -77,7 +75,7 @@ public class Elements extends ItemStat<RandomElementListData, ElementListData> i
inv.registerTemplateEdition(); inv.registerTemplateEdition();
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + MMOUtils.caseOnWords(elementPath.replace(".", " ")) + ChatColor.GRAY inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + MMOUtils.caseOnWords(elementPath.replace(".", " ")) + ChatColor.GRAY
+ " successfully changed to " + ChatColor.GOLD + formula.toString() + ChatColor.GRAY + "."); + " successfully changed to " + ChatColor.GOLD + formula + ChatColor.GRAY + ".");
} }
@Override @Override
@ -102,6 +100,32 @@ public class Elements extends ItemStat<RandomElementListData, ElementListData> i
return new ElementListData(); return new ElementListData();
} }
private Map<ElementStatType, String> statFormat = new HashMap<>();
@Override
public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) {
// LEGACY CODE
if (configObject instanceof String) {
for (ElementStatType statType : ElementStatType.values())
statFormat.put(statType, legacyLanguageFile.getString("elemental-" + statType.lowerCaseName(), "<TranslationNotFound:" + statType.name().toLowerCase() + ">"));
}
// Up-to-date code
else {
Validate.isTrue(configObject instanceof ConfigurationSection, "Must be a config section");
final ConfigurationSection config = (ConfigurationSection) configObject;
for (ElementStatType statType : ElementStatType.values())
statFormat.put(statType, config.getString(statType.lowerCaseName(), "<TranslationNotFound:" + statType.lowerCaseName() + ">"));
}
}
@Override
public String getLegacyTranslationPath() {
// Arbitrary
return "elemental-damage";
}
@Override @Override
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull ElementListData data) { public void whenApplied(@NotNull ItemStackBuilder item, @NotNull ElementListData data) {
@ -109,7 +133,7 @@ public class Elements extends ItemStat<RandomElementListData, ElementListData> i
// Write Lore // Write Lore
for (Pair<Element, ElementStatType> pair : data.getKeys()) { for (Pair<Element, ElementStatType> pair : data.getKeys()) {
final String format = ItemStat.translate("elemental-" + pair.getValue().lowerCaseName()) final String format = statFormat.get(pair.getValue())
.replace("{color}", pair.getKey().getColor()) .replace("{color}", pair.getKey().getColor())
.replace("{icon}", pair.getKey().getLoreIcon()) .replace("{icon}", pair.getKey().getLoreIcon())
.replace("{element}", pair.getKey().getName()); .replace("{element}", pair.getKey().getName());
@ -183,6 +207,8 @@ public class Elements extends ItemStat<RandomElementListData, ElementListData> i
Validate.isTrue(currentData instanceof ElementListData, "Current Data is not ElementListData"); Validate.isTrue(currentData instanceof ElementListData, "Current Data is not ElementListData");
Validate.isTrue(templateData instanceof RandomElementListData, "Template Data is not RandomElementListData"); Validate.isTrue(templateData instanceof RandomElementListData, "Template Data is not RandomElementListData");
List<String> elementLore = new ArrayList<>();
// Examine every element stat possible // Examine every element stat possible
for (Element element : Element.values()) for (Element element : Element.values())
for (ElementStatType statType : ElementStatType.values()) { for (ElementStatType statType : ElementStatType.values()) {
@ -197,20 +223,20 @@ public class Elements extends ItemStat<RandomElementListData, ElementListData> i
if (techMinimum != 0 || techMaximum != 0) { if (techMinimum != 0 || techMaximum != 0) {
// Get path // Get path
String path = element.getId().toLowerCase() + "-" + statType.name().toLowerCase().replace("_", "-");
String builtRange; String builtRange;
if (SilentNumbers.round(techMinimum, 2) == SilentNumbers.round(techMaximum, 2)) { if (SilentNumbers.round(techMinimum, 2) == SilentNumbers.round(techMaximum, 2)) {
builtRange = DoubleStat.formatPath(statType.getConcatenatedTagPath(element), ItemStat.translate(path), true, techMinimum); builtRange = DoubleStat.formatPath(statType.getConcatenatedTagPath(element), statFormat.get(statType), true, techMinimum);
} else { } else {
builtRange = DoubleStat.formatPath(statType.getConcatenatedTagPath(element), ItemStat.translate(path), true, techMinimum, techMaximum); builtRange = DoubleStat.formatPath(statType.getConcatenatedTagPath(element), statFormat.get(statType), true, techMinimum, techMaximum);
} }
// Just display normally // Just display normally
item.getLore().insert(path, builtRange); elementLore.add(builtRange);
} }
} }
if (!elementLore.isEmpty()) item.getLore().insert(getPath(), elementLore);
// Add tags // Add tags
item.addItemTag(getAppliedNBT(currentData)); item.addItemTag(getAppliedNBT(currentData));
} }

View File

@ -8,6 +8,7 @@ import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
@ -44,6 +45,31 @@ public class GemSockets extends ItemStat<GemSocketsData, GemSocketsData> {
return new GemSocketsData((List<String>) object); return new GemSocketsData((List<String>) object);
} }
private String emptyGemSocketFormat, filledGemSocketFormat;
@Override
public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) {
// LEGACY CODE
if (configObject instanceof String) {
emptyGemSocketFormat = legacyLanguageFile.getString("empty-gem-socket");
filledGemSocketFormat = legacyLanguageFile.getString("filled-gem-socket");
}
// Up-to-date code
else {
Validate.isTrue(configObject instanceof ConfigurationSection, "Must be a config section");
final ConfigurationSection config = (ConfigurationSection) configObject;
emptyGemSocketFormat = config.getString("empty");
filledGemSocketFormat = config.getString("filled");
}
}
@Override
public String getLegacyTranslationPath() {
return "empty-gem-socket";
}
@Override @Override
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull GemSocketsData sockets) { public void whenApplied(@NotNull ItemStackBuilder item, @NotNull GemSocketsData sockets) {
@ -51,7 +77,6 @@ public class GemSockets extends ItemStat<GemSocketsData, GemSocketsData> {
item.addItemTag(getAppliedNBT(sockets)); item.addItemTag(getAppliedNBT(sockets));
// Edit Lore // Edit Lore
String empty = ItemStat.translate("empty-gem-socket"), filled = ItemStat.translate("filled-gem-socket");
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
for (GemstoneData gem : sockets.getGemstones()) { for (GemstoneData gem : sockets.getGemstones()) {
String gemName = gem.getName(); String gemName = gem.getName();
@ -73,9 +98,9 @@ public class GemSockets extends ItemStat<GemSocketsData, GemSocketsData> {
} }
} }
lore.add(filled.replace("{name}", gemName)); lore.add(filledGemSocketFormat.replace("{name}", gemName));
} }
sockets.getEmptySlots().forEach(slot -> lore.add(empty.replace("{name}", slot))); sockets.getEmptySlots().forEach(slot -> lore.add(emptyGemSocketFormat.replace("{name}", slot)));
item.getLore().insert("gem-stones", lore); item.getLore().insert("gem-stones", lore);
} }
@ -92,11 +117,11 @@ public class GemSockets extends ItemStat<GemSocketsData, GemSocketsData> {
} }
@Override @Override
@NotNull public String getNBTPath() { @NotNull
public String getNBTPath() {
return "MMOITEMS_GEM_STONES"; return "MMOITEMS_GEM_STONES";
} }
@Override @Override
public void whenLoaded(@NotNull ReadMMOItem mmoitem) { public void whenLoaded(@NotNull ReadMMOItem mmoitem) {
@ -109,7 +134,9 @@ public class GemSockets extends ItemStat<GemSocketsData, GemSocketsData> {
StatData data = getLoadedNBT(relevantTags); StatData data = getLoadedNBT(relevantTags);
// Valid? // Valid?
if (data != null) { mmoitem.setData(this, data); } if (data != null) {
mmoitem.setData(this, data);
}
} }
@Nullable @Nullable

View File

@ -61,4 +61,9 @@ public class ItemDamage extends DoubleStat implements GemStoneStat {
@Nullable @Nullable
@Override @Override
public DoubleData getLoadedNBT(@NotNull ArrayList<ItemTag> storedTags) { return null; } public DoubleData getLoadedNBT(@NotNull ArrayList<ItemTag> storedTags) { return null; }
@Override
public String getLegacyTranslationPath() {
return "durability";
}
} }

View File

@ -27,7 +27,7 @@ public class ItemTierStat extends StringStat implements GemStoneStat {
ItemTier tier = MMOItems.plugin.getTiers().get(path); ItemTier tier = MMOItems.plugin.getTiers().get(path);
item.addItemTag(new ItemTag("MMOITEMS_TIER", path)); item.addItemTag(new ItemTag("MMOITEMS_TIER", path));
item.getLore().insert("tier", MMOItems.plugin.getLanguage().getStatFormat(getPath()).replace("{value}", tier.getName())); item.getLore().insert(getPath(), getGeneralStatFormat().replace("{value}", tier.getName()));
} }
@Override @Override
@ -35,7 +35,7 @@ public class ItemTierStat extends StringStat implements GemStoneStat {
String format = message.toUpperCase().replace(" ", "_").replace("-", "_"); String format = message.toUpperCase().replace(" ", "_").replace("-", "_");
Validate.isTrue(MMOItems.plugin.getTiers().has(format), "Couldn't find the tier called '" + format + "'."); Validate.isTrue(MMOItems.plugin.getTiers().has(format), "Couldn't find the tier called '" + format + "'.");
inv.getEditedSection().set("tier", format); inv.getEditedSection().set(getPath(), format);
inv.registerTemplateEdition(); inv.registerTemplateEdition();
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Tier successfully changed to " + format + "."); inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Tier successfully changed to " + format + ".");
} }

View File

@ -19,7 +19,7 @@ public class MaxConsume extends DoubleStat {
item.addItemTag(new ItemTag(getNBTPath(), left)); item.addItemTag(new ItemTag(getNBTPath(), left));
String format = MMOItems.plugin.getLanguage().getStatFormat("max-consume").replace("{value}", String.valueOf(left)); String format = getGeneralStatFormat().replace("{value}", String.valueOf(left));
item.getLore().insert("max-consume", format); item.getLore().insert(getPath(), format);
} }
} }

View File

@ -3,7 +3,6 @@ package net.Indyuce.mmoitems.stat;
import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.player.RPGPlayer; import net.Indyuce.mmoitems.api.player.RPGPlayer;
@ -18,6 +17,7 @@ import net.Indyuce.mmoitems.stat.type.Upgradable;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.configuration.ConfigurationSection;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
@ -35,6 +35,12 @@ public class MaximumDurability extends DoubleStat implements ItemRestriction, Ge
whenApplied(item, currentData); whenApplied(item, currentData);
} }
@Override
public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) {
generalStatFormat = legacyLanguageFile.getString("item-damage");
if (generalStatFormat == null) generalStatFormat = legacyLanguageFile.getString("durability");
}
@Override @Override
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull DoubleData data) { public void whenApplied(@NotNull ItemStackBuilder item, @NotNull DoubleData data) {
@ -44,7 +50,7 @@ public class MaximumDurability extends DoubleStat implements ItemRestriction, Ge
item.addItemTag(new ItemTag(getNBTPath(), max)); item.addItemTag(new ItemTag(getNBTPath(), max));
// Display durability in lore here. // Display durability in lore here.
String format = MMOItems.plugin.getLanguage().getStatFormat("durability").replace("{max}", String.valueOf(max)).replace("{current}", String.valueOf(current)); String format = getGeneralStatFormat().replace("{max}", String.valueOf(max)).replace("{current}", String.valueOf(current));
item.getLore().insert("durability", format); item.getLore().insert("durability", format);
} }

View File

@ -128,10 +128,10 @@ public class PermanentEffects extends ItemStat<RandomPotionEffectListData, Potio
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull PotionEffectListData data) { public void whenApplied(@NotNull ItemStackBuilder item, @NotNull PotionEffectListData data) {
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
String permEffectFormat = ItemStat.translate("perm-effect"); String permEffectFormat = getGeneralStatFormat();
((PotionEffectListData) data).getEffects().forEach(effect -> { data.getEffects().forEach(effect -> lore.add(permEffectFormat
lore.add(permEffectFormat.replace("{effect}", MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType()) + " " + MMOUtils.intToRoman(effect.getLevel()))); .replace("{effect}", MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType())
}); + " " + MMOUtils.intToRoman(effect.getLevel()))));
item.getLore().insert("perm-effects", lore); item.getLore().insert("perm-effects", lore);
@ -139,6 +139,11 @@ public class PermanentEffects extends ItemStat<RandomPotionEffectListData, Potio
item.addItemTag(getAppliedNBT(data)); item.addItemTag(getAppliedNBT(data));
} }
@Override
public String getLegacyTranslationPath() {
return "perm-effect";
}
@NotNull @NotNull
@Override @Override
public ArrayList<ItemTag> getAppliedNBT(@NotNull PotionEffectListData data) { public ArrayList<ItemTag> getAppliedNBT(@NotNull PotionEffectListData data) {
@ -172,7 +177,9 @@ public class PermanentEffects extends ItemStat<RandomPotionEffectListData, Potio
StatData data = getLoadedNBT(rTag); StatData data = getLoadedNBT(rTag);
// Add data, if valid // Add data, if valid
if (data != null) { mmoitem.setData(this, data); } if (data != null) {
mmoitem.setData(this, data);
}
} }
@Nullable @Nullable

View File

@ -41,7 +41,7 @@ public class RequiredLevel extends DoubleStat implements ItemRestriction {
// Lore Management // Lore Management
int lvl = (int) data.getValue(); int lvl = (int) data.getValue();
item.getLore().insert("required-level", formatNumericStat(lvl, "{value}", String.valueOf(lvl))); item.getLore().insert(getPath(), formatNumericStat(lvl, "{value}", String.valueOf(lvl)));
// Insert NBT // Insert NBT
item.addItemTag(getAppliedNBT(data)); item.addItemTag(getAppliedNBT(data));
@ -51,8 +51,8 @@ public class RequiredLevel extends DoubleStat implements ItemRestriction {
public void whenPreviewed(@NotNull ItemStackBuilder item, @NotNull DoubleData currentData, @NotNull NumericStatFormula templateData) throws IllegalArgumentException { public void whenPreviewed(@NotNull ItemStackBuilder item, @NotNull DoubleData currentData, @NotNull NumericStatFormula templateData) throws IllegalArgumentException {
// Get Value // Get Value
double techMinimum = ((NumericStatFormula) templateData).calculate(0, -2.5); double techMinimum = templateData.calculate(0, -2.5);
double techMaximum = ((NumericStatFormula) templateData).calculate(0, 2.5); double techMaximum = templateData.calculate(0, 2.5);
// Cancel if it its NEGATIVE and this doesn't support negative stats. // Cancel if it its NEGATIVE and this doesn't support negative stats.
if (techMaximum < 0 && !handleNegativeStats()) { if (techMaximum < 0 && !handleNegativeStats()) {
@ -61,11 +61,11 @@ public class RequiredLevel extends DoubleStat implements ItemRestriction {
if (techMinimum < 0 && !handleNegativeStats()) { if (techMinimum < 0 && !handleNegativeStats()) {
techMinimum = 0; techMinimum = 0;
} }
if (techMinimum < ((NumericStatFormula) templateData).getBase() - ((NumericStatFormula) templateData).getMaxSpread()) { if (techMinimum < templateData.getBase() - templateData.getMaxSpread()) {
techMinimum = ((NumericStatFormula) templateData).getBase() - ((NumericStatFormula) templateData).getMaxSpread(); techMinimum = templateData.getBase() - templateData.getMaxSpread();
} }
if (techMaximum > ((NumericStatFormula) templateData).getBase() + ((NumericStatFormula) templateData).getMaxSpread()) { if (techMaximum > templateData.getBase() + templateData.getMaxSpread()) {
techMaximum = ((NumericStatFormula) templateData).getBase() + ((NumericStatFormula) templateData).getMaxSpread(); techMaximum = templateData.getBase() + templateData.getMaxSpread();
} }
// Add NBT Path // Add NBT Path
@ -82,7 +82,7 @@ public class RequiredLevel extends DoubleStat implements ItemRestriction {
} }
// Just display normally // Just display normally
item.getLore().insert("required-level", formatNumericStat(techMinimum, "{value}", builtRange)); item.getLore().insert(getPath(), formatNumericStat(techMinimum, "{value}", builtRange));
} }
} }
@ -92,7 +92,7 @@ public class RequiredLevel extends DoubleStat implements ItemRestriction {
// Make and bake // Make and bake
ArrayList<ItemTag> ret = new ArrayList<>(); ArrayList<ItemTag> ret = new ArrayList<>();
ret.add(new ItemTag(getNBTPath(), ((DoubleData) data).getValue())); ret.add(new ItemTag(getNBTPath(), data.getValue()));
return ret; return ret;
} }

View File

@ -68,7 +68,7 @@ public class UpgradeStat extends ItemStat<UpgradeData, UpgradeData> implements C
// Show in lore // Show in lore
if (data.getMaxUpgrades() > 0) if (data.getMaxUpgrades() > 0)
item.getLore().insert(getPath(), item.getLore().insert(getPath(),
MMOItems.plugin.getLanguage().getStatFormat(getPath()).replace("{value}", String.valueOf(data.getMaxUpgrades()))); getGeneralStatFormat().replace("{value}", String.valueOf(data.getMaxUpgrades())));
} }
@NotNull @NotNull

View File

@ -52,7 +52,7 @@ public class BooleanStat extends ItemStat<RandomBooleanData, BooleanData> {
item.addItemTag(getAppliedNBT(data)); item.addItemTag(getAppliedNBT(data));
// Show in lore // Show in lore
item.getLore().insert(getPath(), MMOItems.plugin.getLanguage().getStatFormat(getPath())); item.getLore().insert(getPath(), getGeneralStatFormat());
} }
} }

View File

@ -9,6 +9,7 @@ import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.stat.data.random.RandomStatData; import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.data.type.StatData;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -148,6 +149,26 @@ public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData>
*/ */
public abstract void whenDisplayed(List<String> lore, Optional<R> statData); public abstract void whenDisplayed(List<String> lore, Optional<R> statData);
protected String generalStatFormat;
@Deprecated
public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) {
loadConfiguration(configObject);
}
public void loadConfiguration(@NotNull Object configObject) {
generalStatFormat = configObject.toString();
}
@Deprecated
public String getLegacyTranslationPath() {
return getPath();
}
public String getGeneralStatFormat() {
return generalStatFormat;
}
@NotNull @NotNull
public String getName() { public String getName() {
return name; return name;
@ -228,10 +249,9 @@ public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData>
} }
public String formatNumericStat(double value, String... replace) { public String formatNumericStat(double value, String... replace) {
String format = MMOItems.plugin.getLanguage().getStatFormat(getPath()).replace("<plus>", value > 0 ? "+" : ""); String format = getGeneralStatFormat().replace("<plus>", value > 0 ? "+" : "");
for (int j = 0; j < replace.length; j += 2) { for (int j = 0; j < replace.length; j += 2)
format = format.replace(replace[j], replace[j + 1]); format = format.replace(replace[j], replace[j + 1]);
}
return format; return format;
} }
@ -248,9 +268,9 @@ public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData>
return Objects.hash(id); return Objects.hash(id);
} }
@Deprecated
public static String translate(String path) { public static String translate(String path) {
String str = MMOItems.plugin.getLanguage().getStatFormat(path); return MMOItems.plugin.getLanguage().getStatFormat(path);
return str == null ? "<TranslationNotFound:" + path + ">" : str;
} }
/** /**

View File

@ -39,8 +39,8 @@ public abstract class RequiredLevelStat extends DoubleStat implements ItemRestri
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull DoubleData data) { public void whenApplied(@NotNull ItemStackBuilder item, @NotNull DoubleData data) {
// Lore Management // Lore Management
int lvl = (int) ((DoubleData) data).getValue(); int lvl = (int) data.getValue();
String format = MMOItems.plugin.getLanguage().getStatFormat(getPath()).replace("{value}", String.valueOf(lvl)); String format = getGeneralStatFormat().replace("{value}", String.valueOf(lvl));
item.getLore().insert(getPath(), format); item.getLore().insert(getPath(), format);
// Insert NBT // Insert NBT

View File

@ -42,90 +42,14 @@ public class StringListStat extends ItemStat<StringListData, StringListData> {
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull StringListData data) { public void whenApplied(@NotNull ItemStackBuilder item, @NotNull StringListData data) {
// Empty stuff // Empty stuff
if (!(data instanceof StringListData)) { return; } if (!(data instanceof StringListData)) return;
if (data.getList().size() == 0) { return; } if (data.getList().size() == 0) return;
// Chop // Chop
final String joined = String.join(", ", data.getList()); final String joined = String.join(", ", data.getList());
final String format = MMOItems.plugin.getLanguage().getStatFormat(getPath()); final String format = getGeneralStatFormat();
final String finalStr = format.replace("{value}", joined); final String finalStr = format.replace("{value}", joined);
/*
// Identify colour
StringBuilder col = new StringBuilder(""); int pnd = format.indexOf('#');
if (pnd > 0) {
// Everything before thay pound
String input = format.substring(0, pnd);
int length = input.length();
for(int index = length - 1; index > -1; --index) {
// Observe char
char section = input.charAt(index);
boolean isSection = (section == '\u00a7' || section == '&');
boolean isAngle = (section == '<');
// Is there at least one char, as for it to be a color code
if (isSection && index < (length - 1)) {
// Observe next character
char c = input.charAt(index + 1);
ChatColor color = ChatColor.getByChar(c);
// Was it a color code?
if (color != null) {
// That's our color
col.insert(0, color.toString());
// If its a reset or a color character, that's the end
if (color.isColor() || color == ChatColor.RESET) {
break;
}
}
// If there is at least 10 chars, as for it to complete HEX######>
} else if(isAngle && index < (length - 10)) {
// Observe tenth characters
char aC = input.charAt(index + 10);
// Closing bracket
if (aC == '>') {
// Observe hex
char lH = input.charAt(index + 1);
char lE = input.charAt(index + 2);
char lX = input.charAt(index + 3);
if (lH == 'H' && lE == 'E' && lX == 'X') {
// Get hex
char c1 = input.charAt(index + 4);
char c2 = input.charAt(index + 5);
char c3 = input.charAt(index + 6);
char c4 = input.charAt(index + 7);
char c5 = input.charAt(index + 8);
char c6 = input.charAt(index + 9);
col.insert(0, '>')
.insert(0, c6)
.insert(0, c5)
.insert(0, c4)
.insert(0, c3)
.insert(0, c2)
.insert(0, c1)
.insert(0, "<HEX");
// Um yes that qualifies as a color code
break;
}
}
}
}
} */
// Display in lore // Display in lore
// item.getLore().insert(getPath(), SilentNumbers.chop(finalStr, 50, col.toString())); // item.getLore().insert(getPath(), SilentNumbers.chop(finalStr, 50, col.toString()));
item.getLore().insert(getPath(), finalStr); item.getLore().insert(getPath(), finalStr);
@ -140,7 +64,7 @@ public class StringListStat extends ItemStat<StringListData, StringListData> {
JsonArray array = new JsonArray(); JsonArray array = new JsonArray();
// For every list entry // For every list entry
for (String str : ((StringListData) data).getList()) { for (String str : data.getList()) {
// Add to the array as-is // Add to the array as-is
array.add(str); array.add(str);
@ -196,7 +120,9 @@ public class StringListStat extends ItemStat<StringListData, StringListData> {
StatData data = getLoadedNBT(relevantTags); StatData data = getLoadedNBT(relevantTags);
// Valid? // Valid?
if (data != null) { mmoitem.setData(this, data); } if (data != null) {
mmoitem.setData(this, data);
}
} }
@Nullable @Nullable

View File

@ -30,10 +30,14 @@ physical-damage: '&3 &7■ Physical Damage: &f<plus>{value}%'
projectile-damage: '&3 &7■ Projectile Damage: &f<plus>{value}%' projectile-damage: '&3 &7■ Projectile Damage: &f<plus>{value}%'
faction-damage-undead: '&3 &7■ Undead Faction Damage: &f<plus>{value}%' faction-damage-undead: '&3 &7■ Undead Faction Damage: &f<plus>{value}%'
# Abilities # Abilities (changed in MI 6.9.5)
ability-format: '&a>&8| &7{trigger} &8|&e|&8| &7&l{ability}' ability:
ability-modifier: ' &3>&8|&7 {modifier}&8: &f{value}' general-format: "&f䀐 &7{trigger} &8|&e|&8| &7&l{ability}\n"
ability-splitter: '&8' modifier-foreach: "&7{modifier}&8: &f{value}"
modifier-splitter: " &8&l|&7 "
ability-splitter:
enabled: true
format: ''
# Armor Stats # Armor Stats
block-power: '&3 &7■ Block Power: &f<plus>{value}%' block-power: '&3 &7■ Block Power: &f<plus>{value}%'
@ -78,8 +82,8 @@ additional-experience-smithing: '&7■ Additional Smithing Experience: &f<plus>{
additional-experience-woodcutting: '&7■ Additional Woodcutting Experience: &f<plus>{value}%' additional-experience-woodcutting: '&7■ Additional Woodcutting Experience: &f<plus>{value}%'
# Extra Options # Extra Options
perm-effect: '&3 &7■ Permanent &f{effect}' perm-effects: '&3 &7■ Permanent &f{effect}'
command: '&3 &7■ Command: &f{format} &3 &7(&f{cooldown}&3 &7s)' commands: '&3 &7■ Command: &f{format} &3 &7(&f{cooldown}&3 &7s)'
item-cooldown: '&3 &7■ &f{value}&3 &7s Cooldown' item-cooldown: '&3 &7■ &f{value}&3 &7s Cooldown'
arrow-potion-effects: '&3 &7■ Arrow Effect: &f{effect}' arrow-potion-effects: '&3 &7■ Arrow Effect: &f{effect}'
@ -89,7 +93,7 @@ restore-food: '&3 &7■ Restores &f{value} &7Food'
restore-saturation: '&3 &7■ Restores &f{value} &7Saturation' restore-saturation: '&3 &7■ Restores &f{value} &7Saturation'
restore-mana: '&3 &7■ Restores &f{value} &7Mana' restore-mana: '&3 &7■ Restores &f{value} &7Mana'
restore-stamina: '&3 &7■ Restores &f{value} &7Stamina' restore-stamina: '&3 &7■ Restores &f{value} &7Stamina'
effect: '&3 &7■ Grants &f{effect} &7for &f{duration} &7s' effects: '&3 &7■ Grants &f{effect} &7for &f{duration} &7s'
repair: '&3 &7■ Repair: &f{value}' repair: '&3 &7■ Repair: &f{value}'
repair-percent: '&3 &7■ Repair: &f{value}%' repair-percent: '&3 &7■ Repair: &f{value}%'
can-identify: '&3 &7■ Can identify items.' can-identify: '&3 &7■ Can identify items.'
@ -99,10 +103,9 @@ success-rate: '&3 &7■ Success Rate: &a&l{value}%'
max-consume: '&3 &7■ &f{value} &7Uses Left' max-consume: '&3 &7■ &f{value} &7Uses Left'
# Gem Stones # Gem Stones
gem-sockets:
empty-gem-socket: '&a◆ Empty {name} Gem Socket' empty-gem-socket: '&a◆ Empty {name} Gem Socket'
filled-gem-socket: '&a◆ {name}' filled-gem-socket: '&a◆ {name}'
when-applied: '&aWhen Applied:'
gem-stone-lore: '&8&l[&2&l*&8&l] &aDrag onto an item &7to apply!'
# Soulbound # Soulbound
soulbinding-chance: '&3 &7■ Has a &a{value}% &7chance to bind your item.' soulbinding-chance: '&3 &7■ Has a &a{value}% &7chance to bind your item.'
@ -113,10 +116,9 @@ soulbound-level: '&3 &7■ Level &e{value} &7Soulbound'
autosmelt: '&3 &7■ &fAutosmelt' autosmelt: '&3 &7■ &fAutosmelt'
bouncing-crack: '&3 &7■ &fBouncing Crack' bouncing-crack: '&3 &7■ &fBouncing Crack'
pickaxe-power: '&3 &7■ &fPickaxe Power: &a{value}' pickaxe-power: '&3 &7■ &fPickaxe Power: &a{value}'
durability: '&7Durability: {current} / {max}' item-damage: '&7Durability: {current} / {max}'
# General # General
item-type: '&c{type}'
tier: '&3 &7Tier: {value}' tier: '&3 &7Tier: {value}'
required-class: '&3 &7{value} Item' required-class: '&3 &7{value} Item'
required-level: '&eRequires Lvl {value}' required-level: '&eRequires Lvl {value}'
@ -140,12 +142,13 @@ profession-smelting: '&eSmelting Level: &c{value}'
profession-smithing: '&eSmithing Level: &c{value}' profession-smithing: '&eSmithing Level: &c{value}'
profession-woodcutting: '&eWoodcutting Level: &c{value}' profession-woodcutting: '&eWoodcutting Level: &c{value}'
# Elemental Stat Format # Elemental Stat Formats
elemental-damage: '{color}{icon}&7 {value} {element} Damage' element:
elemental-damage-percent: '{color}{icon}&7 +{value}% {element} Damage' damage: '{color}{icon}&7 {value} {element} Damage'
elemental-defense: '{color}{icon}&7 {value} {element} Defense' damage-percent: '{color}{icon}&7 +{value}% {element} Damage'
elemental-defense-percent: '{color}{icon}&7 +{value}% {element} Defense' defense: '{color}{icon}&7 {value} {element} Defense'
elemental-weakness: '{color}{icon}&7 {value}% {element} Weakness' defense-percent: '{color}{icon}&7 +{value}% {element} Defense'
weakness: '{color}{icon}&7 {value}% {element} Weakness'
# Custom stats # Custom stats
custom-myluck: '&3 &7■ Luck: &f<plus>{value}' custom-myluck: '&3 &7■ Luck: &f<plus>{value}'