You can now add action-bar: 'format' to class files

This will override the default action bar format for that class only.
Formatting is the same as the default one.
This commit is contained in:
ASangarin 2020-09-10 19:29:41 +02:00
parent 2620f67672
commit 1ec270566d
2 changed files with 12 additions and 2 deletions

View File

@ -31,7 +31,7 @@ public class PlayerActionBar extends BukkitRunnable {
for (PlayerData data : PlayerData.getAll())
if (data.isOnline() && !data.getPlayer().isDead() && !data.isCasting() && data.canSeeActionBar()) {
data.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(MMOCore.plugin.placeholderParser.parse(data.getPlayer(),
MMOLib.plugin.parseColors(new String(format)
MMOLib.plugin.parseColors(new String(data.getProfess().hasActionBar() ? data.getProfess().getActionBar() : format)
.replace("{health}", digit.format(data.getPlayer().getHealth()))
.replace("{max_health}", "" + StatType.MAX_HEALTH.format(data.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()))
.replace("{mana_icon}", data.getProfess().getManaDisplay().getIcon())

View File

@ -43,7 +43,7 @@ import net.mmogroup.mmolib.api.MMOLineConfig;
import net.mmogroup.mmolib.version.VersionMaterial;
public class PlayerClass extends PostLoadObject {
private final String name, id;
private final String name, id, actionBarFormat;
private final List<String> description = new ArrayList<>(), attrDescription = new ArrayList<>();
private final ItemStack icon;
private final Map<ClassOption, Boolean> options = new HashMap<>();
@ -90,6 +90,7 @@ public class PlayerClass extends PostLoadObject {
: ManaDisplayOptions.DEFAULT;
maxLevel = config.getInt("max-level");
displayOrder = config.getInt("display.order");
actionBarFormat = config.getString("action-bar", "");
expCurve = config.contains("exp-curve")
? MMOCore.plugin.experience.getOrThrow(
@ -185,6 +186,7 @@ public class PlayerClass extends PostLoadObject {
displayOrder = 0;
expCurve = ExpCurve.DEFAULT;
castParticle = new CastingParticle(Particle.SPELL_INSTANT);
actionBarFormat = "";
this.icon = new ItemStack(material);
setOption(ClassOption.DISPLAY, false);
@ -321,4 +323,12 @@ public class PlayerClass extends PostLoadObject {
public boolean equals(Object obj) {
return obj != null && obj instanceof PlayerClass && ((PlayerClass) obj).id.equals(id);
}
public String getActionBar() {
return actionBarFormat;
}
public boolean hasActionBar() {
return actionBarFormat.isEmpty();
}
}