Fixed abilities not displaying in the lore

This commit is contained in:
Jules 2024-04-06 16:52:44 -07:00
parent c1ecc198e3
commit 9142ca4183
7 changed files with 40 additions and 41 deletions

View File

@ -114,7 +114,6 @@ public class MMOItemBuilder extends Buildable<MMOItem> {
// Get name data // Get name data
StatHistory hist = StatHistory.from(mmoitem, ItemStats.NAME); StatHistory hist = StatHistory.from(mmoitem, ItemStats.NAME);
if (!mmoitem.hasData(ItemStats.NAME)) mmoitem.setData(ItemStats.NAME, new NameData("Item"));
nameModifiers.forEach((obs, mod) -> { nameModifiers.forEach((obs, mod) -> {
@ -123,7 +122,7 @@ public class MMOItemBuilder extends Buildable<MMOItem> {
// Include modifier information // Include modifier information
if (mod.getType() == ModifierType.PREFIX) modName.addPrefix(mod.getFormat()); 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 // Register onto SH
hist.registerModifierBonus(obs, modName); hist.registerModifierBonus(obs, modName);

View File

@ -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.item.SupportedNBTTagValues;
import io.lumine.mythic.lib.api.util.AltChar; import io.lumine.mythic.lib.api.util.AltChar;
import io.lumine.mythic.lib.skill.trigger.TriggerType; 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.MMOItems;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.api.util.NumericStatFormula;
@ -51,32 +51,32 @@ public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData>
return list; return list;
} }
private String generalFormat, modifierForEach, modifierSplitter, abilitySplitter; private String generalFormat, modifierIfAny, modifierForEach, modifierSplitter, abilitySplitter;
private boolean legacyFormat, useAbilitySplitter; private boolean legacyFormat, useAbilitySplitter;
private int modifiersPerLine; private int modifiersPerLine;
@Deprecated @BackwardsCompatibility(version = "6.10")
@Override @Override
public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) { public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) {
// MI <7 config // COMPATIBILITY CODE FOR MI <6.10
if (configObject instanceof ConfigurationSection) { 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; legacyFormat = true;
generalFormat = legacyLanguageFile.getString("ability-format"); generalFormat = legacyLanguageFile.getString("ability-format");
modifierForEach = legacyLanguageFile.getString("ability-modifier"); modifierForEach = legacyLanguageFile.getString("ability-modifier");
abilitySplitter = legacyLanguageFile.getString("ability-splitter"); abilitySplitter = legacyLanguageFile.getString("ability-splitter");
useAbilitySplitter = abilitySplitter != null && !abilitySplitter.isEmpty(); 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 @Override
@ -111,6 +111,8 @@ public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData>
.replace("{trigger}", MMOItems.plugin.getLanguage().getCastingModeName(ability.getTrigger())) .replace("{trigger}", MMOItems.plugin.getLanguage().getCastingModeName(ability.getTrigger()))
.replace("{ability}", ability.getAbility().getName())); .replace("{ability}", ability.getAbility().getName()));
if (!ability.getModifiers().isEmpty()) builder.append(modifierIfAny);
boolean modifierAppened = false; boolean modifierAppened = false;
int lineCounter = 0; int lineCounter = 0;
for (String modifier : ability.getModifiers()) { for (String modifier : ability.getModifiers()) {
@ -126,12 +128,11 @@ public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData>
if (modifiersPerLine > 0 && lineCounter >= modifiersPerLine) { if (modifiersPerLine > 0 && lineCounter >= modifiersPerLine) {
lineCounter = 0; lineCounter = 0;
modifierAppened = false; modifierAppened = false;
abilityLore.add(builder.toString()); builder.append("\n"); // Will be processed later on by MMOItems
builder.setLength(0);
} }
} }
if (modifierAppened) abilityLore.add(builder.toString()); abilityLore.add(builder.toString());
if (useAbilitySplitter) if (useAbilitySplitter)
abilityLore.add(abilitySplitter); abilityLore.add(abilitySplitter);

View File

@ -323,7 +323,7 @@ public class DisplayName extends StringStat implements GemStoneStat {
@NotNull @NotNull
@Override @Override
public StringData getClearStatData() { public StringData getClearStatData() {
return new NameData(""); return new NameData("Item");
} }
@Override @Override

View File

@ -4,7 +4,10 @@ import net.Indyuce.mmoitems.stat.data.type.Mergeable;
import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.data.type.StatData;
import org.jetbrains.annotations.NotNull; 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<AbilityListData> { public class AbilityListData implements StatData, Mergeable<AbilityListData> {
private final List<AbilityData> abilities = new ArrayList<>(); private final List<AbilityData> abilities = new ArrayList<>();
@ -18,16 +21,16 @@ public class AbilityListData implements StatData, Mergeable<AbilityListData> {
} }
public void add(@NotNull AbilityData... abilities) { public void add(@NotNull AbilityData... abilities) {
this.abilities.addAll(Arrays.asList(abilities)); Collections.addAll(this.abilities, abilities);
} }
public void add(@NotNull Collection<AbilityData> abilit) { public void add(@NotNull Collection<AbilityData> abilities) {
abilities.addAll(abilit); this.abilities.addAll(abilities);
} }
@NotNull @NotNull
public Set<AbilityData> getAbilities() { public List<AbilityData> getAbilities() {
return new HashSet<>(abilities); return abilities;
} }
@Override @Override
@ -38,9 +41,7 @@ public class AbilityListData implements StatData, Mergeable<AbilityListData> {
@NotNull @NotNull
@Override @Override
public AbilityListData clone() { public AbilityListData clone() {
final AbilityListData clone = new AbilityListData(); return new AbilityListData(this.abilities);
clone.abilities.addAll(this.abilities);
return clone;
} }
@Override @Override

View File

@ -2,6 +2,7 @@ package net.Indyuce.mmoitems.stat.type;
import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.ItemTag; 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.MMOItems;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
@ -141,8 +142,8 @@ public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData>
* actual Stat Data from the NBT stored within the item. Reverses * actual Stat Data from the NBT stored within the item. Reverses
* <code>getAppliedNBT()</code> actually. * <code>getAppliedNBT()</code> actually.
* <p></p> * <p></p>
* Shall return null if the tags passed dont provide enough * Shall return null if the tags passed don't provide enough
* information to generate a useable StatData. * information to generate a usable StatData.
* *
* @author gunging * @author gunging
*/ */
@ -163,7 +164,7 @@ public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData>
protected String generalStatFormat; protected String generalStatFormat;
@Deprecated @BackwardsCompatibility(version = "6.10")
public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) { public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) {
loadConfiguration(configObject); loadConfiguration(configObject);
} }
@ -172,7 +173,7 @@ public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData>
generalStatFormat = configObject.toString(); generalStatFormat = configObject.toString();
} }
@Deprecated @BackwardsCompatibility(version = "6.10")
public String getLegacyTranslationPath() { public String getLegacyTranslationPath() {
return getPath(); return getPath();
} }
@ -200,7 +201,7 @@ public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData>
* Mainly for backwards compatibility. Aliases are basically * Mainly for backwards compatibility. Aliases are basically
* other string identifiers that point to the same item stat. * other string identifiers that point to the same item stat.
* Useful when changing stat keys inside the item configs. * Useful when changing stat keys inside the item configs.
* * <p>
* Aliases have to follow the UPPER_CASE stat identifier format. * Aliases have to follow the UPPER_CASE stat identifier format.
*/ */
@Nullable @Nullable

View File

@ -14,17 +14,13 @@ public abstract class Buildable<B> {
protected abstract B whenBuilt(); protected abstract B whenBuilt();
public void validateNotBuilt() {
Validate.isTrue(lock, "Has already been built");
}
public boolean isBuilt() { public boolean isBuilt() {
return !lock; return !lock;
} }
@NotNull @NotNull
public B build() { public B build() {
validateNotBuilt(); Validate.isTrue(lock, "Has already been built");
lock = false; lock = false;
return whenBuilt(); return whenBuilt();
} }

View File

@ -32,7 +32,8 @@ faction-damage-undead: '&3 &7■ Undead Faction Damage: &f<plus>{value}%'
# Abilities (changed in MI 6.9.5) # Abilities (changed in MI 6.9.5)
ability: 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-foreach: "&7{modifier}&8: &f{value}"
modifier-splitter: " &8&l|&7 " modifier-splitter: " &8&l|&7 "
modifiers-per-line: 3 modifiers-per-line: 3