Negative stats now show up in the lore.

This commit is contained in:
Ethan 2020-12-07 02:59:25 -05:00
parent 8ce520cc2a
commit ec4ae923d2
3 changed files with 15 additions and 2 deletions

Binary file not shown.

View File

@ -51,9 +51,16 @@ public class DoubleStat extends ItemStat implements Upgradable {
@Override @Override
public void whenApplied(ItemStackBuilder item, StatData data) { public void whenApplied(ItemStackBuilder item, StatData data) {
double value = ((DoubleData) data).getValue(); double value = ((DoubleData) data).getValue();
item.addItemTag(new ItemTag(getNBTPath(), value)); // If value is not allowed to be negative it will not
if (value > 0) // apply the stat or the lore.
if (value < 0 && !canNegative())
return;
// If the value is 0 the lore will not be applied
// but the stat will still be added to the nbt
if (value != 0)
item.getLore().insert(getPath(), formatNumericStat(value, "#", new StatFormat("##").format(value))); item.getLore().insert(getPath(), formatNumericStat(value, "#", new StatFormat("##").format(value)));
item.addItemTag(new ItemTag(getNBTPath(), value));
} }
@Override @Override

View File

@ -210,4 +210,10 @@ public abstract class ItemStat {
String str = MMOItems.plugin.getLanguage().getStatFormat(path); String str = MMOItems.plugin.getLanguage().getStatFormat(path);
return str == null ? "<TranslationNotFound:" + path + ">" : str; return str == null ? "<TranslationNotFound:" + path + ">" : str;
} }
// Sets if the double value is allowed to be
// a negative.
public boolean canNegative() {
return true;
}
} }