Default item ability no longer prompts console error logs

This commit is contained in:
Jules 2024-06-21 13:17:20 -07:00
parent a85b4d05c3
commit 56f5e580d0
4 changed files with 16 additions and 6 deletions

View File

@ -124,9 +124,13 @@ public class AbilityListEdition extends EditionInventory {
for (int j = 1; j < 8; j++)
if (!getEditedSection().getConfigurationSection("ability").contains("ability" + j)) {
getEditedSection().createSection("ability.ability" + j);
// (Fixes MMOItems#1575) Initialize sample ability to avoid console logs
final String tag = "ability" + j;
getEditedSection().set("ability." + tag + ".type", "FIREBOLT");
getEditedSection().set("ability." + tag + ".mode", "RIGHT_CLICK");
registerTemplateEdition();
break;
return;
}
}

View File

@ -2,7 +2,6 @@ package net.Indyuce.mmoitems.manager;
import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.skill.trigger.TriggerType;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ConfigFile;
import net.Indyuce.mmoitems.api.ReforgeOptions;
@ -243,8 +242,14 @@ public class ConfigManager implements Reloadable {
return Message.valueOf(UtilityMethods.enumName(path)).getUpdated();
}
@Deprecated
@NotNull
public String getCastingModeName(@NotNull TriggerType triggerType) {
return getTriggerTypeName(triggerType);
}
@NotNull
public String getTriggerTypeName(@NotNull TriggerType triggerType) {
return Objects.requireNonNull(triggerTypeNames.get(triggerType), "Trigger type name for '" + triggerType.name() + "' not found");
}

View File

@ -89,7 +89,7 @@ public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData>
data.getAbilities().forEach(ability -> {
final StringBuilder builder = new StringBuilder(generalFormat
.replace("{trigger}", MMOItems.plugin.getLanguage().getCastingModeName(ability.getTrigger()))
.replace("{trigger}", MMOItems.plugin.getLanguage().getTriggerTypeName(ability.getTrigger()))
.replace("{ability}", ability.getAbility().getName()));
if (!ability.getModifiers().isEmpty()) builder.append(modifierIfAny);

View File

@ -21,7 +21,8 @@ public class RandomAbilityData {
private final Map<String, NumericStatFormula> modifiers = new HashMap<>();
public RandomAbilityData(ConfigurationSection config) {
Validate.isTrue(config.contains("type") && config.contains("mode"), "Ability is missing type or mode");
Validate.isTrue(config.contains("type"), "Missing ability type");
Validate.isTrue(config.contains("mode"), "Missing ability trigger type/casting mode");
String abilityFormat = config.getString("type").toUpperCase().replace("-", "_").replace(" ", "_");
Validate.isTrue(MMOItems.plugin.getSkills().hasSkill(abilityFormat), "Could not find ability called '" + abilityFormat + "'");