Load and unload classes dynamically in your project
package de.labystudio.pluginloader;
import de.labystudio.pluginloader.plugin.Plugin;
import java.io.File;
public class DemoProject implements Core {
public DemoProject() {
// Create plugin loader
PluginLoader pluginLoader = new PluginLoader(this, new File("plugins"),
ClassLoader.getSystemClassLoader(), System.out::println);
// Load all plugins in directory
pluginLoader.loadPluginsInDirectory();
// Unload a plugin
Plugin testPlugin = pluginLoader.getPlugin("TestPlugin");
pluginLoader.unloadPlugin(testPlugin);
// Load single jar file
pluginLoader.loadPlugin(testPlugin.getJarFile());
}
}
package de.labystudio.pluginloader;
import de.labystudio.pluginloader.plugin.Plugin;
public class TestPlugin extends Plugin {
@Override
public void onEnable() {
// Enable your plugin...
}
@Override
public void onDisable() {
// Disable your plugin...
}
}
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
compile 'com.github.LabyStudio:pluginloader:1.0.3'
}