Displaying upgrades can now be done in the lore instead.

(Regen config.yml if you want to use these changes.)
This commit is contained in:
Aria 2019-12-09 17:38:55 +01:00
parent 5a1a754538
commit 12d21d1b8b
2 changed files with 20 additions and 5 deletions

View File

@ -23,6 +23,7 @@ import net.Indyuce.mmoitems.api.util.AltChar;
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.gui.edition.UpgradingEdition;
import net.Indyuce.mmoitems.stat.data.StatData;
import net.Indyuce.mmoitems.stat.data.StringListData;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.Indyuce.mmoitems.stat.type.StringStat.StringData;
import net.Indyuce.mmoitems.version.nms.ItemTag;
@ -192,12 +193,21 @@ public class Upgrade_Stat extends ItemStat {
}
public void upgrade(MMOItem mmoitem) {
// change display name
if (mmoitem.hasData(ItemStat.NAME)) {
String suffix = ChatColor.translateAlternateColorCodes('&', MMOItems.plugin.getConfig().getString("item-upgrading.name-suffix"));
StringData nameData = (StringData) mmoitem.getData(ItemStat.NAME);
nameData.setString(level == 0 ? nameData.toString() + suffix.replace("#lvl#", "" + (level + 1)) : nameData.toString().replace(suffix.replace("#lvl#", "" + level), suffix.replace("#lvl#", "" + (level + 1))));
String suffix = ChatColor.translateAlternateColorCodes('&', MMOItems.plugin.getConfig().getString("item-upgrading.name-suffix"));
if(MMOItems.plugin.getConfig().getBoolean("item-upgrading.display-in-name"))
if (mmoitem.hasData(ItemStat.NAME)) {
StringData nameData = (StringData) mmoitem.getData(ItemStat.NAME);
nameData.setString(level == 0 ? nameData.toString() + suffix.replace("#lvl#", "" + (level + 1)) : nameData.toString().replace(suffix.replace("#lvl#", "" + level), suffix.replace("#lvl#", "" + (level + 1))));
}
else if (mmoitem.hasData(ItemStat.LORE)) {
StringListData loreData = (StringListData) mmoitem.getData(ItemStat.LORE);
loreData.getList().forEach(line -> {
if(line.contains("%upgrade_level%") || line.contains(suffix.replace("#lvl#", "" + level))) {
line.replace("%upgrade_level%", suffix.replace("#lvl#", "" + level + 1));
line.replace(suffix.replace("#lvl#", "" + level), suffix.replace("#lvl#", "" + level + 1));
}
});
}
// apply stat updates

View File

@ -62,6 +62,11 @@ item-glow: true
item-upgrading:
# Display name suffix for upgraded items.
name-suffix: '&f &a+#lvl#'
# Whether to display in Item Name or Lore
# Disable if item renaming is available to players.
# If set to 'false', remember to include
# %upgrade_level% in your item lore.
display-in-name: true
soulbound:
# Edit soulbound damage when players try to use