Fixed revid-ed items not stacking

This commit is contained in:
Jules 2024-08-26 22:05:22 -07:00
parent ee27b4d566
commit 0099a415fa
3 changed files with 12 additions and 13 deletions

View File

@ -130,9 +130,8 @@ public class ItemStackBuilder {
* Enchantment data must never be clear and lack history. This is
* the basis for when an item is 'old'
*/
if (!builtMMOItem.hasData(ItemStats.ENCHANTS)) {
builtMMOItem.setData(ItemStats.ENCHANTS, ItemStats.ENCHANTS.getClearStatData());
}
builtMMOItem.computeData(ItemStats.ENCHANTS);
builtMMOItem.computeStatHistory(ItemStats.ENCHANTS);
//GEM// else {MMOItems.log("\u00a73 -?- \u00a77Apparently found enchantment data \u00a7b" + (mmoitem.getData(ItemStats.ENCHANTS) == null ? "null" : ((EnchantListData) mmoitem.getData(ItemStats.ENCHANTS)).getEnchants().size())); }
/*
@ -140,9 +139,8 @@ public class ItemStackBuilder {
* through non-MMOItems supported sources, the name can be changed in
* an anvil, so the very original name must be saved.
*/
if (!builtMMOItem.hasData(ItemStats.NAME))
builtMMOItem.setData(ItemStats.NAME, ItemStats.NAME.getClearStatData());
builtMMOItem.computeStatHistory(ItemStats.NAME); // Ignore result
builtMMOItem.computeData(ItemStats.NAME);
builtMMOItem.computeStatHistory(ItemStats.NAME);
// For every stat within this item
for (ItemStat stat : builtMMOItem.getStats())

View File

@ -4,7 +4,6 @@ import net.Indyuce.mmoitems.ItemStats;
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 org.apache.commons.lang.Validate;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.jetbrains.annotations.NotNull;
@ -89,7 +88,7 @@ public class EnchantListData implements StatData, Mergeable<EnchantListData> {
final AtomicBoolean check = new AtomicBoolean();
enchants.forEach((enchant, lvl) -> {
if (check.get()) builder.append(",");
builder.append(enchant + "=" + lvl);
builder.append(enchant).append("=").append(lvl);
check.set(true);
});
builder.append("}");
@ -138,11 +137,7 @@ public class EnchantListData implements StatData, Mergeable<EnchantListData> {
return;
}
if (!mmoItem.hasData(ItemStats.ENCHANTS)) {
mmoItem.setData(ItemStats.ENCHANTS, new EnchantListData());
}
EnchantListData mmoData = (EnchantListData) mmoItem.getData(ItemStats.ENCHANTS);
EnchantListData mmoData = (EnchantListData) mmoItem.computeData(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) {

View File

@ -141,6 +141,8 @@ public class StatHistory {
public void registerModifierBonus(@NotNull UUID of, @NotNull StatData data) {
Validate.notNull(of, "Modifier UUID cannot be null");
Validate.notNull(data, "Stat data cannot be null");
if (data.isEmpty()) return;
perModifierBonus.put(of, data);
}
@ -205,6 +207,8 @@ public class StatHistory {
public void registerGemstoneData(@NotNull UUID of, @NotNull StatData data) {
Validate.notNull(of, "Gemstone ID cannot be null");
Validate.notNull(data, "Stat data cannot be null");
if (data.isEmpty()) return;
perGemstoneData.put(of, data);
}
@ -255,6 +259,8 @@ public class StatHistory {
*/
public void registerExternalData(@NotNull StatData data) {
Validate.notNull(data, "Stat data cannot be null");
if (data.isEmpty()) return;
perExternalData.add(data);
}