fixed mmocore loading issue + added expanded layout default

This commit is contained in:
Ethan 2020-09-03 00:12:06 -04:00
parent a3443485e4
commit ca93b6aa10
3 changed files with 30 additions and 11 deletions

View File

@ -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();
}

View File

@ -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"),

View File

@ -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) {
}
}
}
}