diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/build/MMOItemBuilder.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/build/MMOItemBuilder.java index 65ea2bf9..2b3bef18 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/build/MMOItemBuilder.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/build/MMOItemBuilder.java @@ -114,7 +114,6 @@ public class MMOItemBuilder extends Buildable { // Get name data StatHistory hist = StatHistory.from(mmoitem, ItemStats.NAME); - if (!mmoitem.hasData(ItemStats.NAME)) mmoitem.setData(ItemStats.NAME, new NameData("Item")); nameModifiers.forEach((obs, mod) -> { @@ -123,7 +122,7 @@ public class MMOItemBuilder extends Buildable { // Include modifier information if (mod.getType() == ModifierType.PREFIX) modName.addPrefix(mod.getFormat()); - if (mod.getType() == ModifierType.SUFFIX) modName.addSuffix(mod.getFormat()); + else if (mod.getType() == ModifierType.SUFFIX) modName.addSuffix(mod.getFormat()); // Register onto SH hist.registerModifierBonus(obs, modName); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Abilities.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Abilities.java index 05a66a61..c4916482 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Abilities.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Abilities.java @@ -7,8 +7,8 @@ import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.util.AltChar; import io.lumine.mythic.lib.skill.trigger.TriggerType; +import io.lumine.mythic.lib.util.annotation.BackwardsCompatibility; import net.Indyuce.mmoitems.MMOItems; -import net.Indyuce.mmoitems.util.MMOUtils; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.util.NumericStatFormula; @@ -51,32 +51,32 @@ public class Abilities extends ItemStat return list; } - private String generalFormat, modifierForEach, modifierSplitter, abilitySplitter; + private String generalFormat, modifierIfAny, modifierForEach, modifierSplitter, abilitySplitter; private boolean legacyFormat, useAbilitySplitter; private int modifiersPerLine; - @Deprecated + @BackwardsCompatibility(version = "6.10") @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 { + // COMPATIBILITY CODE FOR MI <6.10 + if (!(configObject instanceof ConfigurationSection)) { legacyFormat = true; generalFormat = legacyLanguageFile.getString("ability-format"); modifierForEach = legacyLanguageFile.getString("ability-modifier"); abilitySplitter = legacyLanguageFile.getString("ability-splitter"); useAbilitySplitter = abilitySplitter != null && !abilitySplitter.isEmpty(); + return; } + + final ConfigurationSection config = (ConfigurationSection) configObject; + generalFormat = config.getString("general-format"); + modifierIfAny = config.getString("modifier-if-any"); + 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"); } @Override @@ -111,6 +111,8 @@ public class Abilities extends ItemStat .replace("{trigger}", MMOItems.plugin.getLanguage().getCastingModeName(ability.getTrigger())) .replace("{ability}", ability.getAbility().getName())); + if (!ability.getModifiers().isEmpty()) builder.append(modifierIfAny); + boolean modifierAppened = false; int lineCounter = 0; for (String modifier : ability.getModifiers()) { @@ -126,12 +128,11 @@ public class Abilities extends ItemStat if (modifiersPerLine > 0 && lineCounter >= modifiersPerLine) { lineCounter = 0; modifierAppened = false; - abilityLore.add(builder.toString()); - builder.setLength(0); + builder.append("\n"); // Will be processed later on by MMOItems } } - if (modifierAppened) abilityLore.add(builder.toString()); + abilityLore.add(builder.toString()); if (useAbilitySplitter) abilityLore.add(abilitySplitter); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisplayName.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisplayName.java index c244934a..9c508124 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisplayName.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisplayName.java @@ -323,7 +323,7 @@ public class DisplayName extends StringStat implements GemStoneStat { @NotNull @Override public StringData getClearStatData() { - return new NameData(""); + return new NameData("Item"); } @Override diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/AbilityListData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/AbilityListData.java index 32fb4fae..9d20d919 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/AbilityListData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/AbilityListData.java @@ -4,7 +4,10 @@ import net.Indyuce.mmoitems.stat.data.type.Mergeable; import net.Indyuce.mmoitems.stat.data.type.StatData; import org.jetbrains.annotations.NotNull; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; public class AbilityListData implements StatData, Mergeable { private final List abilities = new ArrayList<>(); @@ -18,16 +21,16 @@ public class AbilityListData implements StatData, Mergeable { } public void add(@NotNull AbilityData... abilities) { - this.abilities.addAll(Arrays.asList(abilities)); + Collections.addAll(this.abilities, abilities); } - public void add(@NotNull Collection abilit) { - abilities.addAll(abilit); + public void add(@NotNull Collection abilities) { + this.abilities.addAll(abilities); } @NotNull - public Set getAbilities() { - return new HashSet<>(abilities); + public List getAbilities() { + return abilities; } @Override @@ -38,9 +41,7 @@ public class AbilityListData implements StatData, Mergeable { @NotNull @Override public AbilityListData clone() { - final AbilityListData clone = new AbilityListData(); - clone.abilities.addAll(this.abilities); - return clone; + return new AbilityListData(this.abilities); } @Override diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/ItemStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/ItemStat.java index 252126ba..5ad69576 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/ItemStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/ItemStat.java @@ -2,6 +2,7 @@ package net.Indyuce.mmoitems.stat.type; import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.api.item.ItemTag; +import io.lumine.mythic.lib.util.annotation.BackwardsCompatibility; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; @@ -141,8 +142,8 @@ public abstract class ItemStat, S extends StatData> * actual Stat Data from the NBT stored within the item. Reverses * getAppliedNBT() actually. *

- * Shall return null if the tags passed dont provide enough - * information to generate a useable StatData. + * Shall return null if the tags passed don't provide enough + * information to generate a usable StatData. * * @author gunging */ @@ -163,7 +164,7 @@ public abstract class ItemStat, S extends StatData> protected String generalStatFormat; - @Deprecated + @BackwardsCompatibility(version = "6.10") public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) { loadConfiguration(configObject); } @@ -172,7 +173,7 @@ public abstract class ItemStat, S extends StatData> generalStatFormat = configObject.toString(); } - @Deprecated + @BackwardsCompatibility(version = "6.10") public String getLegacyTranslationPath() { return getPath(); } @@ -200,7 +201,7 @@ public abstract class ItemStat, S extends StatData> * Mainly for backwards compatibility. Aliases are basically * other string identifiers that point to the same item stat. * Useful when changing stat keys inside the item configs. - * + *

* Aliases have to follow the UPPER_CASE stat identifier format. */ @Nullable diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/Buildable.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/Buildable.java index 171d17d5..01bba0e6 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/Buildable.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/Buildable.java @@ -14,17 +14,13 @@ public abstract class Buildable { protected abstract B whenBuilt(); - public void validateNotBuilt() { - Validate.isTrue(lock, "Has already been built"); - } - public boolean isBuilt() { return !lock; } @NotNull public B build() { - validateNotBuilt(); + Validate.isTrue(lock, "Has already been built"); lock = false; return whenBuilt(); } diff --git a/MMOItems-Dist/src/main/resources/default/language/stats.yml b/MMOItems-Dist/src/main/resources/default/language/stats.yml index 613b2ffa..d02a5f9d 100644 --- a/MMOItems-Dist/src/main/resources/default/language/stats.yml +++ b/MMOItems-Dist/src/main/resources/default/language/stats.yml @@ -32,7 +32,8 @@ faction-damage-undead: '&3 &7■ Undead Faction Damage: &f{value}%' # Abilities (changed in MI 6.9.5) ability: - general-format: "&8| &7{trigger} &8|&e|&8| &7&l{ability}\n" + general-format: "&8| &7{trigger} &8|&e|&8| &7&l{ability}" + modifier-if-any: "\n" # Appended to general-format if the skill has at least one modifier modifier-foreach: "&7{modifier}&8: &f{value}" modifier-splitter: " &8&l|&7 " modifiers-per-line: 3