forked from Upstream/mmocore
Other plugins can register skills
This commit is contained in:
parent
1923bff73c
commit
f829d7c1be
@ -105,12 +105,12 @@ public class MMOCore extends JavaPlugin {
|
||||
public RestrictionManager restrictionManager;
|
||||
public RequestManager requestManager;
|
||||
public ConfigItemManager configItems;
|
||||
public SkillManager skillManager;
|
||||
public VaultEconomy economy;
|
||||
public HologramSupport hologramSupport;
|
||||
public InventoryManager inventoryManager;
|
||||
public RegionHandler regionHandler;
|
||||
public PlayerActionBar actionBarManager;
|
||||
public final SkillManager skillManager = new SkillManager();
|
||||
public PlaceholderParser placeholderParser = new DefaultParser();
|
||||
public DataProvider dataProvider = new YAMLDataProvider();
|
||||
public final ClassManager classManager = new ClassManager();
|
||||
@ -381,7 +381,8 @@ public class MMOCore extends JavaPlugin {
|
||||
|
||||
public void reloadPlugin() {
|
||||
configManager = new ConfigManager();
|
||||
skillManager = new SkillManager();
|
||||
|
||||
skillManager.reload();
|
||||
|
||||
mineManager.clear();
|
||||
mineManager.reload();
|
||||
|
@ -22,15 +22,21 @@ import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
||||
import net.Indyuce.mmocore.comp.mythicmobs.MythicMobSkill;
|
||||
|
||||
public class SkillManager {
|
||||
private Map<String, Skill> skills = new LinkedHashMap<>();
|
||||
private final Map<String, Skill> skills = new LinkedHashMap<>();
|
||||
|
||||
public SkillManager() {
|
||||
/*
|
||||
* skills are initialized when MMOCore enables but SkillManager must be
|
||||
* instanced when MMOCore loads so that extra plugins can register skills
|
||||
* before CLASSES are loaded
|
||||
*/
|
||||
public void reload() {
|
||||
|
||||
if (skills.isEmpty())
|
||||
try {
|
||||
JarEntry entry;
|
||||
for (Enumeration<JarEntry> en = new JarFile(MMOCore.plugin.getJarFile()).entries(); en.hasMoreElements();)
|
||||
if ((entry = en.nextElement()).getName().startsWith("net/Indyuce/mmocore/skill/") && !entry.isDirectory() && !entry.getName().contains("$"))
|
||||
if ((entry = en.nextElement()).getName().startsWith("net/Indyuce/mmocore/skill/") && !entry.isDirectory()
|
||||
&& !entry.getName().contains("$"))
|
||||
register((Skill) Class.forName(entry.getName().replace("/", ".").replace(".class", "")).newInstance());
|
||||
} catch (IOException | InstantiationException | IllegalAccessException | ClassNotFoundException exception) {
|
||||
exception.printStackTrace();
|
||||
@ -50,7 +56,8 @@ public class SkillManager {
|
||||
if (Bukkit.getPluginManager().getPlugin("MythicMobs") != null)
|
||||
for (File file : mythicMobs.listFiles()) {
|
||||
try {
|
||||
register(new MythicMobSkill(file.getName().substring(0, file.getName().length() - 4).toUpperCase(), YamlConfiguration.loadConfiguration(file)));
|
||||
register(new MythicMobSkill(file.getName().substring(0, file.getName().length() - 4).toUpperCase(),
|
||||
YamlConfiguration.loadConfiguration(file)));
|
||||
} catch (Exception exception) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load skill from " + file.getName() + ": " + exception.getMessage());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user