From b9b0f18faaffeea756e473aca1f1a9dd16356846 Mon Sep 17 00:00:00 2001 From: Jules Date: Mon, 7 Feb 2022 20:13:38 +0100 Subject: [PATCH] MI no longer dies when not adding modifier translation --- .../java/net/Indyuce/mmoitems/listener/PlayerListener.java | 5 ----- .../java/net/Indyuce/mmoitems/manager/SkillManager.java | 6 +++--- .../java/net/Indyuce/mmoitems/skill/RegisteredSkill.java | 6 +++--- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/Indyuce/mmoitems/listener/PlayerListener.java b/src/main/java/net/Indyuce/mmoitems/listener/PlayerListener.java index 80fd0053..0baad61c 100644 --- a/src/main/java/net/Indyuce/mmoitems/listener/PlayerListener.java +++ b/src/main/java/net/Indyuce/mmoitems/listener/PlayerListener.java @@ -58,11 +58,6 @@ public class PlayerListener implements Listener { public void savePlayerData(PlayerQuitEvent event) { PlayerData.get(event.getPlayer()).save(); } - public static boolean ChanceSuccess(int percentChance) { - Random rand = new Random(); - return rand.nextInt(100) <= percentChance; - } - /** * If the player dies, its time to roll the death-downgrade stat! */ diff --git a/src/main/java/net/Indyuce/mmoitems/manager/SkillManager.java b/src/main/java/net/Indyuce/mmoitems/manager/SkillManager.java index b092b162..914eded5 100644 --- a/src/main/java/net/Indyuce/mmoitems/manager/SkillManager.java +++ b/src/main/java/net/Indyuce/mmoitems/manager/SkillManager.java @@ -104,7 +104,7 @@ public class SkillManager { } // Copy mythiclib skills - for (SkillHandler handler : MythicLib.plugin.getSkills().getHandlers()) { + for (SkillHandler handler : MythicLib.plugin.getSkills().getHandlers()) { /* * Generate skill configuration files @@ -112,8 +112,8 @@ public class SkillManager { ConfigFile config = new ConfigFile("/skill", handler.getLowerCaseId()); if (!config.exists()) { config.getConfig().set("name", MMOUtils.caseOnWords(handler.getId().replace("_", " ").replace("-", " ").toLowerCase())); - for (Object mod : handler.getModifiers()) { - config.getConfig().set("modifier." + mod + ".name", MMOUtils.caseOnWords(mod.toString().replace("-", " ").toLowerCase())); + for (String mod : handler.getModifiers()) { + config.getConfig().set("modifier." + mod + ".name", MMOUtils.caseOnWords(mod.replace("-", " ").toLowerCase())); config.getConfig().set("modifier." + mod + ".default-value", 0); } config.save(); diff --git a/src/main/java/net/Indyuce/mmoitems/skill/RegisteredSkill.java b/src/main/java/net/Indyuce/mmoitems/skill/RegisteredSkill.java index c02ad459..e86aeac7 100644 --- a/src/main/java/net/Indyuce/mmoitems/skill/RegisteredSkill.java +++ b/src/main/java/net/Indyuce/mmoitems/skill/RegisteredSkill.java @@ -1,5 +1,6 @@ package net.Indyuce.mmoitems.skill; +import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.skill.handler.SkillHandler; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOUtils; @@ -22,9 +23,8 @@ public class RegisteredSkill { this.handler = handler; this.name = Objects.requireNonNull(config.getString("name"), "Could not fill skill name"); - for (Object obj : handler.getModifiers()) { - String mod = obj.toString(); - modifierNames.put(mod, Objects.requireNonNull(config.getString("modifier." + mod + ".name"), "Could not find translation for modifier '" + mod + "'")); + for (String mod : handler.getModifiers()) { + modifierNames.put(mod, config.getString("modifier." + mod + ".name", UtilityMethods.caseOnWords(mod.replace("-", " ")))); modifierDefaultValues.put(mod, config.getDouble("modifier." + mod + ".default-value")); } }