mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-01-03 06:37:47 +01:00
Fixed enchants not working inside modifiers
This commit is contained in:
parent
890e3b97de
commit
16d93e244d
@ -135,7 +135,7 @@ public class UpgradeTemplate {
|
|||||||
((Upgradable) stat).preprocess(mmoitem);
|
((Upgradable) stat).preprocess(mmoitem);
|
||||||
|
|
||||||
// Initializes Stat History
|
// Initializes Stat History
|
||||||
StatHistory hist = StatHistory.from(mmoitem, stat);
|
StatHistory hist = mmoitem.computeStatHistory(stat);
|
||||||
//UPGR//MMOItems.log(" \u00a73>\u00a7a> \u00a77Stat History Initialized");
|
//UPGR//MMOItems.log(" \u00a73>\u00a7a> \u00a77Stat History Initialized");
|
||||||
|
|
||||||
// Midprocess
|
// Midprocess
|
||||||
|
@ -102,7 +102,7 @@ public class GemStone extends UseItem {
|
|||||||
* Now must apply the gem sockets data to the Stat History and then recalculate.
|
* Now must apply the gem sockets data to the Stat History and then recalculate.
|
||||||
* Gotta, however, find the correct StatData to which apply it to.
|
* Gotta, however, find the correct StatData to which apply it to.
|
||||||
*/
|
*/
|
||||||
StatHistory gemStory = StatHistory.from(targetMMO, ItemStats.GEM_SOCKETS);
|
StatHistory gemStory = targetMMO.computeStatHistory(ItemStats.GEM_SOCKETS);
|
||||||
findEmptySocket(gemStory, gemType, gemData);
|
findEmptySocket(gemStory, gemType, gemData);
|
||||||
targetMMO.setData(ItemStats.GEM_SOCKETS, gemStory.recalculate(targetMMO.getUpgradeLevel()));
|
targetMMO.setData(ItemStats.GEM_SOCKETS, gemStory.recalculate(targetMMO.getUpgradeLevel()));
|
||||||
|
|
||||||
|
@ -28,10 +28,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class ItemStackBuilder {
|
public class ItemStackBuilder {
|
||||||
@ -82,10 +79,10 @@ public class ItemStackBuilder {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Does NOT return the built item stack. It returns only returns the
|
* @return Does NOT return the built item stack. It returns only returns the
|
||||||
* default item stack with material applied. Built item stack is given
|
* default item stack with material applied. Built item stack is given
|
||||||
* by build(). This method should only be used to check if the item is
|
* by build(). This method should only be used to check if the item is
|
||||||
* of a specific material (like the Shield Pattern stat which checks if
|
* of a specific material (like the Shield Pattern stat which checks if
|
||||||
* the item is a shield)
|
* the item is a shield)
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public ItemStack getItemStack() {
|
public ItemStack getItemStack() {
|
||||||
@ -140,12 +137,9 @@ public class ItemStackBuilder {
|
|||||||
* through non-MMOItems supported sources, the name can be changed in
|
* through non-MMOItems supported sources, the name can be changed in
|
||||||
* an anvil, so the very original name must be saved.
|
* an anvil, so the very original name must be saved.
|
||||||
*/
|
*/
|
||||||
if (!builtMMOItem.hasData(ItemStats.NAME)) {
|
if (!builtMMOItem.hasData(ItemStats.NAME))
|
||||||
builtMMOItem.setData(ItemStats.NAME, ItemStats.NAME.getClearStatData());
|
builtMMOItem.setData(ItemStats.NAME, ItemStats.NAME.getClearStatData());
|
||||||
}
|
builtMMOItem.computeStatHistory(ItemStats.NAME); // Ignore result
|
||||||
if (builtMMOItem.getStatHistory(ItemStats.NAME) == null) {
|
|
||||||
StatHistory.from(builtMMOItem, ItemStats.NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
// For every stat within this item
|
// For every stat within this item
|
||||||
for (ItemStat stat : builtMMOItem.getStats())
|
for (ItemStat stat : builtMMOItem.getStats())
|
||||||
@ -156,10 +150,10 @@ public class ItemStackBuilder {
|
|||||||
|
|
||||||
// Does the item have any stat history regarding thay?
|
// Does the item have any stat history regarding thay?
|
||||||
StatHistory s = builtMMOItem.getStatHistory(stat);
|
StatHistory s = builtMMOItem.getStatHistory(stat);
|
||||||
int l = mmoitem.getUpgradeLevel();
|
|
||||||
|
|
||||||
// Found it?
|
// Found it?
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
|
int l = mmoitem.getUpgradeLevel();
|
||||||
//GEM//MMOItems.log("\u00a7a -+- \u00a77History exists...");
|
//GEM//MMOItems.log("\u00a7a -+- \u00a77History exists...");
|
||||||
//GEM//s.log();
|
//GEM//s.log();
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ public class MMOItemBuilder extends Buildable<MMOItem> {
|
|||||||
if (!nameModifiers.isEmpty()) {
|
if (!nameModifiers.isEmpty()) {
|
||||||
|
|
||||||
// Get name data
|
// Get name data
|
||||||
StatHistory hist = StatHistory.from(mmoitem, ItemStats.NAME);
|
StatHistory hist = mmoitem.computeStatHistory(ItemStats.NAME);
|
||||||
|
|
||||||
nameModifiers.forEach((obs, mod) -> {
|
nameModifiers.forEach((obs, mod) -> {
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ public class MMOItemBuilder extends Buildable<MMOItem> {
|
|||||||
*/
|
*/
|
||||||
public void addModifierData(@NotNull ItemStat stat, @NotNull StatData data, @NotNull UUID uuid) {
|
public void addModifierData(@NotNull ItemStat stat, @NotNull StatData data, @NotNull UUID uuid) {
|
||||||
if (stat.getClearStatData() instanceof Mergeable)
|
if (stat.getClearStatData() instanceof Mergeable)
|
||||||
StatHistory.from(mmoitem, stat).registerModifierBonus(uuid, data);
|
mmoitem.computeStatHistory(stat).registerModifierBonus(uuid, data);
|
||||||
else mmoitem.setData(stat, data);
|
else mmoitem.setData(stat, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class LiveMMOItem extends ReadMMOItem {
|
|||||||
stat.whenLoaded(this);
|
stat.whenLoaded(this);
|
||||||
|
|
||||||
// History not prematurely loaded?
|
// History not prematurely loaded?
|
||||||
if (getStatHistory(stat) == null) {
|
if (!hasStatHistory(stat)) {
|
||||||
|
|
||||||
// Also load history :think ing:
|
// Also load history :think ing:
|
||||||
ItemTag hisTag = ItemTag.getTagAtPath(ItemStackBuilder.history_keyword + stat.getId(), getNBT(), SupportedNBTTagValues.STRING);
|
ItemTag hisTag = ItemTag.getTagAtPath(ItemStackBuilder.history_keyword + stat.getId(), getNBT(), SupportedNBTTagValues.STRING);
|
||||||
|
@ -11,7 +11,6 @@ import net.Indyuce.mmoitems.api.item.ItemReference;
|
|||||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||||
import net.Indyuce.mmoitems.tooltip.TooltipTexture;
|
import net.Indyuce.mmoitems.tooltip.TooltipTexture;
|
||||||
import net.Indyuce.mmoitems.api.util.MMOItemReforger;
|
import net.Indyuce.mmoitems.api.util.MMOItemReforger;
|
||||||
import net.Indyuce.mmoitems.stat.Enchants;
|
|
||||||
import net.Indyuce.mmoitems.stat.data.*;
|
import net.Indyuce.mmoitems.stat.data.*;
|
||||||
import net.Indyuce.mmoitems.stat.data.type.Mergeable;
|
import net.Indyuce.mmoitems.stat.data.type.Mergeable;
|
||||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||||
@ -71,18 +70,16 @@ public class MMOItem implements ItemReference {
|
|||||||
* stored as a GemStone in the history, allowing to be removed from the item with that same UUID.
|
* stored as a GemStone in the history, allowing to be removed from the item with that same UUID.
|
||||||
*/
|
*/
|
||||||
public void mergeData(@NotNull ItemStat stat, @NotNull StatData data, @Nullable UUID associatedGemStone) {
|
public void mergeData(@NotNull ItemStat stat, @NotNull StatData data, @Nullable UUID associatedGemStone) {
|
||||||
boolean bc = stat.equals(ItemStats.ABILITIES);
|
|
||||||
|
|
||||||
// Merge if possible, otherwise write over
|
// Merge if possible, otherwise write over
|
||||||
if (data instanceof Mergeable) {
|
if (data instanceof Mergeable) {
|
||||||
|
|
||||||
// Prepare to merge, gather history
|
// Prepare to merge, gather history
|
||||||
StatHistory sHistory = StatHistory.from(this, stat);
|
StatHistory sHistory = computeStatHistory(stat);
|
||||||
if (associatedGemStone != null) sHistory.registerGemstoneData(associatedGemStone, data);
|
if (associatedGemStone != null) sHistory.registerGemstoneData(associatedGemStone, data);
|
||||||
else sHistory.registerExternalData(data);
|
else sHistory.registerExternalData(data);
|
||||||
setData(stat, sHistory.recalculate(getUpgradeLevel()));
|
setData(stat, sHistory.recalculate(getUpgradeLevel()));
|
||||||
} else
|
} else setData(stat, data);
|
||||||
setData(stat, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setData(@NotNull ItemStat stat, @NotNull StatData data) {
|
public void setData(@NotNull ItemStat stat, @NotNull StatData data) {
|
||||||
@ -97,10 +94,16 @@ public class MMOItem implements ItemReference {
|
|||||||
stats.remove(stat);
|
stats.remove(stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public StatData getData(@NotNull ItemStat stat) {
|
public StatData getData(@NotNull ItemStat stat) {
|
||||||
return stats.get(stat);
|
return stats.get(stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public StatData computeData(@NotNull ItemStat<?, ?> stat) {
|
||||||
|
return stats.computeIfAbsent(stat, ItemStat::getClearStatData);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasData(@NotNull ItemStat stat) {
|
public boolean hasData(@NotNull ItemStat stat) {
|
||||||
return (stats.get(stat) != null);
|
return (stats.get(stat) != null);
|
||||||
}
|
}
|
||||||
@ -132,66 +135,51 @@ public class MMOItem implements ItemReference {
|
|||||||
@SuppressWarnings("MethodDoesntCallSuperMethod")
|
@SuppressWarnings("MethodDoesntCallSuperMethod")
|
||||||
@Override
|
@Override
|
||||||
public MMOItem clone() {
|
public MMOItem clone() {
|
||||||
MMOItem clone = new MMOItem(type, id);
|
// TODO deep clone
|
||||||
|
final MMOItem clone = new MMOItem(type, id);
|
||||||
// Clone them stats and histories
|
// Clone stats
|
||||||
for (ItemStat stat : stats.keySet()) {
|
clone.stats.putAll(this.stats);
|
||||||
|
// CLone stat histories
|
||||||
// Copy Stat Datas themselves
|
mergeableStatHistory.forEach((stat, hist) -> clone.mergeableStatHistory.put(stat, hist.clone().setParent(clone)));
|
||||||
clone.stats.put(stat, stats.get(stat));
|
|
||||||
|
|
||||||
// Copy Histories
|
|
||||||
StatHistory hist = getStatHistory(stat);
|
|
||||||
if (hist != null) {
|
|
||||||
final StatHistory histClone = hist.clone();
|
|
||||||
histClone.setParent(clone);
|
|
||||||
clone.setStatHistory(stat, histClone);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Thats it
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
//region Stat History Stuff
|
//region Stat History Stuff
|
||||||
/*
|
/**
|
||||||
* When merging stats (like applying a gemstone), the item must remember which were
|
* When merging stats (like applying a gemstone), the item must remember which were
|
||||||
* its original stats, and from which gem stone came each stat, in order to allow
|
* its original stats, and from which gem stone came each stat, in order to allow
|
||||||
* removal of gem stones in the future. This is where that is remembered.
|
* removal of gem stones in the future. This is where that is remembered.
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
private final Map<ItemStat, StatHistory> mergeableStatHistory = new HashMap<>();
|
private final Map<ItemStat<?, ?>, StatHistory> mergeableStatHistory = new HashMap<>();
|
||||||
|
|
||||||
|
public boolean hasStatHistory(@NotNull ItemStat<?, ?> stat) {
|
||||||
|
return stat instanceof Mergeable && mergeableStatHistory.containsKey(stat);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public StatHistory getStatHistory(@NotNull ItemStat<?, ?> stat) {
|
||||||
|
|
||||||
|
// TODO refactor
|
||||||
|
if (stat.equals(ItemStats.ENCHANTS)) return computeStatHistory(stat);
|
||||||
|
|
||||||
|
return mergeableStatHistory.get(stat);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the history associated to this stat, if there is any
|
* Gets the history associated to this stat, if there is any.
|
||||||
* <p></p>
|
|
||||||
* A stat history is basically the memory of its original stats,
|
* A stat history is basically the memory of its original stats,
|
||||||
* from when it was created, its gemstone stats,
|
* from when it was created, its gemstone stats, those added by
|
||||||
* those added by which gem, and its upgrade bonuses.
|
* which gem, and its bonuses due to upgrades.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@NotNull
|
||||||
public StatHistory getStatHistory(@NotNull ItemStat stat) {
|
public StatHistory computeStatHistory(@NotNull ItemStat<?, ?> stat) {
|
||||||
|
return mergeableStatHistory.computeIfAbsent(stat, itemStat -> {
|
||||||
/*
|
final StatData currentData = computeData(itemStat);
|
||||||
* As an assumption for several enchantment recognition operations,
|
Validate.isTrue(currentData instanceof Mergeable, "Stat " + itemStat.getId() + " is not mergeable");
|
||||||
* Enchantment data must never be clear and lack history. This is
|
return new StatHistory(this, itemStat, currentData);
|
||||||
* the basis for when an item is 'old'
|
});
|
||||||
*/
|
|
||||||
if (stat instanceof Enchants)
|
|
||||||
return mergeableStatHistory.getOrDefault(stat, StatHistory.from(this, stat, true));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Normal stat, just fetch.
|
|
||||||
*/
|
|
||||||
try {
|
|
||||||
|
|
||||||
// Well that REALLY should work
|
|
||||||
return mergeableStatHistory.get(stat);
|
|
||||||
|
|
||||||
} catch (ClassCastException ignored) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@ -394,27 +382,23 @@ public class MMOItem implements ItemReference {
|
|||||||
|
|
||||||
// Found?
|
// Found?
|
||||||
final @Nullable GemSocketsData thisSocketsData = (GemSocketsData) getData(ItemStats.GEM_SOCKETS);
|
final @Nullable GemSocketsData thisSocketsData = (GemSocketsData) getData(ItemStats.GEM_SOCKETS);
|
||||||
if (thisSocketsData == null)
|
if (thisSocketsData == null) return new ArrayList<>();
|
||||||
return new ArrayList<>();
|
|
||||||
|
|
||||||
// Find restored items
|
// Find restored items
|
||||||
final List<Pair<GemstoneData, MMOItem>> pairs = new ArrayList<>();
|
final List<Pair<GemstoneData, MMOItem>> pairs = new ArrayList<>();
|
||||||
for (GemstoneData gem : thisSocketsData.getGemstones()) {
|
for (GemstoneData gem : thisSocketsData.getGemstones()) {
|
||||||
final MMOItem restored = MMOItems.plugin.getMMOItem(MMOItems.plugin.getTypes().get(gem.getMMOItemType()), gem.getMMOItemID());
|
final MMOItem restored = MMOItems.plugin.getMMOItem(MMOItems.plugin.getTypes().get(gem.getMMOItemType()), gem.getMMOItemID());
|
||||||
if (restored != null)
|
if (restored != null) pairs.add(Pair.of(gem, restored));
|
||||||
pairs.add(Pair.of(gem, restored));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If RevID updating, no need to identify stats
|
// If RevID updating, no need to identify stats
|
||||||
if (MMOItemReforger.gemstonesRevIDWhenUnsocket)
|
if (MMOItemReforger.gemstonesRevIDWhenUnsocket) return pairs;
|
||||||
return pairs;
|
|
||||||
|
|
||||||
// Identify actual stats
|
// Identify actual stats
|
||||||
for (StatHistory hist : mergeableStatHistory.values())
|
for (StatHistory hist : mergeableStatHistory.values())
|
||||||
for (Pair<GemstoneData, MMOItem> gem : pairs) {
|
for (Pair<GemstoneData, MMOItem> gem : pairs) {
|
||||||
final StatData historicGemData = hist.getGemstoneData(gem.getKey().getHistoricUUID());
|
final StatData historicGemData = hist.getGemstoneData(gem.getKey().getHistoricUUID());
|
||||||
if (historicGemData != null)
|
if (historicGemData != null) gem.getValue().setData(hist.getItemStat(), historicGemData);
|
||||||
gem.getValue().setData(hist.getItemStat(), historicGemData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pairs;
|
return pairs;
|
||||||
@ -433,18 +417,15 @@ public class MMOItem implements ItemReference {
|
|||||||
public MMOItem extractGemstone(@NotNull GemstoneData gem) {
|
public MMOItem extractGemstone(@NotNull GemstoneData gem) {
|
||||||
|
|
||||||
final MMOItem restored = MMOItems.plugin.getMMOItem(MMOItems.plugin.getTypes().get(gem.getMMOItemType()), gem.getMMOItemID());
|
final MMOItem restored = MMOItems.plugin.getMMOItem(MMOItems.plugin.getTypes().get(gem.getMMOItemType()), gem.getMMOItemID());
|
||||||
if (restored == null)
|
if (restored == null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
// If RevID updating, no need to identify stats
|
// If RevID updating, no need to identify stats
|
||||||
if (MMOItemReforger.gemstonesRevIDWhenUnsocket)
|
if (MMOItemReforger.gemstonesRevIDWhenUnsocket) return restored;
|
||||||
return restored;
|
|
||||||
|
|
||||||
// Identify actual stats
|
// Identify actual stats
|
||||||
for (StatHistory hist : mergeableStatHistory.values()) {
|
for (StatHistory hist : mergeableStatHistory.values()) {
|
||||||
final StatData historicGemData = hist.getGemstoneData(gem.getHistoricUUID());
|
final StatData historicGemData = hist.getGemstoneData(gem.getHistoricUUID());
|
||||||
if (historicGemData != null)
|
if (historicGemData != null) restored.setData(hist.getItemStat(), historicGemData);
|
||||||
restored.setData(hist.getItemStat(), historicGemData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return restored;
|
return restored;
|
||||||
@ -460,11 +441,10 @@ public class MMOItem implements ItemReference {
|
|||||||
public void removeGemStone(@NotNull UUID gemUUID, @Nullable String color) {
|
public void removeGemStone(@NotNull UUID gemUUID, @Nullable String color) {
|
||||||
|
|
||||||
// Get gemstone data
|
// Get gemstone data
|
||||||
if (!hasData(ItemStats.GEM_SOCKETS))
|
if (!hasData(ItemStats.GEM_SOCKETS)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
//GEM//MMOItems.log("\u00a7b-\u00a78-\u00a79-\u00a77 Extracting \u00a7e" + gemUUID.toString());
|
//GEM//MMOItems.log("\u00a7b-\u00a78-\u00a79-\u00a77 Extracting \u00a7e" + gemUUID.toString());
|
||||||
StatHistory gemStory = StatHistory.from(this, ItemStats.GEM_SOCKETS);
|
StatHistory gemStory = computeStatHistory(ItemStats.GEM_SOCKETS);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We must only find the StatData where this gem resides,
|
* We must only find the StatData where this gem resides,
|
||||||
@ -472,23 +452,19 @@ public class MMOItem implements ItemReference {
|
|||||||
* will purge themselves from extraneous gems (that are
|
* will purge themselves from extraneous gems (that are
|
||||||
* no longer registered onto the GEM_SOCKETS history).
|
* no longer registered onto the GEM_SOCKETS history).
|
||||||
*/
|
*/
|
||||||
if (((GemSocketsData) gemStory.getOriginalData()).removeGem(gemUUID, color))
|
if (((GemSocketsData) gemStory.getOriginalData()).removeGem(gemUUID, color)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
// Attempt gems
|
// Attempt gems
|
||||||
for (UUID gemDataUUID : gemStory.getAllGemstones())
|
for (UUID gemDataUUID : gemStory.getAllGemstones())
|
||||||
if (((GemSocketsData) gemStory.getGemstoneData(gemDataUUID)).removeGem(gemUUID, color))
|
if (((GemSocketsData) gemStory.getGemstoneData(gemDataUUID)).removeGem(gemUUID, color)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
// Attempt externals
|
// Attempt externals
|
||||||
for (StatData externalData : gemStory.getExternalData())
|
for (StatData externalData : gemStory.getExternalData())
|
||||||
if (((GemSocketsData) externalData).removeGem(gemUUID, color))
|
if (((GemSocketsData) externalData).removeGem(gemUUID, color)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
// Attempt gems
|
// Attempt gems
|
||||||
for (UUID gemDataUUID : gemStory.getAllModifiers())
|
for (UUID gemDataUUID : gemStory.getAllModifiers())
|
||||||
if (((GemSocketsData) gemStory.getModifiersBonus(gemDataUUID)).removeGem(gemUUID, color))
|
if (((GemSocketsData) gemStory.getModifiersBonus(gemDataUUID)).removeGem(gemUUID, color)) return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
//endregion
|
//endregion
|
||||||
}
|
}
|
||||||
|
@ -392,7 +392,7 @@ public class MMOItemReforger {
|
|||||||
for (ItemStat stat : getFreshMMOItem().getUpgradeTemplate().getKeys()) {
|
for (ItemStat stat : getFreshMMOItem().getUpgradeTemplate().getKeys()) {
|
||||||
|
|
||||||
// That stat yes
|
// That stat yes
|
||||||
StatHistory hist = StatHistory.from(getFreshMMOItem(), stat);
|
StatHistory hist = getFreshMMOItem().computeStatHistory(stat);
|
||||||
|
|
||||||
// Recalculate that shit
|
// Recalculate that shit
|
||||||
getFreshMMOItem().setData(hist.getItemStat(), hist.recalculate(getFreshMMOItem().getUpgradeLevel()));
|
getFreshMMOItem().setData(hist.getItemStat(), hist.recalculate(getFreshMMOItem().getUpgradeLevel()));
|
||||||
|
@ -30,6 +30,10 @@ public class DisplayName extends StringStat implements GemStoneStat {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull StringData data) {
|
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull StringData data) {
|
||||||
|
|
||||||
|
// Make sure stat history exists
|
||||||
|
Validate.isTrue(item.getMMOItem().hasStatHistory(this));
|
||||||
|
|
||||||
final ItemTier tier = item.getMMOItem().getTier();
|
final ItemTier tier = item.getMMOItem().getTier();
|
||||||
final AdventureParser parser = MythicLib.plugin.getAdventureParser();
|
final AdventureParser parser = MythicLib.plugin.getAdventureParser();
|
||||||
String format = data.toString();
|
String format = data.toString();
|
||||||
@ -47,9 +51,6 @@ public class DisplayName extends StringStat implements GemStoneStat {
|
|||||||
|
|
||||||
item.getMeta().setDisplayName(format);
|
item.getMeta().setDisplayName(format);
|
||||||
|
|
||||||
// Force Stat History generation
|
|
||||||
StatHistory.from(item.getMMOItem(), this);
|
|
||||||
|
|
||||||
// Add NBT
|
// Add NBT
|
||||||
item.addItemTag(getAppliedNBT(data));
|
item.addItemTag(getAppliedNBT(data));
|
||||||
}
|
}
|
||||||
@ -256,7 +257,7 @@ public class DisplayName extends StringStat implements GemStoneStat {
|
|||||||
if (stored && itemName != null) {
|
if (stored && itemName != null) {
|
||||||
|
|
||||||
// History not prematurely loaded?
|
// History not prematurely loaded?
|
||||||
if (mmoitem.getStatHistory(this) == null) {
|
if (!mmoitem.hasStatHistory(this)) {
|
||||||
|
|
||||||
// Also load history :think ing:
|
// Also load history :think ing:
|
||||||
ItemTag hisTag = ItemTag.getTagAtPath(ItemStackBuilder.history_keyword + getId(), mmoitem.getNBT(), SupportedNBTTagValues.STRING);
|
ItemTag hisTag = ItemTag.getTagAtPath(ItemStackBuilder.history_keyword + getId(), mmoitem.getNBT(), SupportedNBTTagValues.STRING);
|
||||||
|
@ -174,7 +174,7 @@ public class Enchants extends ItemStat<RandomEnchantListData, EnchantListData> i
|
|||||||
* enchantments applied by players before StatHistory existed.
|
* enchantments applied by players before StatHistory existed.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
StatHistory.from(mmoitem, ItemStats.ENCHANTS);
|
mmoitem.computeStatHistory(ItemStats.ENCHANTS); // TODO remove?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -411,7 +411,7 @@ public class Enchants extends ItemStat<RandomEnchantListData, EnchantListData> i
|
|||||||
|
|
||||||
// Get that data
|
// Get that data
|
||||||
EnchantListData data = (EnchantListData) mmoitem.getData(ItemStats.ENCHANTS);
|
EnchantListData data = (EnchantListData) mmoitem.getData(ItemStats.ENCHANTS);
|
||||||
StatHistory hist = StatHistory.from(mmoitem, ItemStats.ENCHANTS);
|
StatHistory hist = mmoitem.computeStatHistory(ItemStats.ENCHANTS);
|
||||||
|
|
||||||
//SENCH//MMOItems.log(" \u00a7b:\u00a73:\u00a79: \u00a77Early Analysis: \u00a73o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o");
|
//SENCH//MMOItems.log(" \u00a7b:\u00a73:\u00a79: \u00a77Early Analysis: \u00a73o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o");
|
||||||
//SENCH//MMOItems.log(" \u00a73=\u00a7b> \u00a77Active:");
|
//SENCH//MMOItems.log(" \u00a73=\u00a7b> \u00a77Active:");
|
||||||
|
@ -92,7 +92,7 @@ public class RandomUnsocket extends DoubleStat implements ConsumableItemInteract
|
|||||||
|
|
||||||
// Drop gemstones to the ground :0
|
// Drop gemstones to the ground :0
|
||||||
ArrayList<ItemStack> items2Drop = new ArrayList<>();
|
ArrayList<ItemStack> items2Drop = new ArrayList<>();
|
||||||
while (s > 0 && mmoGemStones.size() > 0) {
|
while (s > 0 && !mmoGemStones.isEmpty()) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Choose a gem to drop :)
|
* Choose a gem to drop :)
|
||||||
@ -141,7 +141,7 @@ public class RandomUnsocket extends DoubleStat implements ConsumableItemInteract
|
|||||||
|
|
||||||
// Replace
|
// Replace
|
||||||
//HSY//MMOItems.log(" \u00a73-\u00a7a- \u00a77Gem Unsocketing Recalculation \u00a73-\u00a7a-\u00a73-\u00a7a-\u00a73-\u00a7a-\u00a73-\u00a7a-");
|
//HSY//MMOItems.log(" \u00a73-\u00a7a- \u00a77Gem Unsocketing Recalculation \u00a73-\u00a7a-\u00a73-\u00a7a-\u00a73-\u00a7a-\u00a73-\u00a7a-");
|
||||||
mmo.setData(ItemStats.GEM_SOCKETS, StatHistory.from(mmo, ItemStats.GEM_SOCKETS).recalculate(mmo.getUpgradeLevel()));
|
mmo.setData(ItemStats.GEM_SOCKETS, mmo.computeStatHistory(ItemStats.GEM_SOCKETS).recalculate(mmo.getUpgradeLevel()));
|
||||||
//GEM//MMOItems.log("\u00a7b*\u00a77 Final at \u00a7b" + ((GemSocketsData) mmo.getData(ItemStats.GEM_SOCKETS)).getEmptySlots().size() + " Empty\u00a77 and \u00a7e" + ((GemSocketsData) mmo.getData(ItemStats.GEM_SOCKETS)).getGemstones().size() + " Gems");
|
//GEM//MMOItems.log("\u00a7b*\u00a77 Final at \u00a7b" + ((GemSocketsData) mmo.getData(ItemStats.GEM_SOCKETS)).getEmptySlots().size() + " Empty\u00a77 and \u00a7e" + ((GemSocketsData) mmo.getData(ItemStats.GEM_SOCKETS)).getGemstones().size() + " Gems");
|
||||||
event.setCurrentItem(mmo.newBuilder().build());
|
event.setCurrentItem(mmo.newBuilder().build());
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ public class StatHistory {
|
|||||||
private ArrayList<StatData> perExternalData = new ArrayList<>();
|
private ArrayList<StatData> perExternalData = new ArrayList<>();
|
||||||
private HashMap<UUID, StatData> perGemstoneData = new HashMap<>();
|
private HashMap<UUID, StatData> perGemstoneData = new HashMap<>();
|
||||||
|
|
||||||
private StatHistory(@NotNull MMOItem parentItem, @NotNull ItemStat parentStat, @NotNull StatData parentData) {
|
public StatHistory(@NotNull MMOItem parentItem, @NotNull ItemStat parentStat, @NotNull StatData parentData) {
|
||||||
itemStat = parentStat;
|
itemStat = parentStat;
|
||||||
originalData = parentData;
|
originalData = parentData;
|
||||||
parent = parentItem;
|
parent = parentItem;
|
||||||
@ -109,8 +109,10 @@ public class StatHistory {
|
|||||||
return getOriginalData().equals(getMMOItem().getData(getItemStat()));
|
return getOriginalData().equals(getMMOItem().getData(getItemStat()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParent(@NotNull MMOItem parent) {
|
@NotNull
|
||||||
|
public StatHistory setParent(@NotNull MMOItem parent) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -263,73 +265,6 @@ public class StatHistory {
|
|||||||
perExternalData.clear();
|
perExternalData.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the stat history of this item. <b>The stat must be <code>Mergeable</code></b>
|
|
||||||
* <p></p>
|
|
||||||
* If the item has no stat history, it will be created anew and appended; the current stat values will become the 'Original' ones,
|
|
||||||
* and will be forever unchangeable.
|
|
||||||
* <p></p>
|
|
||||||
* <b>Make sure the item has the stat present</b>
|
|
||||||
*
|
|
||||||
* @param ofItem MMOItem to extract stat history from
|
|
||||||
* @param ofStat Stat of which to make history
|
|
||||||
*/
|
|
||||||
@NotNull
|
|
||||||
public static StatHistory from(@NotNull MMOItem ofItem, @NotNull ItemStat ofStat) {
|
|
||||||
return from(ofItem, ofStat, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the stat history of this item. <b>The stat must be <code>Mergeable</code></b>
|
|
||||||
* <p></p>
|
|
||||||
* If the item has no stat history, it will be created anew and appended; the current stat values will become the 'Original' ones,
|
|
||||||
* and will be forever unchangeable.
|
|
||||||
* <p></p>
|
|
||||||
* <b>Make sure the item has the stat present</b>
|
|
||||||
*
|
|
||||||
* @param parentItem MMOItem to extract stat history from
|
|
||||||
* @param stat Stat of which to make history
|
|
||||||
* @param forceNew <b>Only if you know what you are doing</b>, set to true to not check if the item already has stat history of this stat.
|
|
||||||
*/
|
|
||||||
@NotNull
|
|
||||||
public static StatHistory from(@NotNull MMOItem parentItem, @NotNull ItemStat stat, boolean forceNew) {
|
|
||||||
//LVL//MMOItems.log(" \u00a7d*\u00a77-\u00a7a-\u00a761? \u00a77Lvl: \u00a7b" + parentItem.getUpgradeLevel() + "\u00a7d-\u00a77-\u00a7a-\u00a7d-\u00a77-\u00a7a-");
|
|
||||||
// Get history :B
|
|
||||||
StatHistory hist;
|
|
||||||
if (!forceNew) {
|
|
||||||
hist = parentItem.getStatHistory(stat);
|
|
||||||
|
|
||||||
// Found? Thats it
|
|
||||||
if (hist != null) {
|
|
||||||
//UPGRD//MMOItems.log("Found Stat History of \u00a76" + stat.getNBTPath() + "\u00a77 in this \u00a7c" + parentItem.getType().getName() + " " + parentItem.getId());
|
|
||||||
//UPGRD//hist.log();
|
|
||||||
return hist;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// That is Mergeable right...
|
|
||||||
//UPGRD//MMOItems.log("\u00a7aCreated Hisotry of \u00a76" + stat.getNBTPath() + "\u00a7a of this \u00a7c" + parentItem.getType().getName() + " " + parentItem.getId());
|
|
||||||
Validate.isTrue(stat.getClearStatData() instanceof Mergeable, "Non-Mergeable stat data wont have a Stat History; they cannot be modified dynamically in the first place.");
|
|
||||||
|
|
||||||
// Get original data
|
|
||||||
StatData original = parentItem.getData(stat);
|
|
||||||
//LVL//MMOItems.log(" \u00a7d*\u00a77-\u00a7a-\u00a762? \u00a77Lvl: \u00a7b" + parentItem.getUpgradeLevel() + "\u00a7d-\u00a77-\u00a7a-\u00a7d-\u00a77-\u00a7a-");
|
|
||||||
if (original == null) {
|
|
||||||
original = stat.getClearStatData();
|
|
||||||
parentItem.setData(stat, original);
|
|
||||||
//UPGRD//MMOItems.log("\u00a7e +\u00a77 Item didnt have this stat, original set as blanc.");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
original = ((Mergeable) original).clone();
|
|
||||||
//UPGRD//MMOItems.log("\u00a7a +\u00a77 Found original data\u00a7f " + original);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create and register new
|
|
||||||
hist = new StatHistory(parentItem, stat, original);
|
|
||||||
parentItem.setStatHistory(stat, hist);
|
|
||||||
return hist;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the item and makes sure that the UUIDs attributed to gemstones
|
* Checks the item and makes sure that the UUIDs attributed to gemstones
|
||||||
* link to existing gemstones. Removes them if no such gemstone exists.
|
* link to existing gemstones. Removes them if no such gemstone exists.
|
||||||
@ -403,7 +338,7 @@ public class StatHistory {
|
|||||||
Mergeable finalData = ((Mergeable) originalData).clone();
|
Mergeable finalData = ((Mergeable) originalData).clone();
|
||||||
|
|
||||||
// Add modifiers (affected by upgrades as if they were base item data)
|
// Add modifiers (affected by upgrades as if they were base item data)
|
||||||
for (UUID modifierId : perModifierBonus.keySet()) finalData.mergeWith((Mergeable) getModifiersBonus(modifierId));
|
for (StatData data : perModifierBonus.values()) finalData.mergeWith((Mergeable) data);
|
||||||
|
|
||||||
// Level up
|
// Level up
|
||||||
if (upgradeInfo != null)
|
if (upgradeInfo != null)
|
||||||
@ -497,7 +432,7 @@ public class StatHistory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Include
|
// Include
|
||||||
if (externals.size() > 0) {
|
if (!externals.isEmpty()) {
|
||||||
object.add(ENC_EXS, externals);
|
object.add(ENC_EXS, externals);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -545,6 +480,10 @@ public class StatHistory {
|
|||||||
return toJson().toString();
|
return toJson().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isUpgradeable() {
|
||||||
|
return getMMOItem().hasUpgradeTemplate() && getMMOItem().getUpgradeTemplate().getUpgradeInfo(getItemStat()) != null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To read from NBT data. This undoes {@link #toJson()} basically.
|
* To read from NBT data. This undoes {@link #toJson()} basically.
|
||||||
* <p></p>
|
* <p></p>
|
||||||
@ -813,6 +752,28 @@ public class StatHistory {
|
|||||||
return his;
|
return his;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated See {@link MMOItem#computeStatHistory(ItemStat)} (ItemStat)}
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
@Deprecated
|
||||||
|
public static StatHistory from(@NotNull MMOItem ofItem, @NotNull ItemStat ofStat) {
|
||||||
|
return ofItem.computeStatHistory(ofStat);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Deprecated
|
||||||
|
public static StatHistory from(@NotNull MMOItem parentItem, @NotNull ItemStat stat, boolean forceNew) {
|
||||||
|
|
||||||
|
if (forceNew) {
|
||||||
|
StatHistory newHist = new StatHistory(parentItem, stat, Objects.requireNonNull(parentItem.getData(stat)));
|
||||||
|
parentItem.setStatHistory(stat, newHist);
|
||||||
|
return newHist;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parentItem.computeStatHistory((ItemStat<?, ?>) stat);
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public StatData recalculateUnupgraded(boolean withPurge) {
|
public StatData recalculateUnupgraded(boolean withPurge) {
|
||||||
@ -834,9 +795,5 @@ public class StatHistory {
|
|||||||
public void consolidateEXSH() {
|
public void consolidateEXSH() {
|
||||||
fuseExternalData();
|
fuseExternalData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUpgradeable() {
|
|
||||||
return getMMOItem().hasUpgradeTemplate() && getMMOItem().getUpgradeTemplate().getUpgradeInfo(getItemStat()) != null;
|
|
||||||
}
|
|
||||||
//endregion
|
//endregion
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package net.Indyuce.mmoitems.listener.reforging;
|
package net.Indyuce.mmoitems.listener.reforging;
|
||||||
|
|
||||||
import io.lumine.mythic.lib.api.util.Ref;
|
|
||||||
import net.Indyuce.mmoitems.ItemStats;
|
import net.Indyuce.mmoitems.ItemStats;
|
||||||
import net.Indyuce.mmoitems.MMOItems;
|
import net.Indyuce.mmoitems.MMOItems;
|
||||||
import net.Indyuce.mmoitems.api.event.MMOItemReforgeEvent;
|
import net.Indyuce.mmoitems.api.event.MMOItemReforgeEvent;
|
||||||
@ -43,7 +42,7 @@ public class RFGKeepEnchantments implements Listener {
|
|||||||
Enchants.separateEnchantments(operable);
|
Enchants.separateEnchantments(operable);
|
||||||
|
|
||||||
// Gather
|
// Gather
|
||||||
StatHistory hist = StatHistory.from(operable, ItemStats.ENCHANTS);
|
StatHistory hist = operable.computeStatHistory(ItemStats.ENCHANTS);
|
||||||
EnchantListData maybeOriginalEnchs = ((EnchantListData) hist.getOriginalData()).clone();
|
EnchantListData maybeOriginalEnchs = ((EnchantListData) hist.getOriginalData()).clone();
|
||||||
|
|
||||||
//RFG//MMOItems.log(" \u00a7b*** \u00a77Enchantments in old item:");
|
//RFG//MMOItems.log(" \u00a7b*** \u00a77Enchantments in old item:");
|
||||||
@ -52,7 +51,7 @@ public class RFGKeepEnchantments implements Listener {
|
|||||||
|
|
||||||
// Whats in the new one
|
// Whats in the new one
|
||||||
//RFG//MMOItems.log(" \u00a7b*** \u00a77Enchantments in new item:");
|
//RFG//MMOItems.log(" \u00a7b*** \u00a77Enchantments in new item:");
|
||||||
StatHistory future = StatHistory.from(event.getNewMMOItem(), ItemStats.ENCHANTS);
|
StatHistory future = event.getNewMMOItem().computeStatHistory(ItemStats.ENCHANTS);
|
||||||
//RFG//future.log();
|
//RFG//future.log();
|
||||||
|
|
||||||
//RFG//MMOItems.log(" \u00a7b* \u00a77Transfer those already externals:"); int n = 0;
|
//RFG//MMOItems.log(" \u00a7b* \u00a77Transfer those already externals:"); int n = 0;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.Indyuce.mmoitems.listener.reforging;
|
package net.Indyuce.mmoitems.listener.reforging;
|
||||||
|
|
||||||
import net.Indyuce.mmoitems.ItemStats;
|
import net.Indyuce.mmoitems.ItemStats;
|
||||||
import net.Indyuce.mmoitems.MMOItems;
|
|
||||||
import net.Indyuce.mmoitems.api.event.MMOItemReforgeEvent;
|
import net.Indyuce.mmoitems.api.event.MMOItemReforgeEvent;
|
||||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||||
import net.Indyuce.mmoitems.stat.type.StatHistory;
|
import net.Indyuce.mmoitems.stat.type.StatHistory;
|
||||||
@ -28,7 +27,7 @@ public class RFGKeepExternalSH implements Listener {
|
|||||||
if (oldHist.getItemStat() == ItemStats.ENCHANTS) { continue; }
|
if (oldHist.getItemStat() == ItemStats.ENCHANTS) { continue; }
|
||||||
|
|
||||||
// Get newer
|
// Get newer
|
||||||
StatHistory newHist = StatHistory.from(event.getNewMMOItem(), oldHist.getItemStat());
|
StatHistory newHist = event.getNewMMOItem().computeStatHistory(oldHist.getItemStat());
|
||||||
|
|
||||||
// Through all EXSH
|
// Through all EXSH
|
||||||
for (StatData exSH : oldHist.getExternalData()) {
|
for (StatData exSH : oldHist.getExternalData()) {
|
||||||
|
@ -148,7 +148,7 @@ public class RFGKeepGems implements Listener {
|
|||||||
/*
|
/*
|
||||||
* The gem data is registered directly into the history (emphasis on not recalculating with purge)
|
* The gem data is registered directly into the history (emphasis on not recalculating with purge)
|
||||||
*/
|
*/
|
||||||
StatHistory hist = StatHistory.from(event.getNewMMOItem(), stat);
|
StatHistory hist = event.getNewMMOItem().computeStatHistory(stat);
|
||||||
hist.registerGemstoneData(reforgedGemData.getHistoricUUID(), data);
|
hist.registerGemstoneData(reforgedGemData.getHistoricUUID(), data);
|
||||||
|
|
||||||
//RFG//MMOItems.log("\u00a79>>> \u00a77 Stat history of this stat");
|
//RFG//MMOItems.log("\u00a79>>> \u00a77 Stat history of this stat");
|
||||||
@ -174,7 +174,7 @@ public class RFGKeepGems implements Listener {
|
|||||||
//RFG//for (GemstoneData s : reforgedGemstoneData.getGemstones()) { MMOItems.log(" \u00a7a*\u00a7f " + s.getName() + "\u00a77 " + s.getHistoricUUID()); }
|
//RFG//for (GemstoneData s : reforgedGemstoneData.getGemstones()) { MMOItems.log(" \u00a7a*\u00a7f " + s.getName() + "\u00a77 " + s.getHistoricUUID()); }
|
||||||
|
|
||||||
// That's the original data
|
// That's the original data
|
||||||
StatHistory gemStory = StatHistory.from(event.getNewMMOItem(), ItemStats.GEM_SOCKETS);
|
StatHistory gemStory = event.getNewMMOItem().computeStatHistory(ItemStats.GEM_SOCKETS);
|
||||||
gemStory.setOriginalData(reforgedGemstoneData);
|
gemStory.setOriginalData(reforgedGemstoneData);
|
||||||
event.getNewMMOItem().setData(ItemStats.GEM_SOCKETS, gemStory.recalculate(event.getNewMMOItem().getUpgradeLevel()));
|
event.getNewMMOItem().setData(ItemStats.GEM_SOCKETS, gemStory.recalculate(event.getNewMMOItem().getUpgradeLevel()));
|
||||||
//RFG//MMOItems.log(" \u00a7a* \u00a77History Final\u00a7a --------");
|
//RFG//MMOItems.log(" \u00a7a* \u00a77History Final\u00a7a --------");
|
||||||
|
@ -38,7 +38,7 @@ public class RFGKeepLore implements Listener {
|
|||||||
if (extraLore.size() == 0) { return; }
|
if (extraLore.size() == 0) { return; }
|
||||||
|
|
||||||
// All right set it as the original in the Stat History
|
// All right set it as the original in the Stat History
|
||||||
StatHistory hist = StatHistory.from(event.getNewMMOItem(), ItemStats.LORE);
|
StatHistory hist = event.getNewMMOItem().computeStatHistory(ItemStats.LORE);
|
||||||
|
|
||||||
// UUH just add it to the original I guess bruh
|
// UUH just add it to the original I guess bruh
|
||||||
StringListData original = (StringListData) hist.getOriginalData();
|
StringListData original = (StringListData) hist.getOriginalData();
|
||||||
|
@ -33,7 +33,7 @@ public class RFGKeepModifications implements Listener {
|
|||||||
for (StatHistory oldHist : event.getOldMMOItem().getStatHistories()) {
|
for (StatHistory oldHist : event.getOldMMOItem().getStatHistories()) {
|
||||||
|
|
||||||
// Get newer
|
// Get newer
|
||||||
StatHistory newHist = StatHistory.from(event.getNewMMOItem(), oldHist.getItemStat());
|
StatHistory newHist = event.getNewMMOItem().computeStatHistory(oldHist.getItemStat());
|
||||||
|
|
||||||
// Through all EXSH
|
// Through all EXSH
|
||||||
for (UUID mod : oldHist.getAllModifiers()) {
|
for (UUID mod : oldHist.getAllModifiers()) {
|
||||||
|
@ -50,7 +50,7 @@ public class RFGKeepName implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// All right set it as the original in the Stat History
|
// All right set it as the original in the Stat History
|
||||||
StatHistory hist = StatHistory.from(event.getNewMMOItem(), ItemStats.NAME);
|
StatHistory hist = event.getNewMMOItem().computeStatHistory(ItemStats.NAME);
|
||||||
|
|
||||||
// Put it there
|
// Put it there
|
||||||
((NameData) hist.getOriginalData()).setString(transfer.getMainName());
|
((NameData) hist.getOriginalData()).setString(transfer.getMainName());
|
||||||
|
@ -54,7 +54,7 @@ public class RFGKeepRNG implements Listener {
|
|||||||
* preserve its rolls, even if it should be
|
* preserve its rolls, even if it should be
|
||||||
* preserving the rolls.
|
* preserving the rolls.
|
||||||
*/
|
*/
|
||||||
final StatHistory hist = StatHistory.from(event.getOldMMOItem(), stat);
|
final StatHistory hist = event.getOldMMOItem().computeStatHistory( stat);
|
||||||
final StatData keptData = ((UpdatableRandomStatData) source).reroll(stat, hist.getOriginalData(), event.getReforger().getGenerationItemLevel());
|
final StatData keptData = ((UpdatableRandomStatData) source).reroll(stat, hist.getOriginalData(), event.getReforger().getGenerationItemLevel());
|
||||||
|
|
||||||
// Old roll is ridiculously low probability under the new parameters. Forget.
|
// Old roll is ridiculously low probability under the new parameters. Forget.
|
||||||
@ -62,7 +62,7 @@ public class RFGKeepRNG implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Fetch History from the new item
|
// Fetch History from the new item
|
||||||
final StatHistory clear = StatHistory.from(event.getNewMMOItem(), stat);
|
final StatHistory clear = event.getNewMMOItem().computeStatHistory(stat);
|
||||||
|
|
||||||
// Replace original data of the new one with the roll from the old one
|
// Replace original data of the new one with the roll from the old one
|
||||||
clear.setOriginalData(keptData);
|
clear.setOriginalData(keptData);
|
||||||
|
Loading…
Reference in New Issue
Block a user