mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2024-12-23 04:47:34 +01:00
Merge remote-tracking branch 'origin/1019-bug-config-option-item-revision-keep-data-reroll-doesn-t-work'
# Conflicts: # .gitignore
This commit is contained in:
commit
0da5c6877c
@ -18,21 +18,31 @@ public class ReforgeOptions {
|
|||||||
private final boolean keepSkins;
|
private final boolean keepSkins;
|
||||||
private final boolean keepUpgrades;
|
private final boolean keepUpgrades;
|
||||||
private final boolean keepGemStones;
|
private final boolean keepGemStones;
|
||||||
private final boolean keepSoulbind;
|
private final boolean keepSoulBind;
|
||||||
private final boolean keepExternalSH;
|
private final boolean keepExternalSH;
|
||||||
private final boolean keepModifications;
|
private final boolean keepModifications;
|
||||||
@Nullable private final Boolean keepTier;
|
@Nullable
|
||||||
|
private final Boolean keepTier;
|
||||||
|
|
||||||
private final boolean reroll;
|
private final boolean reRoll;
|
||||||
|
|
||||||
// Third Party Stuff
|
// Third Party Stuff
|
||||||
private final boolean keepAdvancedEnchantments;
|
private final boolean keepAdvancedEnchantments;
|
||||||
|
|
||||||
@NotNull String keepCase = ChatColor.GRAY.toString();
|
@NotNull
|
||||||
public void setKeepCase(@NotNull String kc) { keepCase = kc; }
|
String keepCase = ChatColor.GRAY.toString();
|
||||||
@NotNull public String getKeepCase() { return keepCase; }
|
|
||||||
|
|
||||||
@NotNull ArrayList<String> blacklistedItems = new ArrayList<>();
|
public void setKeepCase(@NotNull String kc) {
|
||||||
|
keepCase = kc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getKeepCase() {
|
||||||
|
return keepCase;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
ArrayList<String> blacklistedItems = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apparently, people like to use MMOItems for quests. This
|
* Apparently, people like to use MMOItems for quests. This
|
||||||
@ -41,14 +51,15 @@ public class ReforgeOptions {
|
|||||||
* @param mmoitemID Item ID. Listen, including MMOItem Type as
|
* @param mmoitemID Item ID. Listen, including MMOItem Type as
|
||||||
* well is unnecessary hassle, complicates the
|
* well is unnecessary hassle, complicates the
|
||||||
* implementation.
|
* implementation.
|
||||||
*
|
* <p>
|
||||||
* People who name all their items "1", "2", ...
|
* People who name all their items "1", "2", ...
|
||||||
* can learn to not use magic numbers ffs.
|
* can learn to not use magic numbers ffs.
|
||||||
*
|
|
||||||
* @return If this item should not update with RevID (when passing
|
* @return If this item should not update with RevID (when passing
|
||||||
* these options, of course).
|
* these options, of course).
|
||||||
*/
|
*/
|
||||||
public boolean isBlacklisted(@NotNull String mmoitemID) { return blacklistedItems.contains(mmoitemID); }
|
public boolean isBlacklisted(@NotNull String mmoitemID) {
|
||||||
|
return blacklistedItems.contains(mmoitemID);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apparently, people like to use MMOItems for quests. This
|
* Apparently, people like to use MMOItems for quests. This
|
||||||
@ -57,16 +68,20 @@ public class ReforgeOptions {
|
|||||||
* @param mmoitemID Item ID. Listen, including MMOItem Type as
|
* @param mmoitemID Item ID. Listen, including MMOItem Type as
|
||||||
* well is unnecessary hassle, complicates the
|
* well is unnecessary hassle, complicates the
|
||||||
* implementation.
|
* implementation.
|
||||||
*
|
* <p>
|
||||||
* People who name all their items "1", "2", ...
|
* People who name all their items "1", "2", ...
|
||||||
* can learn to not use magic numbers ffs.
|
* can learn to not use magic numbers ffs.
|
||||||
*/
|
*/
|
||||||
public void addToBlacklist(@NotNull String mmoitemID) { blacklistedItems.add(mmoitemID); }
|
public void addToBlacklist(@NotNull String mmoitemID) {
|
||||||
|
blacklistedItems.add(mmoitemID);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* No MMOItem-ID restrictions on RevID.
|
* No MMOItem-ID restrictions on RevID.
|
||||||
*/
|
*/
|
||||||
public void clearBlacklist() { blacklistedItems.clear(); }
|
public void clearBlacklist() {
|
||||||
|
blacklistedItems.clear();
|
||||||
|
}
|
||||||
|
|
||||||
public ReforgeOptions(ConfigurationSection config) {
|
public ReforgeOptions(ConfigurationSection config) {
|
||||||
keepName = config.getBoolean("display-name");
|
keepName = config.getBoolean("display-name");
|
||||||
@ -75,11 +90,11 @@ public class ReforgeOptions {
|
|||||||
keepUpgrades = config.getBoolean("upgrades");
|
keepUpgrades = config.getBoolean("upgrades");
|
||||||
keepGemStones = config.getBoolean("gemstones", false) || config.getBoolean("gems", false);
|
keepGemStones = config.getBoolean("gemstones", false) || config.getBoolean("gems", false);
|
||||||
keepSkins = config.getBoolean("skins", false);
|
keepSkins = config.getBoolean("skins", false);
|
||||||
keepSoulbind = config.getBoolean("soulbound");
|
keepSoulBind = config.getBoolean("soulbound");
|
||||||
keepCase = config.getString("kept-lore-prefix", ChatColor.GRAY.toString());
|
keepCase = config.getString("kept-lore-prefix", ChatColor.GRAY.toString());
|
||||||
keepExternalSH = config.getBoolean("external-sh", true);
|
keepExternalSH = config.getBoolean("external-sh", true);
|
||||||
keepModifications = config.getBoolean("modifications");
|
keepModifications = config.getBoolean("modifications");
|
||||||
reroll = config.getBoolean("reroll");
|
reRoll = config.getBoolean("reroll");
|
||||||
keepAdvancedEnchantments = config.getBoolean("advanced-enchantments");
|
keepAdvancedEnchantments = config.getBoolean("advanced-enchantments");
|
||||||
keepTier = config.contains("tier") ? config.getBoolean("tier", true) : null;
|
keepTier = config.contains("tier") ? config.getBoolean("tier", true) : null;
|
||||||
}
|
}
|
||||||
@ -90,9 +105,9 @@ public class ReforgeOptions {
|
|||||||
keepEnchantments = arr(values, 2);
|
keepEnchantments = arr(values, 2);
|
||||||
keepUpgrades = arr(values, 3);
|
keepUpgrades = arr(values, 3);
|
||||||
keepGemStones = arr(values, 4);
|
keepGemStones = arr(values, 4);
|
||||||
keepSoulbind = arr(values, 5);
|
keepSoulBind = arr(values, 5);
|
||||||
keepExternalSH = arr(values, 6);
|
keepExternalSH = arr(values, 6);
|
||||||
reroll = arr(values, 7);
|
reRoll = arr(values, 7);
|
||||||
keepModifications = arr(values, 8);
|
keepModifications = arr(values, 8);
|
||||||
keepAdvancedEnchantments = arr(values, 9);
|
keepAdvancedEnchantments = arr(values, 9);
|
||||||
keepSkins = arr(values, 10);
|
keepSkins = arr(values, 10);
|
||||||
@ -100,65 +115,82 @@ public class ReforgeOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean arr(@NotNull boolean[] booleans, int idx) {
|
boolean arr(@NotNull boolean[] booleans, int idx) {
|
||||||
|
return booleans.length > idx && booleans[idx];
|
||||||
if (booleans.length > idx) { return booleans[idx]; }
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keeps the display name of the item.
|
* Keeps the display name of the item.
|
||||||
*/
|
*/
|
||||||
public boolean shouldReroll() { return reroll; }
|
public boolean shouldReRoll() {
|
||||||
|
return reRoll;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keeps the display name of the item.
|
* Keeps the display name of the item.
|
||||||
*/
|
*/
|
||||||
public boolean shouldKeepName() { return keepName; }
|
public boolean shouldKeepName() {
|
||||||
|
return keepName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keeps the modifiers of the item.
|
* Keeps the modifiers of the item.
|
||||||
*/
|
*/
|
||||||
public boolean shouldKeepMods() { return keepModifications; }
|
public boolean shouldKeepMods() {
|
||||||
|
return keepModifications;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keeps all lore lines that begin with {@link org.bukkit.ChatColor#GRAY}
|
* Keeps all lore lines that begin with {@link org.bukkit.ChatColor#GRAY}
|
||||||
*/
|
*/
|
||||||
public boolean shouldKeepLore() { return keepLore; }
|
public boolean shouldKeepLore() {
|
||||||
|
return keepLore;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keeps skins
|
* Keeps skins
|
||||||
*/
|
*/
|
||||||
public boolean shouldKeepSkins() { return keepSkins; }
|
public boolean shouldKeepSkins() {
|
||||||
|
return keepSkins;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should keep the tier? defaults to {@link MMOItemReforger#keepTiersWhenReroll}
|
* Should keep the tier? defaults to {@link MMOItemReforger#keepTiersWhenReroll}
|
||||||
*/
|
*/
|
||||||
public boolean shouldKeepTier() { return keepTier == null ? MMOItemReforger.keepTiersWhenReroll : keepTier; }
|
public boolean shouldKeepTier() {
|
||||||
|
return keepTier == null ? MMOItemReforger.keepTiersWhenReroll : keepTier;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should this keep the enchantments the player
|
* Should this keep the enchantments the player
|
||||||
* manually cast onto this item? (Not from gem
|
* manually cast onto this item? (Not from gem
|
||||||
* stones nor upgrades).
|
* stones nor upgrades).
|
||||||
*/
|
*/
|
||||||
public boolean shouldKeepEnchantments() { return keepEnchantments; }
|
public boolean shouldKeepEnchantments() {
|
||||||
|
return keepEnchantments;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should this keep the enchantments the player
|
* Should this keep the enchantments the player
|
||||||
* manually cast onto this item? (Not from gem
|
* manually cast onto this item? (Not from gem
|
||||||
* stones nor upgrades).
|
* stones nor upgrades).
|
||||||
*/
|
*/
|
||||||
public boolean shouldKeepAdvancedEnchants() { return keepAdvancedEnchantments; }
|
public boolean shouldKeepAdvancedEnchants() {
|
||||||
|
return keepAdvancedEnchantments;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keep 'extraneous' data registered onto the Stat History
|
* Keep 'extraneous' data registered onto the Stat History
|
||||||
*/
|
*/
|
||||||
public boolean shouldKeepExternalSH() { return keepExternalSH; }
|
public boolean shouldKeepExternalSH() {
|
||||||
|
return keepExternalSH;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retains the upgrade level of the item.
|
* Retains the upgrade level of the item.
|
||||||
*/
|
*/
|
||||||
public boolean shouldKeepUpgrades() { return keepUpgrades; }
|
public boolean shouldKeepUpgrades() {
|
||||||
|
return keepUpgrades;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retains all gem stones if there are any, removing
|
* Retains all gem stones if there are any, removing
|
||||||
@ -166,10 +198,14 @@ public class ReforgeOptions {
|
|||||||
* <p></p>
|
* <p></p>
|
||||||
* Gemstones remember at what upgrade level they were inserted.
|
* Gemstones remember at what upgrade level they were inserted.
|
||||||
*/
|
*/
|
||||||
public boolean shouldKeepGemStones() { return keepGemStones; }
|
public boolean shouldKeepGemStones() {
|
||||||
|
return keepGemStones;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retains the soulbind if it has any.
|
* Retains the soulbind if it has any.
|
||||||
*/
|
*/
|
||||||
public boolean shouldKeepSoulbind() { return keepSoulbind; }
|
public boolean shouldKeepSoulBind() {
|
||||||
|
return keepSoulBind;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ public class MMOItemReforger {
|
|||||||
Validate.isTrue(stack.getItemMeta() != null, "ItemStack has no ItemMeta, cannot be reforged.");
|
Validate.isTrue(stack.getItemMeta() != null, "ItemStack has no ItemMeta, cannot be reforged.");
|
||||||
meta = stack.getItemMeta();
|
meta = stack.getItemMeta();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create this reforger to handle all operations regarding RevID
|
* Create this reforger to handle all operations regarding RevID
|
||||||
* increases on any ItemStack, including: <br>
|
* increases on any ItemStack, including: <br>
|
||||||
@ -81,6 +82,7 @@ public class MMOItemReforger {
|
|||||||
Validate.isTrue(stack.getItemMeta() != null, "ItemStack has no ItemMeta, cannot be reforged.");
|
Validate.isTrue(stack.getItemMeta() != null, "ItemStack has no ItemMeta, cannot be reforged.");
|
||||||
meta = stack.getItemMeta();
|
meta = stack.getItemMeta();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create this reforger to handle all operations regarding RevID
|
* Create this reforger to handle all operations regarding RevID
|
||||||
* increases on any ItemStack, including: <br>
|
* increases on any ItemStack, including: <br>
|
||||||
@ -89,11 +91,9 @@ public class MMOItemReforger {
|
|||||||
* * Transfer stats from old to fresh <br>
|
* * Transfer stats from old to fresh <br>
|
||||||
* * Build the fresh version <br>
|
* * Build the fresh version <br>
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @param nbtItem If for any reason you already generated an NBTItem,
|
* @param nbtItem If for any reason you already generated an NBTItem,
|
||||||
* you may pass it here to ease the performance of
|
* you may pass it here to ease the performance of
|
||||||
* generating it again from the ItemStack.
|
* generating it again from the ItemStack.
|
||||||
*
|
|
||||||
* @param stack The ItemStack you want to update, or at least
|
* @param stack The ItemStack you want to update, or at least
|
||||||
* know if it should update due to RevID increase.
|
* know if it should update due to RevID increase.
|
||||||
*/
|
*/
|
||||||
@ -108,62 +108,97 @@ public class MMOItemReforger {
|
|||||||
/**
|
/**
|
||||||
* The original ItemStack itself, not even a clone.
|
* The original ItemStack itself, not even a clone.
|
||||||
*/
|
*/
|
||||||
@NotNull final ItemStack stack;
|
@NotNull
|
||||||
|
final ItemStack stack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The original ItemStack, not even a clone.
|
* @return The original ItemStack, not even a clone.
|
||||||
*/
|
*/
|
||||||
@NotNull public ItemStack getStack() { return stack; }
|
@NotNull
|
||||||
|
public ItemStack getStack() {
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The original ItemStack itself, not even a clone.
|
* The original ItemStack itself, not even a clone.
|
||||||
*/
|
*/
|
||||||
@Nullable ItemStack result;
|
@Nullable
|
||||||
|
ItemStack result;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The original ItemStack, not even a clone.
|
* @return The original ItemStack, not even a clone.
|
||||||
*/
|
*/
|
||||||
@Nullable public ItemStack getResult() { return result; }
|
@Nullable
|
||||||
|
public ItemStack getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The original ItemStack itself, not even a clone.
|
* The original ItemStack itself, not even a clone.
|
||||||
*/
|
*/
|
||||||
public void setResult(@Nullable ItemStack item) { result = item; }
|
public void setResult(@Nullable ItemStack item) {
|
||||||
|
result = item;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The original NBTItem information.
|
* The original NBTItem information.
|
||||||
*/
|
*/
|
||||||
@NotNull final NBTItem nbtItem;
|
@NotNull
|
||||||
|
final NBTItem nbtItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The original NBTItem information.
|
* @return The original NBTItem information.
|
||||||
*/
|
*/
|
||||||
@NotNull public NBTItem getNBTItem() { return nbtItem; }
|
@NotNull
|
||||||
|
public NBTItem getNBTItem() {
|
||||||
|
return nbtItem;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The meta of {@link #getStack()} but without
|
* The meta of {@link #getStack()} but without
|
||||||
* that pesky {@link Nullable} annotation.
|
* that pesky {@link Nullable} annotation.
|
||||||
*/
|
*/
|
||||||
@NotNull final ItemMeta meta;
|
@NotNull
|
||||||
|
final ItemMeta meta;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The meta of {@link #getStack()} but without that
|
* @return The meta of {@link #getStack()} but without that
|
||||||
* pesky {@link Nullable} annotation.
|
* pesky {@link Nullable} annotation.
|
||||||
*/
|
*/
|
||||||
@NotNull public ItemMeta getMeta() { return meta; }
|
@NotNull
|
||||||
|
public ItemMeta getMeta() {
|
||||||
|
return meta;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The player to reroll modifiers based on their level
|
* The player to reroll modifiers based on their level
|
||||||
*/
|
*/
|
||||||
@Nullable RPGPlayer player;
|
@Nullable
|
||||||
|
RPGPlayer player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return player The player to reroll modifiers based on their level
|
* @return player The player to reroll modifiers based on their level
|
||||||
*/
|
*/
|
||||||
@Nullable public RPGPlayer getPlayer() { return player; }
|
@Nullable
|
||||||
|
public RPGPlayer getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param player The player to reroll modifiers based on their level
|
* @param player The player to reroll modifiers based on their level
|
||||||
*/
|
*/
|
||||||
public void setPlayer(@Nullable RPGPlayer player) { this.player = player;}
|
public void setPlayer(@Nullable RPGPlayer player) {
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param player The player to reroll modifiers based on their level
|
* @param player The player to reroll modifiers based on their level
|
||||||
*/
|
*/
|
||||||
public void setPlayer(@Nullable Player player) {
|
public void setPlayer(@Nullable Player player) {
|
||||||
if (player == null) { this.player = null; return; }
|
if (player == null) {
|
||||||
|
this.player = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Get data
|
// Get data
|
||||||
this.player = PlayerData.get(player).getRPG();
|
this.player = PlayerData.get(player).getRPG();
|
||||||
@ -171,53 +206,73 @@ public class MMOItemReforger {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* If the item should update, this wont be null anymore.
|
* If the item should update, this wont be null anymore.
|
||||||
*
|
* <p>
|
||||||
* Guaranteed not-null when updating.
|
* Guaranteed not-null when updating.
|
||||||
*/
|
*/
|
||||||
@Nullable LiveMMOItem oldMMOItem;
|
@Nullable
|
||||||
|
LiveMMOItem oldMMOItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The MMOItem being updated. For safety, it should be cloned,
|
* @return The MMOItem being updated. For safety, it should be cloned,
|
||||||
* in case any plugin decides to make changes in it... though
|
* in case any plugin decides to make changes in it... though
|
||||||
* this should be entirely for <b>reading purposes only</b>.
|
* this should be entirely for <b>reading purposes only</b>.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"NullableProblems", "ConstantConditions"})
|
@SuppressWarnings({"NullableProblems", "ConstantConditions"})
|
||||||
@NotNull public LiveMMOItem getOldMMOItem() { return oldMMOItem; }
|
@NotNull
|
||||||
|
public LiveMMOItem getOldMMOItem() {
|
||||||
|
return oldMMOItem;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The loaded template of the MMOItem in question.
|
* The loaded template of the MMOItem in question.
|
||||||
*
|
* <p>
|
||||||
* Guaranteed not-null when updating.
|
* Guaranteed not-null when updating.
|
||||||
*/
|
*/
|
||||||
@Nullable private MMOItemTemplate template;
|
@Nullable
|
||||||
|
private MMOItemTemplate template;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The loaded template of the MMOItem in question.
|
* @return The loaded template of the MMOItem in question.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"NullableProblems", "ConstantConditions"})
|
@SuppressWarnings({"NullableProblems", "ConstantConditions"})
|
||||||
@NotNull public MMOItemTemplate getTemplate() { return template; }
|
@NotNull
|
||||||
|
public MMOItemTemplate getTemplate() {
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Updated version of the MMOItem, with
|
* The Updated version of the MMOItem, with
|
||||||
* its revised stats.
|
* its revised stats.
|
||||||
*
|
* <p>
|
||||||
* Guaranteed not-null when updating.
|
* Guaranteed not-null when updating.
|
||||||
*/
|
*/
|
||||||
@Nullable private MMOItem freshMMOItem;
|
@Nullable
|
||||||
|
private MMOItem freshMMOItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The Updated version of the MMOItem, with
|
* @return The Updated version of the MMOItem, with
|
||||||
* its revised stats.
|
* its revised stats.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"NullableProblems", "ConstantConditions"})
|
@SuppressWarnings({"NullableProblems", "ConstantConditions"})
|
||||||
@NotNull public MMOItem getFreshMMOItem() { return freshMMOItem; }
|
@NotNull
|
||||||
|
public MMOItem getFreshMMOItem() {
|
||||||
|
return freshMMOItem;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mmo The Updated version of the MMOItem, with
|
* @param mmo The Updated version of the MMOItem, with
|
||||||
* the revised stats.
|
* the revised stats.
|
||||||
*/
|
*/
|
||||||
public void setFreshMMOItem(@NotNull MMOItem mmo) { freshMMOItem = mmo; }
|
public void setFreshMMOItem(@NotNull MMOItem mmo) {
|
||||||
|
freshMMOItem = mmo;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If it is possible to update this ItemStack via this class.
|
* If it is possible to update this ItemStack via this class.
|
||||||
*/
|
*/
|
||||||
@Nullable Boolean canUpdate;
|
@Nullable
|
||||||
|
Boolean canUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The value is stored so the operations don't have to run again on
|
* The value is stored so the operations don't have to run again on
|
||||||
* subsequent calls, which also means you have to make a new
|
* subsequent calls, which also means you have to make a new
|
||||||
@ -230,14 +285,14 @@ public class MMOItemReforger {
|
|||||||
//RFG//MMOItems.log("§8Reforge §4CAN §7Can reforge? " + SilentNumbers.getItemName(getStack()));
|
//RFG//MMOItems.log("§8Reforge §4CAN §7Can reforge? " + SilentNumbers.getItemName(getStack()));
|
||||||
|
|
||||||
// Already went through these operations ~
|
// Already went through these operations ~
|
||||||
if (canUpdate != null) { return canUpdate; }
|
if (canUpdate != null) return canUpdate;
|
||||||
|
|
||||||
// Does it not have type?
|
// Does it not have type?
|
||||||
if (!getNBTItem().hasType()) { return canUpdate = false; }
|
if (!getNBTItem().hasType()) return canUpdate = false;
|
||||||
|
|
||||||
// Ay get template
|
// Ay get template
|
||||||
template = MMOItems.plugin.getTemplates().getTemplate(getNBTItem());
|
template = MMOItems.plugin.getTemplates().getTemplate(getNBTItem());
|
||||||
if (template == null) { return canUpdate = false; }
|
if (template == null) return canUpdate = false;
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
return canUpdate = true;
|
return canUpdate = true;
|
||||||
@ -246,18 +301,19 @@ public class MMOItemReforger {
|
|||||||
/**
|
/**
|
||||||
* If it is recommended to update because the RevID value in the ItemStack is outdated.
|
* If it is recommended to update because the RevID value in the ItemStack is outdated.
|
||||||
*/
|
*/
|
||||||
@Nullable Boolean shouldUpdate;
|
@Nullable
|
||||||
|
Boolean shouldUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The value is stored so the operations don't have to run again on
|
* The value is stored so the operations don't have to run again on
|
||||||
* subsequent calls, which also means you have to make a new
|
* subsequent calls, which also means you have to make a new
|
||||||
* MMOItemReforger if you make changes, because it wont be read again.
|
* MMOItemReforger if you make changes, because it wont be read again.
|
||||||
*
|
*
|
||||||
* @param reason Why the item should be updated?
|
* @param reason Why the item should be updated?
|
||||||
*
|
* <p>
|
||||||
* Used to disable updating items in the config,
|
* Used to disable updating items in the config,
|
||||||
* only during specific 'reasons' like the player
|
* only during specific 'reasons' like the player
|
||||||
* joining or picking the item up.
|
* joining or picking the item up.
|
||||||
*
|
|
||||||
* @return If this is an MMOItem with an outdated RevID value.
|
* @return If this is an MMOItem with an outdated RevID value.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("NestedAssignment")
|
@SuppressWarnings("NestedAssignment")
|
||||||
@ -265,25 +321,31 @@ public class MMOItemReforger {
|
|||||||
//RFG//MMOItems.log("§8Reforge §4SHD §7Should reforge? " + SilentNumbers.getItemName(getStack()));
|
//RFG//MMOItems.log("§8Reforge §4SHD §7Should reforge? " + SilentNumbers.getItemName(getStack()));
|
||||||
|
|
||||||
// Already went through these operations ~
|
// Already went through these operations ~
|
||||||
if (shouldUpdate != null) { return shouldUpdate; }
|
if (shouldUpdate != null)
|
||||||
|
return shouldUpdate;
|
||||||
|
|
||||||
// Fist of all, can it update?
|
// Fist of all, can it update?
|
||||||
if (!canReforge()) { return shouldUpdate = false; }
|
if (!canReforge())
|
||||||
|
return shouldUpdate = false;
|
||||||
|
|
||||||
// Its not GooP Converter's VANILLA is it?
|
// Its not GooP Converter's VANILLA is it?
|
||||||
if ("VANILLA".equals(nbtItem.getString("MMOITEMS_ITEM_ID"))) { return false; }
|
if ("VANILLA".equals(nbtItem.getString("MMOITEMS_ITEM_ID")))
|
||||||
|
return false;
|
||||||
|
|
||||||
// Disabled in config?
|
// Disabled in config?
|
||||||
if (reason != null && MMOItems.plugin.getConfig().getBoolean("item-revision.disable-on." + reason)) { return shouldUpdate = false; }
|
if (reason != null && MMOItems.plugin.getConfig().getBoolean("item-revision.disable-on." + reason))
|
||||||
|
return shouldUpdate = false;
|
||||||
|
|
||||||
// Greater RevID in template? Go ahead, update!
|
// Greater RevID in template? Go ahead, update!
|
||||||
int templateRevision = getTemplate().getRevisionId();
|
int templateRevision = getTemplate().getRevisionId();
|
||||||
int mmoitemRevision = (getNBTItem().hasTag(ItemStats.REVISION_ID.getNBTPath()) ? getNBTItem().getInteger(ItemStats.REVISION_ID.getNBTPath()) : 1);
|
int mmoitemRevision = (getNBTItem().hasTag(ItemStats.REVISION_ID.getNBTPath()) ? getNBTItem().getInteger(ItemStats.REVISION_ID.getNBTPath()) : 1);
|
||||||
if (templateRevision > mmoitemRevision) { return shouldUpdate = true; }
|
if (templateRevision > mmoitemRevision)
|
||||||
|
return shouldUpdate = true;
|
||||||
|
|
||||||
// What about in the internal revision?
|
// What about in the internal revision?
|
||||||
int internalRevision = (nbtItem.hasTag(ItemStats.INTERNAL_REVISION_ID.getNBTPath()) ? nbtItem.getInteger(ItemStats.INTERNAL_REVISION_ID.getNBTPath()) : 1);
|
int internalRevision = (nbtItem.hasTag(ItemStats.INTERNAL_REVISION_ID.getNBTPath()) ? nbtItem.getInteger(ItemStats.INTERNAL_REVISION_ID.getNBTPath()) : 1);
|
||||||
if (MMOItems.INTERNAL_REVISION_ID > internalRevision) { return shouldUpdate = true; }
|
if (MMOItems.INTERNAL_REVISION_ID > internalRevision)
|
||||||
|
return shouldUpdate = true;
|
||||||
|
|
||||||
// Actually, no need
|
// Actually, no need
|
||||||
return shouldUpdate = false;
|
return shouldUpdate = false;
|
||||||
@ -300,7 +362,9 @@ public class MMOItemReforger {
|
|||||||
* event runs, the gemstone updater stores the gem items here
|
* event runs, the gemstone updater stores the gem items here
|
||||||
* so that the player gets them back at the completion of this.
|
* so that the player gets them back at the completion of this.
|
||||||
*/
|
*/
|
||||||
@NotNull final ArrayList<ItemStack> reforgingOutput = new ArrayList<>();
|
@NotNull
|
||||||
|
final ArrayList<ItemStack> reforgingOutput = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sometimes, reforging will take away things from the item that
|
* Sometimes, reforging will take away things from the item that
|
||||||
* we don't want to be destroyed forever, these items will drop
|
* we don't want to be destroyed forever, these items will drop
|
||||||
@ -315,14 +379,12 @@ public class MMOItemReforger {
|
|||||||
* @param item Add an item to this process.
|
* @param item Add an item to this process.
|
||||||
*/
|
*/
|
||||||
public void addReforgingOutput(@Nullable ItemStack item) {
|
public void addReforgingOutput(@Nullable ItemStack item) {
|
||||||
|
|
||||||
// Ew
|
// Ew
|
||||||
if (SilentNumbers.isAir(item)) { return; }
|
if (!SilentNumbers.isAir(item) && item.getType().isItem())
|
||||||
if (!item.getType().isItem()) { return; }
|
|
||||||
|
|
||||||
// Add that
|
// Add that
|
||||||
reforgingOutput.add(item);
|
reforgingOutput.add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sometimes, reforging will take away things from the item that
|
* Sometimes, reforging will take away things from the item that
|
||||||
* we don't want to be destroyed forever, these items will drop
|
* we don't want to be destroyed forever, these items will drop
|
||||||
@ -334,7 +396,10 @@ public class MMOItemReforger {
|
|||||||
* event runs, the gemstone updater stores the gem items here
|
* event runs, the gemstone updater stores the gem items here
|
||||||
* so that the player gets them back at the completion of this.
|
* so that the player gets them back at the completion of this.
|
||||||
*/
|
*/
|
||||||
public void clearReforgingOutput() { reforgingOutput.clear(); }
|
public void clearReforgingOutput() {
|
||||||
|
reforgingOutput.clear();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sometimes, reforging will take away things from the item that
|
* Sometimes, reforging will take away things from the item that
|
||||||
* we don't want to be destroyed forever, these items will drop
|
* we don't want to be destroyed forever, these items will drop
|
||||||
@ -348,18 +413,24 @@ public class MMOItemReforger {
|
|||||||
*
|
*
|
||||||
* @return All the items that will be dropped. The list itself.
|
* @return All the items that will be dropped. The list itself.
|
||||||
*/
|
*/
|
||||||
@NotNull public ArrayList<ItemStack> getReforgingOutput() { return reforgingOutput; }
|
@NotNull
|
||||||
|
public ArrayList<ItemStack> getReforgingOutput() {
|
||||||
|
return reforgingOutput;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The item level modifying the values of RandomStatData
|
* The item level modifying the values of RandomStatData
|
||||||
* upon creating a new MMOItem from the template.
|
* upon creating a new MMOItem from the template.
|
||||||
*/
|
*/
|
||||||
int generationItemLevel;
|
int generationItemLevel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The item level modifying the values of RandomStatData
|
* @return The item level modifying the values of RandomStatData
|
||||||
* upon creating a new MMOItem from the template.
|
* upon creating a new MMOItem from the template.
|
||||||
*/
|
*/
|
||||||
public int getGenerationItemLevel() { return generationItemLevel; }
|
public int getGenerationItemLevel() {
|
||||||
|
return generationItemLevel;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Make sure to check {@link #canReforge()} because an
|
* <b>Make sure to check {@link #canReforge()} because an
|
||||||
@ -371,20 +442,21 @@ public class MMOItemReforger {
|
|||||||
* generate a brand-new one.
|
* generate a brand-new one.
|
||||||
*
|
*
|
||||||
* @param options Additional options to pass onto the modules.
|
* @param options Additional options to pass onto the modules.
|
||||||
*
|
|
||||||
* @return If reforged successfully. Basically <code>true</code>, unless cancelled.
|
* @return If reforged successfully. Basically <code>true</code>, unless cancelled.
|
||||||
*/
|
*/
|
||||||
public boolean reforge(@NotNull ReforgeOptions options) {
|
public boolean reforge(@NotNull ReforgeOptions options) {
|
||||||
//RFG//MMOItems.log("§8Reforge §4RFG§7 Reforging " + SilentNumbers.getItemName(getStack()));
|
//RFG//MMOItems.log("§8Reforge §4RFG§7 Reforging " + SilentNumbers.getItemName(getStack()));
|
||||||
|
|
||||||
// Throw fail
|
// Throw fail
|
||||||
if (!canReforge()) { throw new IllegalArgumentException("Unreforgable Item " + SilentNumbers.getItemName(getStack())); }
|
if (!canReforge())
|
||||||
|
throw new IllegalArgumentException("Unreforgable Item " + SilentNumbers.getItemName(getStack()));
|
||||||
|
|
||||||
// Prepare everything properly
|
// Prepare everything properly
|
||||||
oldMMOItem = new LiveMMOItem(getNBTItem());
|
oldMMOItem = new LiveMMOItem(getNBTItem());
|
||||||
|
|
||||||
// Not blacklisted right!?
|
// Not blacklisted right!?
|
||||||
if (options.isBlacklisted(getOldMMOItem().getId())) { return false; }
|
if (options.isBlacklisted(getOldMMOItem().getId()))
|
||||||
|
return false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* THis chunk will determine the level the item was, and
|
* THis chunk will determine the level the item was, and
|
||||||
@ -406,14 +478,12 @@ public class MMOItemReforger {
|
|||||||
(iLevel == -32767) ?
|
(iLevel == -32767) ?
|
||||||
|
|
||||||
// Does the item have level?
|
// Does the item have level?
|
||||||
(getOldMMOItem().hasData(ItemStats.ITEM_LEVEL) ? (int) ((DoubleData)getOldMMOItem().getData(ItemStats.ITEM_LEVEL)).getValue() : 0 )
|
(getOldMMOItem().hasData(ItemStats.ITEM_LEVEL) ? (int) ((DoubleData) getOldMMOItem().getData(ItemStats.ITEM_LEVEL)).getValue() : 0)
|
||||||
|
|
||||||
// Default level was specified, use that.
|
// Default level was specified, use that.
|
||||||
: iLevel;
|
: iLevel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Identify tier.
|
// Identify tier.
|
||||||
ItemTier tier =
|
ItemTier tier =
|
||||||
|
|
||||||
@ -436,19 +506,18 @@ public class MMOItemReforger {
|
|||||||
Bukkit.getPluginManager().callEvent(mmoREV);
|
Bukkit.getPluginManager().callEvent(mmoREV);
|
||||||
|
|
||||||
// Cancelled? it ends there
|
// Cancelled? it ends there
|
||||||
if (mmoREV.isCancelled()) {
|
if (mmoREV.isCancelled())
|
||||||
//RFG//MMOItems.log("§8Reforge §4RFG§c Event Cancelled");
|
//RFG//MMOItems.log("§8Reforge §4RFG§c Event Cancelled");
|
||||||
return false; }
|
return false;
|
||||||
//RFG//MMOItems.log("§8Reforge §2RFG§7 Running Reforge Finish");
|
//RFG//MMOItems.log("§8Reforge §2RFG§7 Running Reforge Finish");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Properly recalculate all based on histories
|
* Properly recalculate all based on histories
|
||||||
*/
|
*/
|
||||||
for (StatHistory hist : getFreshMMOItem().getStatHistories()) {
|
for (StatHistory hist : getFreshMMOItem().getStatHistories())
|
||||||
|
|
||||||
// Recalculate that shit
|
// Recalculate that shit
|
||||||
getFreshMMOItem().setData(hist.getItemStat(), hist.recalculate(getFreshMMOItem().getUpgradeLevel()));
|
getFreshMMOItem().setData(hist.getItemStat(), hist.recalculate(getFreshMMOItem().getUpgradeLevel()));
|
||||||
}
|
|
||||||
if (getFreshMMOItem().hasUpgradeTemplate()) {
|
if (getFreshMMOItem().hasUpgradeTemplate()) {
|
||||||
|
|
||||||
for (ItemStat stat : getFreshMMOItem().getUpgradeTemplate().getKeys()) {
|
for (ItemStat stat : getFreshMMOItem().getUpgradeTemplate().getKeys()) {
|
||||||
@ -465,7 +534,7 @@ public class MMOItemReforger {
|
|||||||
result = getFreshMMOItem().newBuilder().build();
|
result = getFreshMMOItem().newBuilder().build();
|
||||||
|
|
||||||
// Run another event...
|
// Run another event...
|
||||||
MMOItemReforgeFinishEvent mmoFIN = new MMOItemReforgeFinishEvent(result,this, options);
|
MMOItemReforgeFinishEvent mmoFIN = new MMOItemReforgeFinishEvent(result, this, options);
|
||||||
Bukkit.getPluginManager().callEvent(mmoFIN);
|
Bukkit.getPluginManager().callEvent(mmoFIN);
|
||||||
|
|
||||||
// Finally, the result item.
|
// Finally, the result item.
|
||||||
@ -493,47 +562,64 @@ public class MMOItemReforger {
|
|||||||
//region Deprecated API
|
//region Deprecated API
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void update(@Nullable Player p, @NotNull ReforgeOptions options) {
|
public void update(@Nullable Player p, @NotNull ReforgeOptions options) {
|
||||||
if (p != null) { setPlayer(p); }
|
if (p != null)
|
||||||
|
setPlayer(p);
|
||||||
reforge(options);
|
reforge(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void update(@Nullable RPGPlayer player, @NotNull ReforgeOptions options) {
|
public void update(@Nullable RPGPlayer player, @NotNull ReforgeOptions options) {
|
||||||
if (player != null) { setPlayer(player); }
|
if (player != null)
|
||||||
|
setPlayer(player);
|
||||||
reforge(options);
|
reforge(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
void regenerate(@Nullable RPGPlayer p) {
|
void regenerate(@Nullable RPGPlayer p) {
|
||||||
if (p != null) { setPlayer(p); }
|
if (p != null)
|
||||||
|
setPlayer(p);
|
||||||
reforge(new ReforgeOptions(false, false, false, false, false, false, false, true));
|
reforge(new ReforgeOptions(false, false, false, false, false, false, false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
int regenerate(@Nullable RPGPlayer player, @NotNull MMOItemTemplate template) {
|
int regenerate(@Nullable RPGPlayer player, @NotNull MMOItemTemplate template) {
|
||||||
if (player != null) { setPlayer(player); }
|
if (player != null)
|
||||||
|
setPlayer(player);
|
||||||
canUpdate = true; //If the template exists, it EXISTS!
|
canUpdate = true; //If the template exists, it EXISTS!
|
||||||
this.template = template;
|
this.template = template;
|
||||||
reforge(new ReforgeOptions(false, false, false, false, false, false, false, true));
|
reforge(new ReforgeOptions(false, false, false, false, false, false, false, true));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void reforge(@Nullable Player p, @NotNull ReforgeOptions options) {
|
public void reforge(@Nullable Player p, @NotNull ReforgeOptions options) {
|
||||||
if (p != null) { setPlayer(p); }
|
if (p != null)
|
||||||
|
setPlayer(p);
|
||||||
reforge(options);
|
reforge(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void reforge(@Nullable RPGPlayer player, @NotNull ReforgeOptions options) {
|
public void reforge(@Nullable RPGPlayer player, @NotNull ReforgeOptions options) {
|
||||||
if (player != null) { setPlayer(player); }
|
if (player != null)
|
||||||
|
setPlayer(player);
|
||||||
reforge(options);
|
reforge(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public ItemStack toStack() {
|
public ItemStack toStack() {
|
||||||
return getResult();
|
return getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean hasChanges() {
|
public boolean hasChanges() {
|
||||||
return getResult() != null;
|
return getResult() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@NotNull public ArrayList<MMOItem> getDestroyedGems() { return new ArrayList<>(); }
|
@NotNull
|
||||||
|
public ArrayList<MMOItem> getDestroyedGems() {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ public class RevisionInventory extends EditionInventory {
|
|||||||
break;
|
break;
|
||||||
case 30:
|
case 30:
|
||||||
which = soulbind.clone();
|
which = soulbind.clone();
|
||||||
enable = MMOItems.plugin.getLanguage().revisionOptions.shouldKeepSoulbind();
|
enable = MMOItems.plugin.getLanguage().revisionOptions.shouldKeepSoulBind();
|
||||||
break;
|
break;
|
||||||
case 33:
|
case 33:
|
||||||
id = getEditedSection().getInt(ItemStats.REVISION_ID.getPath(), 1);
|
id = getEditedSection().getInt(ItemStats.REVISION_ID.getPath(), 1);
|
||||||
|
@ -21,6 +21,8 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ItemListener implements Listener {
|
public class ItemListener implements Listener {
|
||||||
|
|
||||||
// Aye
|
// Aye
|
||||||
@ -55,7 +57,7 @@ public class ItemListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
private void itemCraft(CraftItemEvent e) {
|
private void itemCraft(CraftItemEvent e) {
|
||||||
if(!(e.getWhoClicked() instanceof Player)) return;
|
if (!(e.getWhoClicked() instanceof Player)) return;
|
||||||
ItemStack newItem = modifyItem(e.getCurrentItem(), (Player) e.getWhoClicked(), "craft");
|
ItemStack newItem = modifyItem(e.getCurrentItem(), (Player) e.getWhoClicked(), "craft");
|
||||||
if (newItem != null) e.setCurrentItem(newItem);
|
if (newItem != null) e.setCurrentItem(newItem);
|
||||||
}
|
}
|
||||||
@ -79,13 +81,13 @@ public class ItemListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
ItemStack newItem = modifyItem(player.getEquipment().getHelmet(), player, "join");
|
ItemStack newItem = modifyItem(player.getEquipment().getHelmet(), player, "join");
|
||||||
if(newItem != null) player.getEquipment().setHelmet(newItem);
|
if (newItem != null) player.getEquipment().setHelmet(newItem);
|
||||||
newItem = modifyItem(player.getEquipment().getChestplate(), player, "join");
|
newItem = modifyItem(player.getEquipment().getChestplate(), player, "join");
|
||||||
if(newItem != null) player.getEquipment().setChestplate(newItem);
|
if (newItem != null) player.getEquipment().setChestplate(newItem);
|
||||||
newItem = modifyItem(player.getEquipment().getLeggings(), player, "join");
|
newItem = modifyItem(player.getEquipment().getLeggings(), player, "join");
|
||||||
if(newItem != null) player.getEquipment().setLeggings(newItem);
|
if (newItem != null) player.getEquipment().setLeggings(newItem);
|
||||||
newItem = modifyItem(player.getEquipment().getBoots(), player, "join");
|
newItem = modifyItem(player.getEquipment().getBoots(), player, "join");
|
||||||
if(newItem != null) player.getEquipment().setBoots(newItem);
|
if (newItem != null) player.getEquipment().setBoots(newItem);
|
||||||
|
|
||||||
for (int j = 0; j < 9; j++) {
|
for (int j = 0; j < 9; j++) {
|
||||||
newItem = modifyItem(player.getInventory().getItem(j), player, "join");
|
newItem = modifyItem(player.getInventory().getItem(j), player, "join");
|
||||||
@ -93,37 +95,35 @@ public class ItemListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
newItem = modifyItem(player.getEquipment().getItemInOffHand(), player, "join");
|
newItem = modifyItem(player.getEquipment().getItemInOffHand(), player, "join");
|
||||||
if(newItem != null) player.getEquipment().setItemInOffHand(newItem);
|
if (newItem != null) player.getEquipment().setItemInOffHand(newItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable private ItemStack modifyItem(@Nullable ItemStack stack, @NotNull Player player, @NotNull String reason) {
|
@Nullable
|
||||||
|
private ItemStack modifyItem(@Nullable ItemStack stack, @NotNull Player player, @NotNull String reason) {
|
||||||
//RFG//MMOItems.log("§8Reforge §cMOD§7 Modifying " + SilentNumbers.getItemName(stack) + " §7due to§3 " + reason);
|
//RFG//MMOItems.log("§8Reforge §cMOD§7 Modifying " + SilentNumbers.getItemName(stack) + " §7due to§3 " + reason);
|
||||||
|
|
||||||
// Sleep on metaless stacks
|
// Sleep on metaless stacks
|
||||||
if (stack == null) { return null; }
|
if (stack == null || !stack.hasItemMeta())
|
||||||
if (!stack.hasItemMeta()) { return null; }
|
return null;
|
||||||
|
|
||||||
// Create a reforger to look at it
|
// Create a reforger to look at it
|
||||||
MMOItemReforger mod = new MMOItemReforger(stack);
|
MMOItemReforger mod = new MMOItemReforger(stack);
|
||||||
|
|
||||||
// Shouldn't update? I sleep
|
// Shouldn't update? I sleep
|
||||||
if (!mod.shouldReforge(reason)) { return null; }
|
if (!mod.shouldReforge(reason)) return null;
|
||||||
|
|
||||||
// All right update then
|
// All right update then
|
||||||
mod.setPlayer(player);
|
mod.setPlayer(player);
|
||||||
if (!mod.reforge(MMOItems.plugin.getLanguage().revisionOptions)) {
|
if (!mod.reforge(MMOItems.plugin.getLanguage().revisionOptions))
|
||||||
|
return null;
|
||||||
return null; }
|
|
||||||
|
|
||||||
// Drop all those items
|
// Drop all those items
|
||||||
for (ItemStack drop : player.getInventory().addItem(
|
player.getInventory()
|
||||||
mod.getReforgingOutput().toArray(new ItemStack[0])).values()) {
|
.addItem(mod.getReforgingOutput().toArray(new ItemStack[0]))
|
||||||
|
.values()
|
||||||
// Not air right
|
.stream()
|
||||||
if (SilentNumbers.isAir(drop)) { continue; }
|
.filter(drop -> !SilentNumbers.isAir(drop))
|
||||||
|
.forEach(drop -> player.getWorld().dropItem(player.getLocation(), drop));
|
||||||
// Drop to the world
|
|
||||||
player.getWorld().dropItem(player.getLocation(), drop); }
|
|
||||||
|
|
||||||
// That's it
|
// That's it
|
||||||
return mod.getResult();
|
return mod.getResult();
|
||||||
|
@ -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.random.RandomStatData;
|
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
|
||||||
import net.Indyuce.mmoitems.stat.data.random.UpdatableRandomStatData;
|
import net.Indyuce.mmoitems.stat.data.random.UpdatableRandomStatData;
|
||||||
@ -24,40 +23,35 @@ public class RFGKeepRNG implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onReforge(MMOItemReforgeEvent event) {
|
public void onReforge(MMOItemReforgeEvent event) {
|
||||||
|
|
||||||
// Rerolling stats? Nevermind
|
// Rerolling stats? Nevermind
|
||||||
if (event.getOptions().shouldReroll()) {
|
if (event.getOptions().shouldReRoll()) {
|
||||||
|
event.setCancelled(true);
|
||||||
//RFG// MMOItems.log("§8Reforge §4EFG§7 Keeping new item (Complete RNG Reroll)");
|
//RFG// MMOItems.log("§8Reforge §4EFG§7 Keeping new item (Complete RNG Reroll)");
|
||||||
return; }
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//RFG// MMOItems.log("§8Reforge §4EFG§7 Keeping old RNG Rolls");
|
//RFG// MMOItems.log("§8Reforge §4EFG§7 Keeping old RNG Rolls");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Proceed to go through all stats
|
* Proceed to go through all stats
|
||||||
*/
|
*/
|
||||||
for (ItemStat stat : event.getOldMMOItem().getStats()) {
|
event.getOldMMOItem()
|
||||||
|
.getStats()
|
||||||
|
.stream()
|
||||||
// Skip if it cant merge
|
// Skip if it cant merge
|
||||||
if (!(stat.getClearStatData() instanceof Mergeable)) {
|
.filter(stat -> stat.getClearStatData() instanceof Mergeable)
|
||||||
//RFG// MMOItems.log("§8Reforge §3RNG§7 Stat\u00a7f " + stat.getId() + "\u00a77 is \u00a7cnot\u00a77 even mergeable");
|
|
||||||
continue; }
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These stats are exempt from this 'keeping' operation.
|
* These stats are exempt from this 'keeping' operation.
|
||||||
* Probably because there is a ReforgeOption specifically
|
* Probably because there is a ReforgeOption specifically
|
||||||
* designed for them that keeps them separately
|
* designed for them that keeps them separately
|
||||||
*/
|
*/
|
||||||
if (ItemStats.LORE.equals(stat) ||
|
.filter(stat -> !(ItemStats.LORE.equals(stat) ||
|
||||||
ItemStats.NAME.equals(stat) ||
|
ItemStats.NAME.equals(stat) ||
|
||||||
ItemStats.UPGRADE.equals(stat) ||
|
ItemStats.UPGRADE.equals(stat) ||
|
||||||
ItemStats.ENCHANTS.equals(stat) ||
|
ItemStats.ENCHANTS.equals(stat) ||
|
||||||
ItemStats.SOULBOUND.equals(stat) ||
|
ItemStats.SOULBOUND.equals(stat) ||
|
||||||
ItemStats.GEM_SOCKETS.equals(stat)) {
|
ItemStats.GEM_SOCKETS.equals(stat)))
|
||||||
//RFG// MMOItems.log("§8Reforge §3RNG§7 Stat\u00a7f " + stat.getId() + "\u00a77 is \u00a7cnot\u00a77 processed here");
|
.forEach(stat -> {
|
||||||
continue; }
|
|
||||||
|
|
||||||
//RFG// MMOItems.log("§8Reforge §3RNG§7 Stat\u00a7f " + stat.getId() + "\u00a77 being \u00a7bprocessed\u00a77...");
|
|
||||||
|
|
||||||
// Stat history in the old item
|
// Stat history in the old item
|
||||||
StatHistory hist = StatHistory.from(event.getOldMMOItem(), stat);
|
StatHistory hist = StatHistory.from(event.getOldMMOItem(), stat);
|
||||||
|
|
||||||
@ -69,22 +63,23 @@ 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.
|
||||||
*/
|
*/
|
||||||
StatData keptData = shouldRerollRegardless(stat, source, hist.getOriginalData(), event.getReforger().getGenerationItemLevel());
|
StatData keptData = shouldReRollRegardless(stat, source, 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.
|
||||||
if (keptData == null) { continue; }
|
if (keptData == null)
|
||||||
|
return;
|
||||||
|
|
||||||
// Fetch History from the new item
|
// Fetch History from the new item
|
||||||
StatHistory clear = StatHistory.from(event.getNewMMOItem(), stat);
|
StatHistory clear = StatHistory.from(event.getNewMMOItem(), 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);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The item is supposedly being updated, but that doesnt mean all its stats must remain the same.
|
* @return The item is supposedly being updated, but that doesnt mean all its stats must remain the same.
|
||||||
*
|
* <p>
|
||||||
* In contrast to reforging, in which it is expected its RNG to be rerolled, updating should not do it
|
* In contrast to reforging, in which it is expected its RNG to be rerolled, updating should not do it
|
||||||
* except in the most dire scenarios:
|
* except in the most dire scenarios:
|
||||||
* <br><br>
|
* <br><br>
|
||||||
@ -95,15 +90,12 @@ public class RFGKeepRNG implements Listener {
|
|||||||
* <br><br>
|
* <br><br>
|
||||||
* + There is a new stat: The original data is null so this method cannot be called, will roll the
|
* + There is a new stat: The original data is null so this method cannot be called, will roll the
|
||||||
* new stat to actually add it for the first time.
|
* new stat to actually add it for the first time.
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Nullable StatData shouldRerollRegardless(@NotNull ItemStat stat, @NotNull RandomStatData source, @NotNull StatData original, int determinedItemLevel) {
|
@Nullable StatData shouldReRollRegardless(@NotNull ItemStat stat, @NotNull RandomStatData source, @NotNull StatData original, int determinedItemLevel) {
|
||||||
|
|
||||||
// Not Mergeable, impossible to keep
|
// Not Mergeable, impossible to keep
|
||||||
if (!(source instanceof UpdatableRandomStatData)) {
|
if (!(source instanceof UpdatableRandomStatData))
|
||||||
//RFG// MMOItems.log("§8Reforge §3RNG§7 Stat\u00a7f " + stat.getId() + "\u00a77 is not updatable!");
|
//RFG// MMOItems.log("§8Reforge §3RNG§7 Stat\u00a7f " + stat.getId() + "\u00a77 is not updatable!");
|
||||||
return null; }
|
return null;
|
||||||
|
|
||||||
// Just pass on
|
// Just pass on
|
||||||
return ((UpdatableRandomStatData) source).reroll(stat, original, determinedItemLevel);
|
return ((UpdatableRandomStatData) source).reroll(stat, original, determinedItemLevel);
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
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.api.util.MMOItemReforger;
|
|
||||||
import net.Indyuce.mmoitems.stat.data.SoulboundData;
|
import net.Indyuce.mmoitems.stat.data.SoulboundData;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -36,7 +34,7 @@ public class RFGKeepSoulbound implements Listener {
|
|||||||
// event.getNewMMOItem().setData(ItemStats.SOULBOUND, new SoulboundData(event.getPlayer().getUniqueId(), event.getPlayer().getName(), MMOItemReforger.autoSoulbindLevel));
|
// event.getNewMMOItem().setData(ItemStats.SOULBOUND, new SoulboundData(event.getPlayer().getUniqueId(), event.getPlayer().getName(), MMOItemReforger.autoSoulbindLevel));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
} else if (event.getOptions().shouldKeepSoulbind()) {
|
} else if (event.getOptions().shouldKeepSoulBind()) {
|
||||||
//RFG// MMOItems.log("§8Reforge §4EFG§7 Keeping Soulbound");
|
//RFG// MMOItems.log("§8Reforge §4EFG§7 Keeping Soulbound");
|
||||||
|
|
||||||
// Keep it
|
// Keep it
|
||||||
|
Loading…
Reference in New Issue
Block a user