Merge remote-tracking branch 'origin/master'

This commit is contained in:
Ka0rX 2022-07-26 10:25:19 +02:00
commit 2e5cb2b725
2 changed files with 7 additions and 3 deletions

View File

@ -2,6 +2,7 @@ package net.Indyuce.mmocore.gui;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.api.stat.handler.StatHandler;
import io.lumine.mythic.lib.api.stat.modifier.StatModifier;
import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmocore.MMOCore;
@ -131,13 +132,13 @@ public class PlayerStats extends EditableInventory {
replaced = info.format(stats.getBase(info.name));
} else if (holder.endsWith("_extra")) {
StatInfo info = StatInfo.valueOf(UtilityMethods.enumName(holder.substring(0, holder.length() - 5)));
replaced = info.format(stats.getStat(info.name) - stats.getBase(info.name));
replaced = info.format(MythicLib.plugin.getStats().getTotalValue(info.name, stats.getMap()) - stats.getBase(info.name));
} else if (holder.startsWith("attribute_")) {
PlayerAttribute attr = MMOCore.plugin.attributeManager.get(holder.substring(10).replace("_", "-").toLowerCase());
replaced = String.valueOf(inv.target.getAttributes().getAttribute(attr));
} else {
StatInfo info = StatInfo.valueOf(UtilityMethods.enumName(holder));
replaced = info.format(stats.getStat(info.name));
replaced = info.format(MythicLib.plugin.getStats().getTotalValue(info.name, stats.getMap()));
}
str = str.replace("{" + holder + "}", replaced);

View File

@ -2,6 +2,7 @@ package net.Indyuce.mmocore.gui.api.item;
import net.Indyuce.mmocore.MMOCore;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
@ -21,7 +22,9 @@ public class Placeholders {
// Internal placeholders
while (str.contains("{") && str.substring(str.indexOf("{")).contains("}")) {
String holder = str.substring(str.indexOf("{") + 1, str.indexOf("}"));
str = str.replace("{" + holder + "}", placeholders.getOrDefault(holder, "Error"));
@Nullable String found = placeholders.get(holder);
if (found != null)
str = str.replace("{" + holder + "}", found);
}
// External placeholders