Removed occurences of #getModifier, fixing issue w/ skill timers

This commit is contained in:
Jules 2023-06-18 14:49:40 +02:00
parent 516f286d66
commit f67c6fe6af
5 changed files with 22 additions and 22 deletions

View File

@ -240,7 +240,7 @@ public class PluginUpdateManager {
// Apply old modifier name
for (String mod : skill.getHandler().getModifiers())
config.set("modifier." + mod + ".name", Objects.requireNonNullElse(abilities.getString("modifier." + mod), skill.getModifierName(mod)));
config.set("modifier." + mod + ".name", Objects.requireNonNullElse(abilities.getString("modifier." + mod), skill.getParameterName(mod)));
configFile.save();
}

View File

@ -13,16 +13,16 @@ import java.util.Objects;
public class RegisteredSkill {
@NotNull private final SkillHandler<?> handler;
@NotNull private final String name;
@NotNull private final Map<String, String> modifierNames = new HashMap<>();
@NotNull private final Map<String, Double> modifierDefaultValues = new HashMap<>();
@NotNull private final Map<String, String> parameterNames = new HashMap<>();
@NotNull private final Map<String, Double> defaultParameterValues = new HashMap<>();
public RegisteredSkill(@NotNull SkillHandler<?> handler, @NotNull ConfigurationSection config) {
this.handler = handler;
this.name = Objects.requireNonNull(config.getString("name"), "Could not fill skill name");
for (String mod : handler.getModifiers()) {
modifierNames.put(mod, config.getString("modifier." + mod + ".name", UtilityMethods.caseOnWords(mod.replace("_", " ").replace("-", " ").toLowerCase())));
modifierDefaultValues.put(mod, config.getDouble("modifier." + mod + ".default-value"));
parameterNames.put(mod, config.getString("modifier." + mod + ".name", UtilityMethods.caseOnWords(mod.replace("_", " ").replace("-", " ").toLowerCase())));
defaultParameterValues.put(mod, config.getDouble("modifier." + mod + ".default-value"));
}
}
@ -42,20 +42,20 @@ public class RegisteredSkill {
@Deprecated
public void setDefaultValue(String modifier, double value) {
modifierDefaultValues.put(modifier, value);
defaultParameterValues.put(modifier, value);
}
@Deprecated
public void setName(String modifier, String name) {
modifierNames.put(modifier, name);
parameterNames.put(modifier, name);
}
@Nullable
public String getModifierName(String modifier) {
return modifierNames.get(modifier);
public String getParameterName(String modifier) {
return parameterNames.get(modifier);
}
public double getDefaultModifier(String modifier) {
return modifierDefaultValues.get(modifier);
return defaultParameterValues.get(modifier);
}
}

View File

@ -45,7 +45,7 @@ public class ShulkerMissile extends SkillHandler<VectorSkillResult> implements L
@Override
public void whenCast(VectorSkillResult result, SkillMetadata skillMeta) {
double duration = skillMeta.getModifier("duration");
double duration = skillMeta.getParameter("duration");
Player caster = skillMeta.getCaster().getPlayer();
@ -64,7 +64,7 @@ public class ShulkerMissile extends SkillHandler<VectorSkillResult> implements L
EntityType.SHULKER_BULLET);
shulkerBullet.setShooter(caster);
MMOItems.plugin.getEntities().registerCustomEntity(shulkerBullet, new ShulkerMissileEntityData(skillMeta.getCaster(), new DamageMetadata(skillMeta.getModifier("damage"), DamageType.SKILL, DamageType.MAGIC, DamageType.PROJECTILE), skillMeta.getModifier("effect-duration"), null));
MMOItems.plugin.getEntities().registerCustomEntity(shulkerBullet, new ShulkerMissileEntityData(skillMeta.getCaster(), new DamageMetadata(skillMeta.getParameter("damage"), DamageType.SKILL, DamageType.MAGIC, DamageType.PROJECTILE), skillMeta.getParameter("effect-duration"), null));
new BukkitRunnable() {
double ti = 0;

View File

@ -64,9 +64,9 @@ public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData>
for (String modifier : ability.getModifiers()) {
item.getLore().registerPlaceholder("ability_" + ability.getAbility().getHandler().getId().toLowerCase() + "_" + modifier,
MythicLib.plugin.getMMOConfig().decimals.format(ability.getModifier(modifier)));
abilityLore.add(modifierFormat.replace("{modifier}", ability.getAbility().getModifierName(modifier)).replace("{value}",
MythicLib.plugin.getMMOConfig().decimals.format(ability.getModifier(modifier))));
MythicLib.plugin.getMMOConfig().decimals.format(ability.getParameter(modifier)));
abilityLore.add(modifierFormat.replace("{modifier}", ability.getAbility().getParameterName(modifier)).replace("{value}",
MythicLib.plugin.getMMOConfig().decimals.format(ability.getParameter(modifier))));
}
if (splitter)

View File

@ -108,13 +108,13 @@ public class AbilityData extends Skill {
return false;
// Check for mana cost
if (hasModifier("mana") && rpgPlayer.getMana() < getModifier("mana")) {
if (hasModifier("mana") && rpgPlayer.getMana() < getParameter("mana")) {
Message.NOT_ENOUGH_MANA.format(ChatColor.RED).send(player);
return false;
}
// Check for stamina cost
if (hasModifier("stamina") && rpgPlayer.getStamina() < getModifier("stamina")) {
if (hasModifier("stamina") && rpgPlayer.getStamina() < getParameter("stamina")) {
Message.NOT_ENOUGH_STAMINA.format(ChatColor.RED).send(player);
return false;
}
@ -128,13 +128,13 @@ public class AbilityData extends Skill {
RPGPlayer rpgPlayer = playerData.getRPG();
// Apply mana cost
if (hasModifier("mana")) rpgPlayer.giveMana(-meta.getModifier("mana"));
if (hasModifier("mana")) rpgPlayer.giveMana(-meta.getParameter("mana"));
// Apply stamina cost
if (hasModifier("stamina")) rpgPlayer.giveStamina(-meta.getModifier("stamina"));
if (hasModifier("stamina")) rpgPlayer.giveStamina(-meta.getParameter("stamina"));
// Apply cooldown
double cooldown = meta.getModifier("cooldown") * (1 - Math.min(.8, meta.getCaster().getStat("COOLDOWN_REDUCTION") / 100));
double cooldown = meta.getParameter("cooldown") * (1 - Math.min(.8, meta.getCaster().getStat("COOLDOWN_REDUCTION") / 100));
if (cooldown > 0) meta.getCaster().getData().getCooldownMap().applyCooldown(this, cooldown);
}
@ -144,7 +144,7 @@ public class AbilityData extends Skill {
}
@Override
public double getModifier(String path) {
public double getParameter(String path) {
return modifiers.getOrDefault(path, ability.getDefaultModifier(path));
}
@ -154,7 +154,7 @@ public class AbilityData extends Skill {
object.addProperty("CastMode", getTrigger().name());
JsonObject modifiers = new JsonObject();
this.modifiers.keySet().forEach(modifier -> modifiers.addProperty(modifier, getModifier(modifier)));
this.modifiers.keySet().forEach(modifier -> modifiers.addProperty(modifier, getParameter(modifier)));
object.add("Modifiers", modifiers);
return object;