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 b4d51a8d..03ced3de 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 @@ -57,14 +57,10 @@ public class MMOItemBuilder extends Buildable { this.tier = tier; // Either use provided tier or look into the template base data - tier = tier != null ? tier - : template.getBaseItemData().containsKey(ItemStats.TIER) ? MMOItems.plugin.getTiers().get(template.getBaseItemData().get(ItemStats.TIER).toString()) - : null; + tier = tier != null ? tier : template.getBaseItemData().containsKey(ItemStats.TIER) ? MMOItems.plugin.getTiers().get(template.getBaseItemData().get(ItemStats.TIER).toString()) : null; // Capacity is not final as it keeps lowering as modifiers are selected - capacity = (template.hasModifierCapacity() ? template.getModifierCapacity() : - tier != null && tier.hasCapacity() ? tier.getModifierCapacity() : - MMOItems.plugin.getLanguage().defaultItemCapacity).calculate(level); + capacity = (template.hasModifierCapacity() ? template.getModifierCapacity() : tier != null && tier.hasCapacity() ? tier.getModifierCapacity() : MMOItems.plugin.getLanguage().defaultItemCapacity).calculate(level); mmoitem = new MMOItem(template.getType(), template.getId()); // Apply base item data @@ -118,8 +114,7 @@ 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")); + if (!mmoitem.hasData(ItemStats.NAME)) mmoitem.setData(ItemStats.NAME, new NameData("Item")); nameModifiers.forEach((obs, mod) -> { @@ -148,18 +143,10 @@ public class MMOItemBuilder extends Buildable { * @param stat Stat owning the data * @param data StatData to apply */ - public void applyData(ItemStat stat, StatData data) { - - // Is the data mergeable? Apply as External SH - if (mmoitem.hasData(stat) && data instanceof Mergeable) { - - ((Mergeable) mmoitem.getData(stat)).merge(data); - - } else { - - // Set, there is no more. - mmoitem.setData(stat, data); - } + public void applyData(@NotNull ItemStat stat, @NotNull StatData data) { + final StatData found = mmoitem.getData(stat); + if (found != null && found instanceof Mergeable) ((Mergeable) found).mergeWith(data); + else mmoitem.setData(stat, data); } /** @@ -171,8 +158,7 @@ public class MMOItemBuilder extends Buildable { public void addModifierData(@NotNull ItemStat stat, @NotNull StatData data, @NotNull UUID uuid) { if (stat.getClearStatData() instanceof Mergeable) StatHistory.from(mmoitem, stat).registerModifierBonus(uuid, data); - else - mmoitem.setData(stat, data); + else mmoitem.setData(stat, data); } /** @@ -206,8 +192,7 @@ public class MMOItemBuilder extends Buildable { @NotNull @Deprecated public static Collection rollModifiers(@NotNull MMOItemTemplate template) { - if (!template.hasOption(TemplateOption.ROLL_MODIFIER_CHECK_ORDER)) - return template.getModifiers().values(); + if (!template.hasOption(TemplateOption.ROLL_MODIFIER_CHECK_ORDER)) return template.getModifiers().values(); List modifiers = new ArrayList<>(template.getModifiers().values()); Collections.shuffle(modifiers); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/util/NumericStatFormula.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/util/NumericStatFormula.java index ccfa5371..51167e6c 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/util/NumericStatFormula.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/util/NumericStatFormula.java @@ -378,7 +378,7 @@ public class NumericStatFormula implements RandomStatData, Updatable //UPGRD//MMOItems.log("\u00a7a +\u00a77 Acceptable Range --- kept"); // Just clone I guess - return original.cloneData(); + return original.clone(); } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/enchants/CrazyEnchantsData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/enchants/CrazyEnchantsData.java index 9d75bd15..6d2e0843 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/enchants/CrazyEnchantsData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/enchants/CrazyEnchantsData.java @@ -15,4 +15,9 @@ public class CrazyEnchantsData implements StatData { public Map getEnchants() { return enchants; } + + @Override + public boolean isEmpty() { + return enchants.isEmpty(); + } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/enchants/advanced_enchants/AdvancedEnchantMap.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/enchants/advanced_enchants/AdvancedEnchantMap.java index cfe514be..eba4306a 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/enchants/advanced_enchants/AdvancedEnchantMap.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/enchants/advanced_enchants/AdvancedEnchantMap.java @@ -8,4 +8,9 @@ import java.util.Map; public class AdvancedEnchantMap implements StatData { public final Map enchants = new HashMap<>(); + + @Override + public boolean isEmpty() { + return enchants.isEmpty(); + } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/Mergeable.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/Mergeable.java index d4d8f6a2..50adbd7c 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/Mergeable.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/Mergeable.java @@ -1,5 +1,9 @@ package net.Indyuce.mmoitems.stat.component; +/** + * @deprecated Not used yet + */ +@Deprecated public interface Mergeable { public void merge(T t); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/StatComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/StatComponent.java index 983967f9..b4dfcf12 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/StatComponent.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/StatComponent.java @@ -1,5 +1,9 @@ package net.Indyuce.mmoitems.stat.component; +/** + * @deprecated Not used yet + */ +@Deprecated public abstract class StatComponent { private final String path; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/Upgradable.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/Upgradable.java index 44108fbf..b5abfaa9 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/Upgradable.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/Upgradable.java @@ -1,4 +1,8 @@ package net.Indyuce.mmoitems.stat.component; +/** + * @deprecated Not used yet + */ +@Deprecated public interface Upgradable { } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/AbstractObjectComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/AbstractObjectComponent.java index 0d8b920c..d8124d40 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/AbstractObjectComponent.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/AbstractObjectComponent.java @@ -3,6 +3,10 @@ package net.Indyuce.mmoitems.stat.component.type; import net.Indyuce.mmoitems.stat.component.StatComponent; import org.jetbrains.annotations.Nullable; +/** + * @deprecated Not used yet + */ +@Deprecated public abstract class AbstractObjectComponent extends StatComponent { public AbstractObjectComponent(String path) { super(path); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/DoubleComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/DoubleComponent.java index 1f5c9360..dc5f021d 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/DoubleComponent.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/DoubleComponent.java @@ -2,7 +2,10 @@ package net.Indyuce.mmoitems.stat.component.type; import net.Indyuce.mmoitems.stat.component.Mergeable; import net.Indyuce.mmoitems.stat.component.StatComponent; - +/** + * @deprecated Not used yet + */ +@Deprecated public class DoubleComponent extends StatComponent implements Mergeable { private double value; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ObjectComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ObjectComponent.java index 945e9e7e..27260f79 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ObjectComponent.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ObjectComponent.java @@ -9,6 +9,10 @@ import java.util.Map; import java.util.Set; import java.util.function.Consumer; +/** + * @deprecated Not used yet + */ +@Deprecated public class ObjectComponent extends AbstractObjectComponent implements Upgradable { private final Map components = new HashMap<>(); 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 e9870a0b..36143462 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 @@ -1,64 +1,83 @@ package net.Indyuce.mmoitems.stat.data; -import java.util.Arrays; -import java.util.LinkedHashSet; -import java.util.Set; - import net.Indyuce.mmoitems.stat.data.type.Mergeable; import net.Indyuce.mmoitems.stat.data.type.StatData; import org.jetbrains.annotations.NotNull; +import java.util.*; + public class AbilityListData implements StatData, Mergeable { - @NotNull private final Set abilities = new LinkedHashSet<>(); + private final List abilities = new ArrayList<>(); - public AbilityListData(@NotNull AbilityData... abilities) { - add(abilities); - } + public AbilityListData(@NotNull AbilityData... abilities) { + add(abilities); + } - public AbilityListData(@NotNull Set abilit) { add(abilit); } + public AbilityListData(@NotNull Collection abilities) { + add(abilities); + } - public void add(@NotNull AbilityData... abilities) { - this.abilities.addAll(Arrays.asList(abilities)); - } + public void add(@NotNull AbilityData... abilities) { + this.abilities.addAll(Arrays.asList(abilities)); + } - public void add(@NotNull Set abilit) { abilities.addAll(abilit); } + public void add(@NotNull Collection abilit) { + abilities.addAll(abilit); + } - @NotNull - public Set getAbilities() { - return abilities; - } + @NotNull + public Set getAbilities() { + return new HashSet<>(abilities); + } - @Override - public void merge(@NotNull AbilityListData data) { - abilities.addAll(data.abilities); - } + @Override + public void mergeWith(@NotNull AbilityListData targetData) { + abilities.addAll(targetData.abilities); + } - @Override - public boolean equals(Object obj) { - if (!(obj instanceof AbilityListData)) { return false; } + @NotNull + @Override + public AbilityListData clone() { + return new AbilityListData(); + } - // Different number of abilities? Not equal - if (getAbilities().size() != ((AbilityListData) obj).getAbilities().size()) { return false; } + @Override + public boolean equals(Object obj) { + if (!(obj instanceof AbilityListData)) { + return false; + } - // Examine each - for (AbilityData ab : ((AbilityListData) obj).getAbilities()) { + // Different number of abilities? Not equal + if (getAbilities().size() != ((AbilityListData) obj).getAbilities().size()) { + return false; + } - if (ab == null) { continue; } + // Examine each + for (AbilityData ab : ((AbilityListData) obj).getAbilities()) { - boolean unmatched = true; - for (AbilityData thi : getAbilities()) { if (ab.equals(thi)) { unmatched = false; break; } } + if (ab == null) { + continue; + } - // Extraneous ability found, not equal. - if (unmatched) { return false; } - } + boolean unmatched = true; + for (AbilityData thi : getAbilities()) { + if (ab.equals(thi)) { + unmatched = false; + break; + } + } - return true; } + // Extraneous ability found, not equal. + if (unmatched) { + return false; + } + } - @Override - public @NotNull AbilityListData cloneData() { return new AbilityListData(getAbilities()); } + return true; + } - @Override - public boolean isEmpty() { - return abilities.isEmpty(); - } + @Override + public boolean isEmpty() { + return abilities.isEmpty(); + } } \ No newline at end of file diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ArrowParticlesData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ArrowParticlesData.java index e3ef5109..b07cb767 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ArrowParticlesData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ArrowParticlesData.java @@ -1,12 +1,10 @@ package net.Indyuce.mmoitems.stat.data; -import org.bukkit.Particle; - import com.google.gson.JsonObject; - import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; import net.Indyuce.mmoitems.stat.data.type.StatData; +import org.bukkit.Particle; public class ArrowParticlesData implements StatData, RandomStatData { private final Particle particle; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/CommandListData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/CommandListData.java index abcd9381..b879ed91 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/CommandListData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/CommandListData.java @@ -1,32 +1,33 @@ package net.Indyuce.mmoitems.stat.data; -import java.util.*; - -import org.apache.commons.lang.Validate; - import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; import net.Indyuce.mmoitems.stat.data.type.Mergeable; import net.Indyuce.mmoitems.stat.data.type.StatData; import org.jetbrains.annotations.NotNull; -public class CommandListData implements StatData, Mergeable, RandomStatData { +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class CommandListData implements StatData, Mergeable, RandomStatData { @NotNull - private final List commands; + private final List commands = new ArrayList<>(); public CommandListData(@NotNull List commands) { - this.commands = commands; + add(commands); } public CommandListData(CommandData... commands) { - this(new ArrayList<>()); - add(commands); } public void add(CommandData... commands) { - for (CommandData data : commands) - this.commands.add(data); + for (CommandData data : commands) this.commands.add(data); + } + + public void add(Collection commands) { + this.commands.addAll(commands); } @NotNull @@ -43,13 +44,13 @@ public class CommandListData implements StatData, Mergeable, RandomStatData(commands)); + return clone(); } } \ No newline at end of file diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/DoubleData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/DoubleData.java index 3cfa7e6d..75220a74 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/DoubleData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/DoubleData.java @@ -27,12 +27,12 @@ public class DoubleData implements StatData, Mergeable { } @Override - public void merge(DoubleData data) { + public void mergeWith(DoubleData data) { value += data.value; } @Override - public DoubleData cloneData() { return new DoubleData(getValue()); } + public DoubleData clone() { return new DoubleData(value); } @Override public boolean isEmpty() { @@ -42,8 +42,9 @@ public class DoubleData implements StatData, Mergeable { @Override public String toString() { return String.valueOf(getValue()); } - @Override - public boolean equals(Object obj) { - if (!(obj instanceof DoubleData)) { return false; } - return ((DoubleData) obj).getValue() == getValue(); } + @Override + public boolean equals(Object obj) { + if (!(obj instanceof DoubleData)) return false; + return ((DoubleData) obj).getValue() == getValue(); + } } \ No newline at end of file diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ElementListData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ElementListData.java index 3cd31a17..7ac7762a 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ElementListData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ElementListData.java @@ -5,7 +5,6 @@ import net.Indyuce.mmoitems.stat.data.type.Mergeable; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.util.ElementStatType; import net.Indyuce.mmoitems.util.Pair; -import org.apache.commons.lang.Validate; import org.jetbrains.annotations.NotNull; import java.util.LinkedHashMap; @@ -13,7 +12,7 @@ import java.util.Map; import java.util.Objects; import java.util.Set; -public class ElementListData implements Mergeable { +public class ElementListData implements StatData, Mergeable { private final Map, Double> stats = new LinkedHashMap<>(); public double getStat(Element element, ElementStatType statType) { @@ -30,16 +29,14 @@ public class ElementListData implements Mergeable { } @Override - public void merge(StatData data) { - Validate.isTrue(data instanceof ElementListData, "Cannot merge two different stat data types"); - ElementListData extra = (ElementListData) data; + public void mergeWith(@NotNull ElementListData targetData) { //Includes old values if any, fixes stacking of element double values I believe - Kilo - extra.stats.forEach((key, value) -> stats.put(key, value + stats.getOrDefault(key,0.0))); + targetData.stats.forEach((key, value) -> stats.put(key, value + stats.getOrDefault(key,0.0))); } @NotNull @Override - public StatData cloneData() { + public ElementListData clone() { ElementListData ret = new ElementListData(); for (Map.Entry, Double> entry : stats.entrySet()) { Pair key = entry.getKey(); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/EnchantListData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/EnchantListData.java index 32a415ab..1c1fc319 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/EnchantListData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/EnchantListData.java @@ -13,157 +13,188 @@ import org.jetbrains.annotations.Nullable; import java.util.HashMap; import java.util.Map; import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; -public class EnchantListData implements StatData, Mergeable { - private final Map enchants = new HashMap<>(); +public class EnchantListData implements StatData, Mergeable { + private final Map enchants = new HashMap<>(); - public Set getEnchants() { - return enchants.keySet(); - } + @NotNull + public Set getEnchants() { + return enchants.keySet(); + } - public int getLevel(@NotNull Enchantment enchant) { - @Nullable Integer found = enchants.get(enchant); - return found == null ? 0 : found; - } + public int getLevel(@NotNull Enchantment enchant) { + @Nullable Integer found = enchants.get(enchant); + return found == null ? 0 : found; + } public void addEnchant(Enchantment enchant, int level) { - // Ignore lvl 0 enchants :wazowskibruhmoment: - if (level <= 0) { enchants.remove(enchant); } else { enchants.put(enchant, level);} + // Ignore lvl 0 enchants :wazowskibruhmoment: + if (level <= 0) { + enchants.remove(enchant); + } else { + enchants.put(enchant, level); + } } - public void clear() { enchants.clear(); } + public void clear() { + enchants.clear(); + } - @Override - public boolean equals(Object obj) { - if (!(obj instanceof EnchantListData)) { return false; } - if (((EnchantListData) obj).enchants.size() != enchants.size()) { return false; } + @Override + public boolean equals(Object obj) { + if (!(obj instanceof EnchantListData)) { + return false; + } + if (((EnchantListData) obj).enchants.size() != enchants.size()) { + return false; + } - for (Enchantment e : getEnchants()) { + for (Enchantment e : getEnchants()) { - // Compare - if (getLevel(e) != ((EnchantListData) obj).getLevel(e)) { return false; } } - return true; - } + // Compare + if (getLevel(e) != ((EnchantListData) obj).getLevel(e)) { + return false; + } + } + return true; + } - @Override - public void merge(StatData data) { - Validate.isTrue(data instanceof EnchantListData, "Cannot merge two different stat data types"); + @Override + public void mergeWith(@NotNull EnchantListData targetData) { + for (Enchantment enchant : targetData.getEnchants()) + addEnchant(enchant, Math.max(enchants.getOrDefault(enchant, 0), targetData.getLevel(enchant))); + } - final EnchantListData enchantList = (EnchantListData) data; - for (Enchantment enchant : enchantList.getEnchants()) - addEnchant(enchant, Math.max(enchants.getOrDefault(enchant, 0), enchantList.getLevel(enchant))); - } + @Override + @NotNull + public EnchantListData clone() { - @Override - public @NotNull StatData cloneData() { + // Start Fresh + EnchantListData ret = new EnchantListData(); - // Start Fresh - EnchantListData ret = new EnchantListData(); + // Enchant + for (Enchantment enchant : enchants.keySet()) { + ret.addEnchant(enchant, enchants.getOrDefault(enchant, 0)); + } - // Enchant - for (Enchantment enchant : enchants.keySet()) { ret.addEnchant(enchant, enchants.getOrDefault(enchant, 0)); } + // Thats it + return ret; + } - // Thats it - return ret; - } + @Override + public String toString() { + StringBuilder builder = new StringBuilder("EnchantList{"); + final AtomicBoolean check = new AtomicBoolean(); + enchants.forEach((enchant, lvl) -> { + if (check.get()) builder.append(","); + builder.append(enchant + "=" + lvl); + check.set(true); + }); + builder.append("}"); + return builder.toString(); + } - @Override - public boolean isEmpty() { - for (int level : enchants.values()) - if (level > 0) - return false; - return true; - } + @Override + public boolean isEmpty() { + for (int level : enchants.values()) + if (level > 0) + return false; + return true; + } - /** - * todo We cannot yet assume (for a few months) that the Original Enchantment Data - * registered into the Stat History is actually true to the template (since it may - * be the enchantments of an old-enchanted item, put by the player). - *

- * Thus this block of code checks the enchantment data of the newly generated - * MMOItem and follows the following logic to give our best guess if the Original - * stats are actually Original: - *

- * 1: Is the item unenchantable and unrepairable? Then they must be original - *

- * 2: Does the template have no enchantments? Then they must be external - *

- * 3: Does the template have this enchantment at an unobtainable level? Then it must be original - *

- * 4: Does the template have this enchantment at a lesser level? Then it must be external (player upgraded it) - *

- * Original: Included within the template at first creation - * External: Enchanted manually by a player - * - * @param mmoItem The item, to provide context for adequate guessing. - * - */ - public void identifyTrueOriginalEnchantments(@NotNull MMOItem mmoItem) { + /** + * todo We cannot yet assume (for a few months) that the Original Enchantment Data + * registered into the Stat History is actually true to the template (since it may + * be the enchantments of an old-enchanted item, put by the player). + *

+ * Thus this block of code checks the enchantment data of the newly generated + * MMOItem and follows the following logic to give our best guess if the Original + * stats are actually Original: + *

+ * 1: Is the item unenchantable and unrepairable? Then they must be original + *

+ * 2: Does the template have no enchantments? Then they must be external + *

+ * 3: Does the template have this enchantment at an unobtainable level? Then it must be original + *

+ * 4: Does the template have this enchantment at a lesser level? Then it must be external (player upgraded it) + *

+ * Original: Included within the template at first creation + * External: Enchanted manually by a player + * + * @param mmoItem The item, to provide context for adequate guessing. + */ + public void identifyTrueOriginalEnchantments(@NotNull MMOItem mmoItem) { - //RFG//MMOItems.log(" \u00a7b> \u00a77Original Enchantments Upkeep"); + //RFG//MMOItems.log(" \u00a7b> \u00a77Original Enchantments Upkeep"); - // 1: The item is unenchantable and unrepairable? Cancel this operation, the cached are Original - if (mmoItem.hasData(ItemStats.DISABLE_ENCHANTING) && mmoItem.hasData(ItemStats.DISABLE_REPAIRING)) { - //RFG//MMOItems.log(" \u00a7bType-1 \u00a77Original Identification ~ no transfer"); + // 1: The item is unenchantable and unrepairable? Cancel this operation, the cached are Original + if (mmoItem.hasData(ItemStats.DISABLE_ENCHANTING) && mmoItem.hasData(ItemStats.DISABLE_REPAIRING)) { + //RFG//MMOItems.log(" \u00a7bType-1 \u00a77Original Identification ~ no transfer"); - clear(); - return; - } + clear(); + return; + } - if (!mmoItem.hasData(ItemStats.ENCHANTS)) { mmoItem.setData(ItemStats.ENCHANTS, new EnchantListData());} + if (!mmoItem.hasData(ItemStats.ENCHANTS)) { + mmoItem.setData(ItemStats.ENCHANTS, new EnchantListData()); + } - EnchantListData mmoData = (EnchantListData) mmoItem.getData(ItemStats.ENCHANTS); + EnchantListData mmoData = (EnchantListData) mmoItem.getData(ItemStats.ENCHANTS); - // 2: If it has data (It always has) and the amount of enchants is zero, the cached are Extraneous - if (mmoData.getEnchants().size() == 0) { - //RFG//MMOItems.log(" \u00a73Type-2 \u00a77Extraneous Identification ~ all transferred"); + // 2: If it has data (It always has) and the amount of enchants is zero, the cached are Extraneous + if (mmoData.getEnchants().size() == 0) { + //RFG//MMOItems.log(" \u00a73Type-2 \u00a77Extraneous Identification ~ all transferred"); - // All right, lets add those to cached enchantments - mmoItem.mergeData(ItemStats.ENCHANTS,this, null); - return; - } + // All right, lets add those to cached enchantments + mmoItem.mergeData(ItemStats.ENCHANTS, this, null); + return; + } - // Which enchantments are deemed external, after all? - EnchantListData processed = new EnchantListData(); + // Which enchantments are deemed external, after all? + EnchantListData processed = new EnchantListData(); - // Identify material - mmoItem.hasData(ItemStats.MATERIAL); MaterialData mData = (MaterialData) mmoItem.getData(ItemStats.MATERIAL); Material mat = mData.getMaterial(); + // Identify material + mmoItem.hasData(ItemStats.MATERIAL); + MaterialData mData = (MaterialData) mmoItem.getData(ItemStats.MATERIAL); + Material mat = mData.getMaterial(); - // 3 & 4: Lets examine every stat - for (Enchantment e : getEnchants()) { - //RFG//MMOItems.log(" \u00a7b = \u00a77Per Enchant - \u00a7f" + e.getName()); + // 3 & 4: Lets examine every stat + for (Enchantment e : getEnchants()) { + //RFG//MMOItems.log(" \u00a7b = \u00a77Per Enchant - \u00a7f" + e.getName()); - // Lets see hmm - int current = getLevel(e); - int updated = mmoData.getLevel(e); - //RFG//MMOItems.log(" \u00a73 <=: \u00a77Current \u00a7f" + current); - //RFG//MMOItems.log(" \u00a73 <=: \u00a77Updated \u00a7f" + updated); + // Lets see hmm + int current = getLevel(e); + int updated = mmoData.getLevel(e); + //RFG//MMOItems.log(" \u00a73 <=: \u00a77Current \u00a7f" + current); + //RFG//MMOItems.log(" \u00a73 <=: \u00a77Updated \u00a7f" + updated); - // 3: Is it at an unobtainable level? Then its Original - if (updated > e.getMaxLevel() || !e.getItemTarget().includes(mat)) { - //RFG//MMOItems.log(" \u00a7bType-3 \u00a77Original Identification ~ Impossible through vanilla"); + // 3: Is it at an unobtainable level? Then its Original + if (updated > e.getMaxLevel() || !e.getItemTarget().includes(mat)) { + //RFG//MMOItems.log(" \u00a7bType-3 \u00a77Original Identification ~ Impossible through vanilla"); - continue; - } + continue; + } - // 4: Is it at a lesser level? Player must have enchanted, take them as External - if (updated < current) { - //RFG//MMOItems.log(" \u00a73Type-4 \u00a77Extraneous Identification ~ Improvement from the Template"); - processed.addEnchant(e, current); + // 4: Is it at a lesser level? Player must have enchanted, take them as External + if (updated < current) { + //RFG//MMOItems.log(" \u00a73Type-4 \u00a77Extraneous Identification ~ Improvement from the Template"); + processed.addEnchant(e, current); - //noinspection UnnecessaryContinue - continue; - } + //noinspection UnnecessaryContinue + continue; + } - //RFG//MMOItems.log(" \u00a73Type-5 \u00a77Original Identification ~ Not improved from the template"); - } + //RFG//MMOItems.log(" \u00a73Type-5 \u00a77Original Identification ~ Not improved from the template"); + } - // Finish merge - if (!processed.isClear()) { + // Finish merge + if (!processed.isEmpty()) { - // As Extraneosu - mmoItem.mergeData(ItemStats.ENCHANTS, processed, null); - } - } + // As Extraneosu + mmoItem.mergeData(ItemStats.ENCHANTS, processed, null); + } + } } \ No newline at end of file diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/GemSocketsData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/GemSocketsData.java index 6851a51a..1daa9d4e 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/GemSocketsData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/GemSocketsData.java @@ -126,7 +126,7 @@ public class GemSocketsData implements StatData, Mergeable, Rand } @Override - public void merge(GemSocketsData data) { + public void mergeWith(GemSocketsData data) { // Combine both actual gems, and empty slots emptySlots.addAll(data.emptySlots); @@ -134,7 +134,7 @@ public class GemSocketsData implements StatData, Mergeable, Rand } @Override - public GemSocketsData cloneData() { + public GemSocketsData clone() { // Clone empty slots GemSocketsData ret = new GemSocketsData(new ArrayList<>(emptySlots)); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/PotionEffectListData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/PotionEffectListData.java index 70420cac..fd43e027 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/PotionEffectListData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/PotionEffectListData.java @@ -1,15 +1,13 @@ package net.Indyuce.mmoitems.stat.data; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.apache.commons.lang.Validate; - import net.Indyuce.mmoitems.stat.data.type.Mergeable; import net.Indyuce.mmoitems.stat.data.type.StatData; import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + public class PotionEffectListData implements StatData, Mergeable { private final List effects = new ArrayList<>(); @@ -20,6 +18,41 @@ public class PotionEffectListData implements StatData, Mergeable effects) { + add(effects); + } + + public void add(PotionEffectData... effects) { + for (PotionEffectData el : effects) this.effects.add(el); + } + + public void add(Collection effects) { + this.effects.addAll(effects); + } + + @NotNull + public List getEffects() { + return effects; + } + + @Override + public boolean isEmpty() { + return effects.isEmpty(); + } + + @Override + public void mergeWith(PotionEffectListData data) { + effects.addAll(data.effects); + } + + @Override + @NotNull + public PotionEffectListData clone() { return new PotionEffectListData(effects); } + @Override public boolean equals(Object obj) { if (!(obj instanceof PotionEffectListData)) { return false; } @@ -41,29 +74,4 @@ public class PotionEffectListData implements StatData, Mergeable getEffects() { - return effects; - } - - @Override - public boolean isEmpty() { - return effects.isEmpty(); - } - - @Override - public void merge(PotionEffectListData data) { - effects.addAll(data.effects); - } - - @Override - public @NotNull PotionEffectListData cloneData() { return new PotionEffectListData(getEffects().toArray(new PotionEffectData[0])); } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ProjectileParticlesData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ProjectileParticlesData.java index 58d6bf10..83d0da6d 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ProjectileParticlesData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ProjectileParticlesData.java @@ -77,6 +77,11 @@ public class ProjectileParticlesData implements StatData, RandomStatData { private double health, food, saturation; public RestoreData(double health, double food, double saturation) { @@ -44,17 +44,16 @@ public class RestoreData implements StatData, Mergeable { } @Override - public void merge(StatData data) { - Validate.isTrue(data instanceof RestoreData, "Cannot merge two different stat data types"); - health += ((RestoreData) data).health; - food += ((RestoreData) data).food; - saturation += ((RestoreData) data).saturation; + public void mergeWith(@NotNull RestoreData targetData) { + health += targetData.health; + food += targetData.food; + saturation += targetData.saturation; } @Override - public @NotNull - StatData cloneData() { - return new RestoreData(getHealth(), getFood(), getSaturation()); + @NotNull + public RestoreData clone() { + return new RestoreData(health, food, saturation); } @Override diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ShieldPatternData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ShieldPatternData.java index 7f0fb282..f7fb6308 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ShieldPatternData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ShieldPatternData.java @@ -1,43 +1,62 @@ package net.Indyuce.mmoitems.stat.data; +import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; +import net.Indyuce.mmoitems.stat.data.random.RandomStatData; +import net.Indyuce.mmoitems.stat.data.type.StatData; +import org.bukkit.DyeColor; +import org.bukkit.block.banner.Pattern; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.bukkit.DyeColor; -import org.bukkit.block.banner.Pattern; - -import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; -import net.Indyuce.mmoitems.stat.data.random.RandomStatData; -import net.Indyuce.mmoitems.stat.data.type.StatData; - public class ShieldPatternData implements StatData, RandomStatData { - private final DyeColor base; - private final List patterns = new ArrayList<>(); + private DyeColor base; + private final List patterns = new ArrayList<>(); - public ShieldPatternData(DyeColor base, Pattern... patterns) { - this.base = base; - this.patterns.addAll(Arrays.asList(patterns)); - } + public ShieldPatternData(DyeColor base, Pattern... patterns) { + this.base = base; + this.patterns.addAll(Arrays.asList(patterns)); + } - public DyeColor getBaseColor() { - return base; - } + public void setBase(@Nullable DyeColor base) { + this.base = base; + } - public List getPatterns() { - return patterns; - } + @Nullable + public DyeColor getBaseColor() { + return base; + } - public void add(Pattern pattern) { - patterns.add(pattern); - } + @NotNull + public List getPatterns() { + return patterns; + } - public void addAll(List patterns) { - this.patterns.addAll(patterns); - } + public void add(Pattern pattern) { + patterns.add(pattern); + } - @Override - public ShieldPatternData randomize(MMOItemBuilder builder) { - return this; - } + public void addAll(List patterns) { + this.patterns.addAll(patterns); + } + + @Override + public ShieldPatternData clone() { + final ShieldPatternData clone = new ShieldPatternData(base); + clone.patterns.addAll(patterns); + return clone; + } + + @Override + public boolean isEmpty() { + return base == null && patterns.isEmpty(); + } + + @Override + public ShieldPatternData randomize(MMOItemBuilder builder) { + return this; + } } \ No newline at end of file diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/SkullTextureData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/SkullTextureData.java index 99609e39..90aeb8c4 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/SkullTextureData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/SkullTextureData.java @@ -1,24 +1,41 @@ package net.Indyuce.mmoitems.stat.data; import com.mojang.authlib.GameProfile; - import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; import net.Indyuce.mmoitems.stat.data.type.StatData; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class SkullTextureData implements StatData, RandomStatData { - private final GameProfile profile; + private GameProfile profile; - public SkullTextureData(GameProfile profile) { - this.profile = profile; - } + public SkullTextureData(GameProfile profile) { + this.profile = profile; + } - public GameProfile getGameProfile() { - return profile; - } + @Nullable + public GameProfile getGameProfile() { + return profile; + } - @Override - public SkullTextureData randomize(MMOItemBuilder builder) { - return this; - } + public void setGameProfile(@Nullable GameProfile profile) { + this.profile = profile; + } + + @NotNull + @Override + public SkullTextureData clone() { + return new SkullTextureData(profile); + } + + @Override + public boolean isEmpty() { + return profile == null; + } + + @Override + public SkullTextureData randomize(MMOItemBuilder builder) { + return this; + } } \ No newline at end of file diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/SoulboundData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/SoulboundData.java index 415b32c8..9492e2ae 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/SoulboundData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/SoulboundData.java @@ -1,51 +1,61 @@ package net.Indyuce.mmoitems.stat.data; +import com.google.gson.JsonObject; +import net.Indyuce.mmoitems.stat.data.type.StatData; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + import java.util.UUID; -import org.bukkit.entity.Player; - -import com.google.gson.JsonObject; - -import net.Indyuce.mmoitems.stat.data.type.StatData; - public class SoulboundData implements StatData { - private final UUID uuid; - private final String name; - private final int level; + private final UUID uuid; + private final String name; + private final int level; - public SoulboundData(Player player, int level) { - this(player.getUniqueId(), player.getName(), level); - } + public SoulboundData(Player player, int level) { + this(player.getUniqueId(), player.getName(), level); + } - public SoulboundData(UUID uuid, String name, int level) { - this.uuid = uuid; - this.name = name; - this.level = level; - } + public SoulboundData(UUID uuid, String name, int level) { + this.uuid = uuid; + this.name = name; + this.level = level; + } - public SoulboundData(JsonObject object) { - uuid = UUID.fromString(object.get("UUID").getAsString()); - name = object.get("Name").getAsString(); - level = object.get("Level").getAsInt(); - } + public SoulboundData(JsonObject object) { + uuid = UUID.fromString(object.get("UUID").getAsString()); + name = object.get("Name").getAsString(); + level = object.get("Level").getAsInt(); + } - public UUID getUniqueId() { - return uuid; - } + public UUID getUniqueId() { + return uuid; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public int getLevel() { - return level; - } + public int getLevel() { + return level; + } - public JsonObject toJson() { - JsonObject object = new JsonObject(); - object.addProperty("Level", level); - object.addProperty("Name", name); - object.addProperty("UUID", uuid.toString()); - return object; - } + public JsonObject toJson() { + JsonObject object = new JsonObject(); + object.addProperty("Level", level); + object.addProperty("Name", name); + object.addProperty("UUID", uuid.toString()); + return object; + } + + @NotNull + @Override + public StatData clone() { + return this; + } + + @Override + public boolean isEmpty() { + return false; + } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/SoundListData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/SoundListData.java index e3db3f63..8cf21700 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/SoundListData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/SoundListData.java @@ -5,83 +5,93 @@ import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; import net.Indyuce.mmoitems.stat.data.type.Mergeable; import net.Indyuce.mmoitems.stat.data.type.StatData; -import org.apache.commons.lang.Validate; import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; -public class SoundListData implements StatData, Mergeable, RandomStatData { - private final Map sounds; +public class SoundListData implements StatData, Mergeable, RandomStatData { + private final Map sounds = new LinkedHashMap<>(); - public SoundListData() { - this(new HashMap<>()); - } + public SoundListData() { + } - public SoundListData(Map sounds) { - this.sounds = sounds; - } + public SoundListData(@NotNull Map sounds) { + sounds.forEach(this.sounds::put); + } - public Set getCustomSounds() { - return sounds.keySet(); - } + public Set getCustomSounds() { + return sounds.keySet(); + } - public Map mapData() { - return sounds; - } + public Map mapData() { + return sounds; + } - /** - * @return Sound used, or null if none - */ - @Nullable - public SoundData get(CustomSound sound) { - return sounds.getOrDefault(sound, null); - } + /** + * @return Sound used, or null if none + */ + @Nullable + public SoundData get(CustomSound sound) { + return sounds.getOrDefault(sound, null); + } - public void set(CustomSound type, SoundData data) { - this.sounds.put(type, data); - } + public void set(CustomSound type, SoundData data) { + this.sounds.put(type, data); + } - @Override - public boolean equals(Object obj) { - if (!(obj instanceof SoundListData)) { return false; } - if (((SoundListData) obj).getCustomSounds().size() != getCustomSounds().size()) { return false; } + @Override + public boolean equals(Object obj) { + if (!(obj instanceof SoundListData)) { + return false; + } + if (((SoundListData) obj).getCustomSounds().size() != getCustomSounds().size()) { + return false; + } - for (CustomSound sound : ((SoundListData) obj).getCustomSounds()) { + for (CustomSound sound : ((SoundListData) obj).getCustomSounds()) { - if (sound == null) { continue; } + if (sound == null) { + continue; + } - boolean unmatched = true; - for (CustomSound thi : getCustomSounds()) { + boolean unmatched = true; + for (CustomSound thi : getCustomSounds()) { - if (sound.equals(thi)) { - unmatched = false; - break; } } - if (unmatched) { return false; } - } + if (sound.equals(thi)) { + unmatched = false; + break; + } + } + if (unmatched) { + return false; + } + } - return true; - } + return true; + } - @Override - public void merge(StatData data) { - Validate.isTrue(data instanceof SoundListData, "Cannot merge two different stat data types"); - SoundListData cast = (SoundListData) data; - cast.sounds.forEach(sounds::put); - } + @Override + public void mergeWith(SoundListData targetData) { + targetData.sounds.forEach(sounds::put); + } - @Override - public @NotNull StatData cloneData() { return new SoundListData(mapData()); } + @Override + @NotNull + public SoundListData clone() { + return new SoundListData(mapData()); + } - @Override - public boolean isEmpty() { - return sounds.isEmpty(); - } + @Override + public boolean isEmpty() { + return sounds.isEmpty(); + } - @Override - public SoundListData randomize(MMOItemBuilder builder) { - return new SoundListData(new HashMap<>(sounds)); - } + @Override + public SoundListData randomize(MMOItemBuilder builder) { + return new SoundListData(new HashMap<>(sounds)); + } } \ No newline at end of file diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/StoredTagsData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/StoredTagsData.java index 3c319ddb..3a94e8c2 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/StoredTagsData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/StoredTagsData.java @@ -110,12 +110,12 @@ public class StoredTagsData implements StatData, Mergeable { } @Override - public void merge(StoredTagsData data) { + public void mergeWith(StoredTagsData data) { tags.addAll(data.tags); } @Override - public StoredTagsData cloneData() { + public StoredTagsData clone() { return new StoredTagsData(getTags()); } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/StringData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/StringData.java index 4f2c9fd3..a5807c97 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/StringData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/StringData.java @@ -2,12 +2,11 @@ package net.Indyuce.mmoitems.stat.data; import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; -import net.Indyuce.mmoitems.stat.data.type.Mergeable; import net.Indyuce.mmoitems.stat.data.type.StatData; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public class StringData implements StatData, RandomStatData, Mergeable { +public class StringData implements StatData, RandomStatData { @Nullable private String value; @@ -39,16 +38,9 @@ public class StringData implements StatData, RandomStatData, Mergeab return value == null || value.isEmpty(); } - @Override - public void merge(@Nullable StringData data) { - - // Overwrite - value = data.getString(); - } - @NotNull @Override - public StringData cloneData() { + public StringData clone() { return new StringData(value); } } \ No newline at end of file diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/StringListData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/StringListData.java index 33f9b33d..5d04ca67 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/StringListData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/StringListData.java @@ -1,13 +1,7 @@ package net.Indyuce.mmoitems.stat.data; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import io.lumine.mythic.lib.api.util.ui.SilentNumbers; - import com.google.gson.JsonArray; - +import io.lumine.mythic.lib.api.util.ui.SilentNumbers; import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; import net.Indyuce.mmoitems.stat.data.type.Mergeable; @@ -15,8 +9,11 @@ import net.Indyuce.mmoitems.stat.data.type.StatData; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public class StringListData implements StatData, RandomStatData, Mergeable { - @NotNull private final List list; +import java.util.ArrayList; +import java.util.List; + +public class StringListData implements StatData, Mergeable, RandomStatData { + @NotNull private final List list = new ArrayList<>(); @Override public boolean equals(Object obj) { @@ -26,21 +23,18 @@ public class StringListData implements StatData, RandomStatData, } public StringListData() { - this(new ArrayList<>()); } public StringListData(@NotNull String[] array) { - this(Arrays.asList(array)); + for (String str : array) this.list.add(str); } public StringListData(@NotNull JsonArray array) { - this(); - array.forEach(str -> list.add(str.getAsString())); } public StringListData(@NotNull List list) { - this.list = list; + this.list.addAll(list); } @NotNull public List getList() { @@ -53,13 +47,13 @@ public class StringListData implements StatData, RandomStatData, } @Override - public void merge(StringListData data) { + public void mergeWith(StringListData data) { list.addAll(data.list); } @Override @NotNull - public StringListData cloneData() { return new StringListData(new ArrayList<>(getList())); } + public StringListData clone() { return new StringListData(list); } @Override public boolean isEmpty() { return list.isEmpty(); } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/UpgradeData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/UpgradeData.java index f70ab911..3d2e7f4e 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/UpgradeData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/UpgradeData.java @@ -18,7 +18,7 @@ import org.jetbrains.annotations.Nullable; *

• Chance of successful upgrade *

• May it get destroyed if unsucessful upgrade? */ -public class UpgradeData implements StatData, RandomStatData, Cloneable { +public class UpgradeData implements StatData, RandomStatData { /** * @return The String a consumable must match to Upgrade this Item @@ -149,6 +149,11 @@ public class UpgradeData implements StatData, RandomStatData, Clone return reference == null || data.reference == null || reference.isEmpty() || data.reference.isEmpty() || reference.equals(data.reference); } + @Override + public boolean isEmpty() { + return false; + } + /** * Upgrade this MMOItem by 1 Level */ @@ -197,7 +202,6 @@ public class UpgradeData implements StatData, RandomStatData, Clone @Override public UpgradeData clone() { - try { super.clone(); } catch (CloneNotSupportedException ignored) { } - - return new UpgradeData(reference, template, workbench, destroy, max, min, success); } + return new UpgradeData(reference, template, workbench, destroy, max, min, success); + } } \ No newline at end of file diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/UpdatableRandomStatData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/UpdatableRandomStatData.java index 8c4620fe..796d236a 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/UpdatableRandomStatData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/UpdatableRandomStatData.java @@ -1,6 +1,5 @@ package net.Indyuce.mmoitems.stat.data.random; -import net.Indyuce.mmoitems.stat.data.type.Mergeable; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.ItemStat; import org.jetbrains.annotations.NotNull; @@ -32,7 +31,7 @@ public interface UpdatableRandomStatData { * @param determinedItemLevel The level of the item * @return The rerolled StatData if the original is unreasonable. *

- * If the original is reasonable, a clone of it, probably using {@link Mergeable#cloneData()} + * If the original is reasonable, a clone of it, probably using {@link StatData#clone()} */ @NotNull S reroll(@NotNull ItemStat stat, @NotNull S original, int determinedItemLevel); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/type/Mergeable.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/type/Mergeable.java index 9b102d84..4a3c779f 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/type/Mergeable.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/type/Mergeable.java @@ -6,38 +6,30 @@ import org.jetbrains.annotations.NotNull; /** * Most intuitive use is for ItemStats to not completely replace each other - * when used through Gem Stones. However, this serves a crucial internal - * role in determining which stats generate {@link StatHistory}'s, which in - * turn allows them to be {@link Upgradable}. + * when used through Gem Stones. This could happen for very complex options + * like arrow particles, where only the while stat component makes sense (and + * those behaviours are hardcoded for simplicity), but most of the time they + * add up and get merged. + *

+ * This serves a crucial internal role in determining which stats generate + * {@link StatHistory}'s, which in turn allows them to be {@link Upgradable}. *

* Strongly encouraged to override the equals method * to something fitting here as Mergeable stats should support comparisons. - * - * @deprecated All stat datas should be mergeable. Refactor planned for MI7 */ -@Deprecated public interface Mergeable extends StatData { /** - * Merging two stat data is used when either applying a gem stone to an item - * which already has this type of item data, or when generating an item - * randomly so that the item benefits from all modifiers + * Merging two stat datas is required when an item benefits from + * a buff in a stat, given by + * - the base item data + 1 modifier + * - at least 2 modifiers */ - void merge(S data); + void mergeWith(S data); /** * Returns a Data with the same values as this, but that is not this. */ @NotNull - S cloneData(); - - /** - * @return true If this is the default state of the StatData, like an enchantment - * list data having 0 enchantments, or a percent bonus double stat having a value of 0. - */ - @Deprecated - default boolean isClear() { - // Backwards compatibility - return isEmpty(); - } + S clone(); } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/type/StatData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/type/StatData.java index 33405d57..a1353a7d 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/type/StatData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/type/StatData.java @@ -5,6 +5,13 @@ package net.Indyuce.mmoitems.stat.data.type; *

* These are paired with an ItemStat to mean something, * they then become the value of such ItemStat. + *

+ * A stat data is enough to calculate the effects of a given item onto a + * player but it not sufficient to take into accoun the full history of + * an item. + * + * @author jules + * @see {@link net.Indyuce.mmoitems.stat.type.StatHistory} */ public interface StatData { @@ -12,8 +19,5 @@ public interface StatData { * @return true If this is the default state of the StatData, like an enchantment * list data having 0 enchantments, or a percent bonus double stat having a value of 0. */ - default boolean isEmpty() { - // Backwards compatibility - return this instanceof Mergeable && ((Mergeable) this).isClear(); - } + public boolean isEmpty(); } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/type/UpgradeInfo.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/type/UpgradeInfo.java index 14c7c8cd..fcdeea5b 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/type/UpgradeInfo.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/type/UpgradeInfo.java @@ -1,6 +1,8 @@ package net.Indyuce.mmoitems.stat.data.type; /** - * Parsed from the configs into providing a StatData all the changes each upgrade will give it. + * Parsed from the configs into providing a StatData + * all the changes each upgrade will give it. */ -public interface UpgradeInfo { } +public interface UpgradeInfo { +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/NameData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/NameData.java index 50188050..b55ac6f0 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/NameData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/NameData.java @@ -1,10 +1,8 @@ package net.Indyuce.mmoitems.stat.type; import io.lumine.mythic.lib.api.item.ItemTag; -import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.data.type.Mergeable; -import net.Indyuce.mmoitems.stat.data.type.StatData; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -13,7 +11,7 @@ import java.util.ArrayList; /** * Data that stores what an item is originally named like and prefixes or whatever. */ -public class NameData extends StringData implements Mergeable { +public class NameData extends StringData implements Mergeable { public NameData(@NotNull String str) { super(str); } @@ -109,29 +107,20 @@ public class NameData extends StringData implements Mergeable { @NotNull public ArrayList getSuffixes() { return suffixes; } @Override - public void merge(StringData data) { - - // Assimilate - if (data instanceof NameData) { - - // Replace name if not empty - if (!((NameData) data).getMainName().isEmpty()) { setString(((NameData) data).getMainName()); } - - // Assimilate - for (String p : ((NameData) data).getPrefixes()) { addPrefix(p);} - for (String p : ((NameData) data).getSuffixes()) { addSuffix(p);} - - } else if (data instanceof StringData) { - + public void mergeWith(NameData data) { + if (!data.getMainName().isEmpty()) setString(data.getMainName()); + for (String p : data.getPrefixes()) addPrefix(p); + for (String p : data.getSuffixes()) addSuffix(p); + /* } else if (data instanceof StringData) { // Replace name if not empty if (data.toString().isEmpty()) { return; } setString(data.toString()); - } + }*/ } @NotNull @Override - public StringData cloneData() { + public NameData clone() { NameData c = new NameData(getMainName()); for (String p : getPrefixes()) { c.addPrefix(p);} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/StatHistory.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/StatHistory.java index 5681a38e..f138e2b4 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/StatHistory.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/StatHistory.java @@ -257,20 +257,13 @@ public class StatHistory { } /** - * Collapses all ExSH stat data into one. + * Collapses all external stat datas into only one. */ public void consolidateEXSH() { // Create Clear StatData theEXSH = getItemStat().getClearStatData(); - - // Merge All - for (StatData ex : getExternalData()) { - if (ex == null) { - continue; - } - ((Mergeable) theEXSH).merge(ex); - } + for (StatData ex : getExternalData()) if (ex != null) ((Mergeable) theEXSH).mergeWith(ex); // Clear and Register getExternalData().clear(); @@ -353,7 +346,7 @@ public class StatHistory { //UPGRD//MMOItems.log("\u00a7e +\u00a77 Item didnt have this stat, original set as blanc."); } else { - original = ((Mergeable) original).cloneData(); + original = ((Mergeable) original).clone(); //UPGRD//MMOItems.log("\u00a7a +\u00a77 Found original data\u00a7f " + original); } //LVL//MMOItems.log(" \u00a7d*\u00a77-\u00a7a-\u00a763? \u00a77Lvl: \u00a7b" + ofItem.getUpgradeLevel() + "\u00a7d-\u00a77-\u00a7a-\u00a7d-\u00a77-\u00a7a-"); @@ -548,7 +541,7 @@ public class StatHistory { } // Clone original - StatData ogCloned = ((Mergeable) originalData).cloneData(); + StatData ogCloned = ((Mergeable) originalData).clone(); //DBL//if (ogCloned instanceof DoubleData) MMOItems.log("\u00a76 >\u00a77 Original Base: \u00a7e" + ((DoubleData) ogCloned).getValue() + "\u00a78 {Original:\u00a77 " + ((DoubleData) getOriginalData()).getValue() + "\u00a78}"); // Add Modifiers (who are affected by upgrades as if they was the base item data @@ -556,7 +549,7 @@ public class StatHistory { //DBL//if (getModifiersBonus() instanceof DoubleData) MMOItems.log("\u00a76 >\u00a7c> \u00a77 Modifier Base: \u00a7e" + ((DoubleData) getModifiersBonus()).getValue()); // Just merge ig - ((Mergeable) ogCloned).merge(((Mergeable) getModifiersBonus(d)).cloneData()); + ((Mergeable) ogCloned).mergeWith(((Mergeable) getModifiersBonus(d)).clone()); } // Level up @@ -602,11 +595,11 @@ public class StatHistory { //DBL//if (getGemstoneData(d) instanceof DoubleData) MMOItems.log("\u00a76 \u00a7b|>\u00a77 Gemstone Base: \u00a7e" + ((DoubleData) getGemstoneData(d)).getValue()); // Apply upgrades //noinspection ConstantConditions - StatData gRet = ((Upgradable) getItemStat()).apply(((Mergeable) getGemstoneData(d)).cloneData(), inf, gLevel); + StatData gRet = ((Upgradable) getItemStat()).apply(((Mergeable) getGemstoneData(d)).clone(), inf, gLevel); //DBL//if (gRet instanceof DoubleData) MMOItems.log("\u00a76 \u00a7b|>\u00a77 Leveled Base: \u00a7e" + ((DoubleData) gRet).getValue()); // Merge - ((Mergeable) ret).merge(((Mergeable) gRet).cloneData()); + ((Mergeable) ret).mergeWith(((Mergeable) gRet).clone()); } // Add up externals (who dont suffer upgrades @@ -614,7 +607,7 @@ public class StatHistory { //DBL//if (d instanceof DoubleData) MMOItems.log("\u00a76 >\u00a7c> \u00a77 Extraneous Base: \u00a7e" + ((DoubleData) d).getValue()); // Just merge ig - ((Mergeable) ret).merge(((Mergeable) d).cloneData()); + ((Mergeable) ret).mergeWith(((Mergeable) d).clone()); } // Return result @@ -635,7 +628,7 @@ public class StatHistory { //RECALCULATE//MMOItems.log("\u00a73|||\u00a77 Calculating \u00a7f" + getItemStat().getNBTPath() + "\u00a77 as Mergeable"); // Just clone bro - StatData ret = ((Mergeable) getOriginalData()).cloneData(); + StatData ret = ((Mergeable) getOriginalData()).clone(); //DBL//if (ret instanceof DoubleData) MMOItems.log("\u00a73 > \u00a77 Original Base: \u00a7e" + ((DoubleData) ret).getValue()); @@ -643,19 +636,19 @@ public class StatHistory { for (StatData d : perModifierBonus.values()) { //DBL//if (getModifiersBonus() instanceof DoubleData) MMOItems.log("\u00a73 >\u00a7c> \u00a77 Modifier Base: \u00a7e" + ((DoubleData) getModifiersBonus()).getValue()); // Just merge ig - ((Mergeable) ret).merge(((Mergeable) d).cloneData()); + ((Mergeable) ret).mergeWith(((Mergeable) d).clone()); } // Add up gemstones for (StatData d : perGemstoneData.values()) { //DBL//if (d instanceof DoubleData) MMOItems.log("\u00a73 >\u00a7b> \u00a77 Gemstone Base: \u00a7e" + ((DoubleData) d).getValue()); - ((Mergeable) ret).merge(((Mergeable) d).cloneData()); + ((Mergeable) ret).mergeWith(((Mergeable) d).clone()); } // Add up externals for (StatData d : getExternalData()) { //DBL//if (d instanceof DoubleData) MMOItems.log("\u00a73 >\u00a7c> \u00a77 Extraneous Base: \u00a7e" + ((DoubleData) d).getValue()); - ((Mergeable) ret).merge(((Mergeable) d).cloneData()); + ((Mergeable) ret).mergeWith(((Mergeable) d).clone()); } // Return result @@ -689,7 +682,7 @@ public class StatHistory { * And allows net.Indyuce.mmoitems.stat.Enchants.whenLoaded() to correctly initialize the * StatHistory of these items. */ - if (!((Mergeable) getOriginalData()).isClear() || getItemStat() == ItemStats.ENCHANTS) { + if (!getOriginalData().isEmpty() || getItemStat() == ItemStats.ENCHANTS) { object.add(enc_OGS, ItemTag.compressTags(getItemStat().getAppliedNBT(getOriginalData()))); } @@ -726,7 +719,7 @@ public class StatHistory { for (StatData ex : getExternalData()) { // Skip clear - if (((Mergeable) ex).isClear()) { + if (ex.isEmpty()) { continue; } @@ -1078,7 +1071,7 @@ public class StatHistory { public StatHistory clone(@NotNull MMOItem clonedMMOItem) { // Clone - StatHistory res = new StatHistory(clonedMMOItem, getItemStat(), ((Mergeable) getOriginalData()).cloneData()); + StatHistory res = new StatHistory(clonedMMOItem, getItemStat(), ((Mergeable) getOriginalData()).clone()); // Add all for (UUID uid : getAllGemstones()) { @@ -1092,7 +1085,7 @@ public class StatHistory { } // Clone - res.registerGemstoneData(uid, ((Mergeable) gem).cloneData()); + res.registerGemstoneData(uid, ((Mergeable) gem).clone()); } // Add all @@ -1102,7 +1095,7 @@ public class StatHistory { } // Clone - res.registerExternalData(((Mergeable) ex).cloneData()); + res.registerExternalData(((Mergeable) ex).clone()); } // Clone @@ -1118,7 +1111,7 @@ public class StatHistory { } // Clone - res.registerModifierBonus(uid, ((Mergeable) mod).cloneData()); + res.registerModifierBonus(uid, ((Mergeable) mod).clone()); } // Thats it diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/Upgradable.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/Upgradable.java index 0f30ca58..1ab36fbb 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/Upgradable.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/Upgradable.java @@ -1,7 +1,6 @@ package net.Indyuce.mmoitems.stat.type; import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem; -import net.Indyuce.mmoitems.stat.data.type.Mergeable; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.data.type.UpgradeInfo; import org.jetbrains.annotations.NotNull; @@ -10,7 +9,7 @@ import org.jetbrains.annotations.Nullable; /** * The methods required for this ItemStat to be Upgradeable.

* It makes sense then that the StatData this uses - * implements {@link Mergeable} and it is even assumed so. + * implements {@link StatData} and it is even assumed so. * * An upgradable stat can be used in an upgrade template to be upgraded * diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/MMOUtils.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/MMOUtils.java index 08fa1fec..e2b0842c 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/MMOUtils.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/MMOUtils.java @@ -11,7 +11,9 @@ import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.skill.trigger.TriggerType; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.Type; +import net.Indyuce.mmoitems.stat.data.type.StatData; import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang.Validate; import org.bukkit.*; import org.bukkit.attribute.Attribute; import org.bukkit.entity.Entity; diff --git a/MMOItems-Dist/src/main/java/net/Indyuce/mmoitems/listener/reforging/RFGKeepEnchantments.java b/MMOItems-Dist/src/main/java/net/Indyuce/mmoitems/listener/reforging/RFGKeepEnchantments.java index 16fdeed1..ed0fa6f0 100644 --- a/MMOItems-Dist/src/main/java/net/Indyuce/mmoitems/listener/reforging/RFGKeepEnchantments.java +++ b/MMOItems-Dist/src/main/java/net/Indyuce/mmoitems/listener/reforging/RFGKeepEnchantments.java @@ -7,7 +7,6 @@ import net.Indyuce.mmoitems.api.event.MMOItemReforgeEvent; import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem; import net.Indyuce.mmoitems.stat.Enchants; import net.Indyuce.mmoitems.stat.data.EnchantListData; -import net.Indyuce.mmoitems.stat.data.type.Mergeable; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.StatHistory; import org.bukkit.enchantments.Enchantment; @@ -15,8 +14,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.jetbrains.annotations.NotNull; -import java.util.UUID; - /** * Transfers enchantments from the old MMOItem to the new one. * @@ -47,7 +44,7 @@ public class RFGKeepEnchantments implements Listener { // Gather StatHistory hist = StatHistory.from(operable, ItemStats.ENCHANTS); - EnchantListData maybeOriginalEnchs = (EnchantListData) ((Mergeable) hist.getOriginalData()).cloneData(); + EnchantListData maybeOriginalEnchs = ((EnchantListData) hist.getOriginalData()).clone(); //RFG//MMOItems.log(" \u00a7b*** \u00a77Enchantments in old item:"); //RFG//hist.log(); diff --git a/MMOItems-Dist/src/main/java/net/Indyuce/mmoitems/listener/reforging/RFGKeepGems.java b/MMOItems-Dist/src/main/java/net/Indyuce/mmoitems/listener/reforging/RFGKeepGems.java index 84e14bde..35ac5d80 100644 --- a/MMOItems-Dist/src/main/java/net/Indyuce/mmoitems/listener/reforging/RFGKeepGems.java +++ b/MMOItems-Dist/src/main/java/net/Indyuce/mmoitems/listener/reforging/RFGKeepGems.java @@ -141,7 +141,7 @@ public class RFGKeepGems implements Listener { if (data instanceof Mergeable) { // Just ignore that lol - if (data instanceof EnchantListData && ((Mergeable) data).isClear()) { continue; } + if (data instanceof EnchantListData && data.isEmpty()) { continue; } //RFG//MMOItems.log("\u00a79>>> \u00a77Gem-Merging \u00a7c" + stat.getNBTPath() + "\u00a7e" + data.toString() + "\u00a78 " + reforgedGemData.getHistoricUUID().toString()); diff --git a/MMOItems-Dist/src/main/java/net/Indyuce/mmoitems/listener/reforging/RFGKeepModifications.java b/MMOItems-Dist/src/main/java/net/Indyuce/mmoitems/listener/reforging/RFGKeepModifications.java index 0ff1e2ba..28c7d2de 100644 --- a/MMOItems-Dist/src/main/java/net/Indyuce/mmoitems/listener/reforging/RFGKeepModifications.java +++ b/MMOItems-Dist/src/main/java/net/Indyuce/mmoitems/listener/reforging/RFGKeepModifications.java @@ -45,7 +45,7 @@ public class RFGKeepModifications implements Listener { if (modData == null) { continue; } // Apply it - newHist.registerModifierBonus(mod, ((Mergeable) modData).cloneData()); + newHist.registerModifierBonus(mod, ((Mergeable) modData).clone()); } } }