diff --git a/src/main/java/net/Indyuce/mmoitems/MMOItems.java b/src/main/java/net/Indyuce/mmoitems/MMOItems.java index 2ad6dff1..1691be9d 100644 --- a/src/main/java/net/Indyuce/mmoitems/MMOItems.java +++ b/src/main/java/net/Indyuce/mmoitems/MMOItems.java @@ -111,6 +111,8 @@ public class MMOItems extends JavaPlugin { typeManager.reload(); + templateManager.loadCompatibility(); // explained why here in method + if (Bukkit.getPluginManager().getPlugin("MMOCore") != null) new MMOCoreMMOLoader(); } diff --git a/src/main/java/net/Indyuce/mmoitems/manager/ConfigManager.java b/src/main/java/net/Indyuce/mmoitems/manager/ConfigManager.java index 0efc1ddc..d5d3e6c3 100644 --- a/src/main/java/net/Indyuce/mmoitems/manager/ConfigManager.java +++ b/src/main/java/net/Indyuce/mmoitems/manager/ConfigManager.java @@ -281,6 +281,7 @@ public class ConfigManager { // station layouts DEFAULT_LAYOUT("layouts/default.yml", "layouts", "default.yml"), + EXPANDED_LAYOUT("layouts/expanded.yml", "layouts", "expanded.yml"), // default item config files -> /MMOItems/item ARMOR("item/armor.yml", "item", "armor.yml"), diff --git a/src/main/java/net/Indyuce/mmoitems/manager/TemplateManager.java b/src/main/java/net/Indyuce/mmoitems/manager/TemplateManager.java index 3523e29e..d2c20b0a 100644 --- a/src/main/java/net/Indyuce/mmoitems/manager/TemplateManager.java +++ b/src/main/java/net/Indyuce/mmoitems/manager/TemplateManager.java @@ -1,16 +1,5 @@ package net.Indyuce.mmoitems.manager; -import java.io.File; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Random; -import java.util.logging.Level; - -import org.apache.commons.lang.Validate; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; - import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.ConfigFile; import net.Indyuce.mmoitems.api.ItemTier; @@ -18,6 +7,16 @@ import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate; import net.Indyuce.mmoitems.api.item.template.TemplateModifier; import net.Indyuce.mmoitems.api.util.TemplateMap; +import org.apache.commons.lang.Validate; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.File; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Random; +import java.util.logging.Level; public class TemplateManager { @@ -212,4 +211,21 @@ public class TemplateManager { } } } + // this loads dummy items for on load so + // plugins that enable before mmoitems that use + // items (mmocore) don't error out and need + // a reload + public void loadCompatibility() { + templates.clear(); + + for (Type type : MMOItems.plugin.getTypes().getAll()) { + FileConfiguration config = type.getConfigFile().getConfig(); + for (String key : config.getKeys(false)) + try { + registerTemplate(new MMOItemTemplate(type, key)); + } catch (IllegalArgumentException ignored) { + + } + } + } }