Created
June 30, 2013 04:36
-
-
Save greatman/5893870 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JarFile jarFile = new JarFile(file); | |
//We load the basic game Plugin configuration | |
ZipEntry configFile = jarFile.getEntry("gameplugin.yml"); | |
//Does the config file exists? | |
if (configFile != null) { | |
YamlConfiguration gamePlugin = YamlConfiguration.loadConfiguration(jarFile.getInputStream(configFile)); | |
//Is the configuration a valid one? | |
if (!gamePlugin.contains("main-class") || !gamePlugin.contains("name")) { | |
ultimateGames.getMessageManager().log(Level.SEVERE, "Game " + file.getAbsolutePath() + " contains a invalid gameplugin.yml file!"); | |
jarFile.close(); | |
continue; | |
} | |
//We try to laod the main class.. | |
pluginClassLoader.addUrl(file.toURI().toURL()); | |
Class<?> clazz = pluginClassLoader.loadClass(gamePlugin.getString("main-class")); | |
//Is the class a valid game plugin? | |
if (GamePlugin.class.isAssignableFrom(clazz)) { | |
ultimateGames.getMessageManager().log(Level.INFO, "Loading " + gamePlugin.getString("name")); | |
GamePlugin plugin = (GamePlugin) clazz.newInstance(); | |
} else { | |
ultimateGames.getMessageManager().log(Level.SEVERE, "Game " + gamePlugin.getString("name") + " got a invalid main class!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment