diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/CMIMaterial.java b/src/main/java/com/gamingmesh/jobs/CMILib/CMIMaterial.java index 7a605373..8bfcfc6e 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/CMIMaterial.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/CMIMaterial.java @@ -1419,9 +1419,7 @@ public enum CMIMaterial { public static CMIMaterial get(int id) { for (CMIMaterial one : CMIMaterial.values()) { - if (one.getMaterial() == null) - continue; - if (one.getId() == id) { + if (one.getMaterial() != null && one.getId() == id) { return one; } } diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java index 151ec970..a67276d2 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java @@ -28,9 +28,8 @@ public class ItemManager { static { for (CMIMaterial one : CMIMaterial.values()) { - if (one == null) - continue; one.updateMaterial(); + Material mat = one.getMaterial(); if (mat == null) { continue; @@ -48,8 +47,11 @@ public class ItemManager { } catch (Exception e) { e.printStackTrace(); } - mojangName = mojangName == null ? mat.toString().replace("_", "").replace(" ", "").toLowerCase() - : mojangName.replace("_", "").replace(" ", "").toLowerCase(); + if (mojangName == null) { + mojangName = mat.toString(); + } + + mojangName = mojangName.replace("_", "").replace(" ", "").toLowerCase(); if (one.isCanHavePotionType()) { for (Potion p : Potion.values()) { diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index d0a8fa50..5464ffe9 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -557,20 +557,26 @@ public class Jobs extends JavaPlugin { boolean found = false; - t: for (JobProgression prog : jPlayer.getJobProgression()) { + for (JobProgression prog : jPlayer.getJobProgression()) { for (JobInfo info : jPlayer.getJobProgression(prog.getJob()).getJob().getJobInfo(type)) { if (info.getActionType() == type) { found = true; - break t; + break; } } - for (Quest q : prog.getJob().getQuests()) { - if (q != null && q.hasAction(type)) { - found = true; - break t; + if (!found) { + for (Quest q : prog.getJob().getQuests()) { + if (q != null && q.hasAction(type)) { + found = true; + break; + } } } + + if (found) { + break; + } } return found; diff --git a/src/main/java/com/gamingmesh/jobs/PermissionManager.java b/src/main/java/com/gamingmesh/jobs/PermissionManager.java index b5e918bc..68231121 100644 --- a/src/main/java/com/gamingmesh/jobs/PermissionManager.java +++ b/src/main/java/com/gamingmesh/jobs/PermissionManager.java @@ -149,7 +149,7 @@ public class PermissionManager { double temp = Double.parseDouble(permission.getKey().replace(perm, "")); if (cumulative) amount += temp; - else if (amount == 0D || allowMinus || temp > amount) + else if (allowMinus || temp > amount) amount = temp; } catch (NumberFormatException ignored) { // Should be ignored diff --git a/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java b/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java index aaa08877..752f00db 100644 --- a/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java @@ -4,8 +4,10 @@ import java.io.File; import java.util.*; import java.util.stream.Collectors; +import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.EntityType; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.CMILib.CMIEnchantment; @@ -289,16 +291,16 @@ public class NameTranslatorManager { ConfigReader c = new ConfigReader(f); c.copyDefaults(true); - for (CMIMaterial one : CMIMaterial.values()) { - if (one.getMaterial() == null) + for (Material one : Material.values()) { + CMIMaterial mat = CMIMaterial.get(one); + if (mat == null || mat.getMaterial() == null) continue; - String n = one.getLegacyId() + (one.getLegacyData() == -1 ? "" : ":" + one.getLegacyData()); - + String n = mat.getLegacyId() + (mat.getLegacyData() == -1 ? "" : ":" + mat.getLegacyData()); String name = null; - if (c.getC().isString("ItemList." + one.toString())) { - name = c.getC().getString("ItemList." + one.toString()); + if (c.getC().isString("ItemList." + mat.toString())) { + name = c.getC().getString("ItemList." + mat.toString()); } if (name == null && c.getC().isConfigurationSection("ItemList." + n)) { @@ -306,59 +308,60 @@ public class NameTranslatorManager { } if (name == null) { - n = one.getLegacyId() + ":" + one.getLegacyData(); + n = mat.getLegacyId() + ":" + mat.getLegacyData(); if (c.getC().isConfigurationSection("ItemList." + n)) { name = c.getC().getString("ItemList." + n + ".Name"); } } if (name == null) { - n = String.valueOf(one.getLegacyId()); + n = String.valueOf(mat.getLegacyId()); if (c.getC().isConfigurationSection("ItemList." + n)) { name = c.getC().getString("ItemList." + n + ".Name"); } } if (name == null) { - n = String.valueOf(one.getId()); + n = String.valueOf(mat.getId()); if (c.getC().isConfigurationSection("ItemList." + n)) { name = c.getC().getString("ItemList." + n + ".Name"); } } if (name == null) { - n = one.getLegacyId() + ":" + one.getLegacyData() + "-" + one.getBukkitName(); + n = mat.getLegacyId() + ":" + mat.getLegacyData() + "-" + mat.getBukkitName(); if (c.getC().isString("ItemList." + n)) { name = c.getC().getString("ItemList." + n); } } if (name == null) { - n = String.valueOf(one.getLegacyId()) + "-" + one.getBukkitName(); + n = String.valueOf(mat.getLegacyId()) + "-" + mat.getBukkitName(); if (c.getC().isString("ItemList." + n)) { name = c.getC().getString("ItemList." + n); } } if (name == null) { - n = String.valueOf(one.getId()) + "-" + one.getBukkitName(); + n = String.valueOf(mat.getId()) + "-" + mat.getBukkitName(); if (c.getC().isString("ItemList." + n)) { name = c.getC().getString("ItemList." + n); } } if (name == null) { - name = one.getName(); + name = mat.getName(); } - c.get("ItemList." + one.toString(), name); + c.get("ItemList." + mat.toString(), name); } - for (CMIEntityType one : CMIEntityType.values()) { - if (!one.isAlive()) + for (EntityType one : EntityType.values()) { + CMIEntityType ent = CMIEntityType.getByType(one); + if (ent == null || !ent.isAlive()) continue; - String n = String.valueOf(one.getId()); + String n = String.valueOf(ent.getId()); String name = null; @@ -367,17 +370,17 @@ public class NameTranslatorManager { } if (name == null) { - n += "-" + one.toString(); + n += "-" + ent.toString(); if (c.getC().isConfigurationSection("EntityList." + n)) { name = c.getC().getString("EntityList." + n); } } if (name == null) { - name = one.getName(); + name = ent.getName(); } - c.get("EntityList." + one.getId() + "-" + one.toString(), name); + c.get("EntityList." + ent.getId() + "-" + ent.toString(), name); } for (Enchantment one : Enchantment.values()) {