mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-23 00:05:52 +01:00
Added possibility to specify decimal format for each skill parameter regarding issue #866.
This commit is contained in:
parent
892b04cd3a
commit
49b699b54b
@ -149,7 +149,10 @@ public class ClassSkill implements CooldownObject, Unlockable {
|
||||
|
||||
// Calculate placeholders
|
||||
Placeholders placeholders = new Placeholders();
|
||||
parameters.keySet().forEach(modifier -> placeholders.register(modifier, MythicLib.plugin.getMMOConfig().decimal.format(data.getMMOPlayerData().getSkillModifierMap().getInstance(skill.getHandler(), modifier).getTotal(parameters.get(modifier).calculate(x)))));
|
||||
parameters.keySet()
|
||||
.forEach(param -> {
|
||||
placeholders.register(param, skill.getDecimalFormat(param).format(data.getMMOPlayerData().getSkillModifierMap().getInstance(skill.getHandler(), param).getTotal(parameters.get(param).calculate(x))));
|
||||
});
|
||||
placeholders.register("mana_name", data.getProfess().getManaDisplay().getName());
|
||||
placeholders.register("mana_color", data.getProfess().getManaDisplay().getFull().toString());
|
||||
|
||||
|
@ -13,12 +13,16 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class RegisteredSkill {
|
||||
private final SkillHandler<?> handler;
|
||||
private final String name;
|
||||
private final Map<String, LinearValue> defaultParameters = new HashMap<>();
|
||||
|
||||
private final Map<String, DecimalFormat> parameterDecimalFormats = new HashMap<>();
|
||||
|
||||
private final ItemStack icon;
|
||||
private final List<String> lore;
|
||||
private final List<String> categories;
|
||||
@ -42,10 +46,15 @@ public class RegisteredSkill {
|
||||
else
|
||||
categories.add("ACTIVE");
|
||||
|
||||
|
||||
// Load default modifier formulas
|
||||
for (String param : handler.getParameters())
|
||||
for (String param : handler.getParameters()) {
|
||||
if (config.contains(param + ".decimal-format"))
|
||||
parameterDecimalFormats.put(param, new DecimalFormat(config.getString(param + ".decimal-format")));
|
||||
defaultParameters.put(param, config.contains(param) ? new LinearValue(config.getConfigurationSection(param)) : LinearValue.ZERO);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* This is so that SkillAPI skill level matches the MMOCore skill level
|
||||
* https://gitlab.com/phoenix-dvpmt/mmocore/-/issues/531
|
||||
@ -111,6 +120,10 @@ public class RegisteredSkill {
|
||||
defaultParameters.put(parameter, linear);
|
||||
}
|
||||
|
||||
public DecimalFormat getDecimalFormat(String parameter) {
|
||||
return parameterDecimalFormats.getOrDefault(parameter, MythicLib.plugin.getMMOConfig().decimal);
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public void addModifierIfNone(String mod, LinearValue defaultValue) {
|
||||
|
Loading…
Reference in New Issue
Block a user