use of io.xol.chunkstories.content.mods.ModsManagerImplementation in project chunkstories by Hugobros3.
the class DefaultPluginManager method reloadPlugins.
@Override
public /**
* Implementation : Checks %gamedir%/plugins/ folder, loads what it can within, checks enabled mods and their plugins/ folder, enables what it can
*/
void reloadPlugins() {
// First disable any leftover plugins
disablePlugins();
// We make a list
LinkedList<PluginInformationImplementation> pluginsToLoad = new LinkedList<PluginInformationImplementation>();
// Creates plugins folder if it isn't present.
File pluginsFolder = new File(GameDirectory.getGameFolderPath() + "/plugins/");
pluginsFolder.mkdirs();
// Iterates over files of the folder
for (File file : pluginsFolder.listFiles()) {
if (file.getName().endsWith(".jar")) {
try {
PluginInformationImplementation pluginInformation = new PluginInformationImplementation(file, ((ModsManagerImplementation) pluginExecutionContext.getContent().modsManager()).getFinalClassLoader());
// Client only plugins require actually being a client
if (pluginInformation.getPluginType() == PluginType.CLIENT_ONLY && !(this instanceof ClientPluginManager))
continue;
else // Server only plugins require the same
if (pluginInformation.getPluginType() == PluginType.MASTER && !(this instanceof ServerPluginManager))
continue;
pluginsToLoad.add(pluginInformation);
} catch (PluginLoadException | IOException e) {
logger().error("Failed to load plugin file " + file + e.getMessage());
e.printStackTrace();
}
}
}
// Mods too can bundle plugins
for (PluginInformationImplementation pluginInformation : ((ModsManagerImplementation) this.pluginExecutionContext.getContent().modsManager()).getAllModsPlugins()) {
// Client only plugins require actually being a client
if (pluginInformation.getPluginType() == PluginType.CLIENT_ONLY && !(this instanceof ClientPluginManager))
continue;
else // Server only plugins require the same
if (pluginInformation.getPluginType() == PluginType.MASTER && !(this instanceof ServerPluginManager))
continue;
pluginsToLoad.add(pluginInformation);
}
// Enables the found plugins
enablePlugins(pluginsToLoad);
}
use of io.xol.chunkstories.content.mods.ModsManagerImplementation in project chunkstories by Hugobros3.
the class ModsManagerTest method testModsManager.
@Test
public void testModsManager() {
String coreContentLocation = System.getProperty("coreContentLocation", "../chunkstories-core/build/distributions/core_content.zip");
try {
ModsManager modsManager = new ModsManagerImplementation(new File(coreContentLocation));
modsManager.loadEnabledMods();
} catch (NonExistentCoreContent e) {
e.printStackTrace();
fail();
} catch (NotAllModsLoadedException e) {
e.printStackTrace();
}
}
Aggregations