diff --git a/src/main/java/net/Indyuce/mmoitems/comp/mmocore/MMOCoreHook.java b/src/main/java/net/Indyuce/mmoitems/comp/mmocore/MMOCoreHook.java index b15e2531..0c5206be 100644 --- a/src/main/java/net/Indyuce/mmoitems/comp/mmocore/MMOCoreHook.java +++ b/src/main/java/net/Indyuce/mmoitems/comp/mmocore/MMOCoreHook.java @@ -35,8 +35,10 @@ public class MMOCoreHook implements RPGHandler, Listener { MMOItems.plugin.getStats().register("COOLDOWN_REDUCTION", new DoubleStat(new ItemStack(Material.BOOK), "Skill Cooldown Reduction", new String[] { "(%) Reduces cooldowns of MMOCore skills." }, "skill-cooldown-reduction")); MMOItems.plugin.getStats().register("ADDITIONAL_EXPERIENCE", new DoubleStat(new ItemStack(Material.EXPERIENCE_BOTTLE), "Additional Experience", new String[] { "Additional % MMOCore main class experience." }, "additional-experience")); - for (DamageType type : DamageType.values()) - MMOItems.plugin.getStats().register(type.name() + "_DAMAGE", new DoubleStat(new ItemStack(Material.GRAY_DYE), MMOUtils.caseOnWords(type.name().toLowerCase().replace("_", " ")) + " Damage (MMOCore)", new String[] { "Additional % MMOCore main class experience." }, "additional-experience")); + for (DamageType type : DamageType.values()) { + String name = MMOUtils.caseOnWords(type.name().toLowerCase()); + MMOItems.plugin.getStats().register(type.name() + "_DAMAGE", new DoubleStat(new ItemStack(Material.IRON_SWORD), name + " Damage (MMOCore)", new String[] { "Additional " + name + " damage." }, type.getPath() + "-damage")); + } } @Override diff --git a/src/main/java/net/Indyuce/mmoitems/manager/StatManager.java b/src/main/java/net/Indyuce/mmoitems/manager/StatManager.java index 14a76fdf..743fba9a 100644 --- a/src/main/java/net/Indyuce/mmoitems/manager/StatManager.java +++ b/src/main/java/net/Indyuce/mmoitems/manager/StatManager.java @@ -16,9 +16,9 @@ import net.Indyuce.mmoitems.stat.type.DoubleStat; import net.Indyuce.mmoitems.stat.type.ItemStat; public class StatManager { - private Map stats = new LinkedHashMap<>(); - private Set gem = new HashSet<>(); - private Set attribute = new HashSet<>(); + private final Map stats = new LinkedHashMap<>(); + private final Set gem = new HashSet<>(); + private final Set attribute = new HashSet<>(); /* * load default stats using java reflection, get all public static final @@ -65,6 +65,15 @@ public class StatManager { if (stat instanceof AttributeStat) attribute.add((AttributeStat) stat); + + /* + * cache stat for every type which may have this stat. really important + * otherwise the stat will NOT be used anywhere in the plugin. + */ + if (MMOItems.plugin.getTypes() != null) + for (Type type : MMOItems.plugin.getTypes().getAll()) + if (type.canHave(stat)) + type.getAvailableStats().add(stat); } public ItemStat get(String str) { @@ -72,6 +81,6 @@ public class StatManager { } private boolean isGemStoneStat(ItemStat stat) { - return Type.GEM_STONE.canHaveStat(stat) && stat != ItemStat.REQUIRED_LEVEL && stat != ItemStat.CUSTOM_MODEL_DATA && stat != ItemStat.DURABILITY && stat != ItemStat.MAX_CUSTOM_DURABILITY && stat != ItemStat.SUCCESS_RATE && stat instanceof DoubleStat; + return Type.GEM_STONE.canHave(stat) && stat != ItemStat.REQUIRED_LEVEL && stat != ItemStat.CUSTOM_MODEL_DATA && stat != ItemStat.DURABILITY && stat != ItemStat.MAX_CUSTOM_DURABILITY && stat != ItemStat.SUCCESS_RATE && stat instanceof DoubleStat; } } diff --git a/src/main/java/net/Indyuce/mmoitems/manager/TypeManager.java b/src/main/java/net/Indyuce/mmoitems/manager/TypeManager.java index e671c4ea..acdea898 100644 --- a/src/main/java/net/Indyuce/mmoitems/manager/TypeManager.java +++ b/src/main/java/net/Indyuce/mmoitems/manager/TypeManager.java @@ -63,7 +63,7 @@ public class TypeManager { * both item generation (and GUI) calculations. probably the thing * which takes the most time when loading item types. */ - type.cacheAvailableStats(MMOItems.plugin.getStats().getAll().stream().filter(stat -> type.canHaveStat(stat)).collect(Collectors.toList())); + type.cacheAvailableStats(MMOItems.plugin.getStats().getAll().stream().filter(stat -> type.canHave(stat)).collect(Collectors.toList())); } }