mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-15 12:13:54 -07:00
Fixed a few bugs getting sample plugin to load
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
@@ -44,9 +44,4 @@ public interface Plugin {
|
||||
* Called when this plugin is enabled
|
||||
*/
|
||||
public void onEnable();
|
||||
|
||||
/**
|
||||
* Called when this plugin is first initialized
|
||||
*/
|
||||
public void onInitialize();
|
||||
}
|
||||
|
@@ -110,7 +110,6 @@ public final class PluginManager {
|
||||
if (result != null) {
|
||||
plugins.add(result);
|
||||
lookupNames.put(result.getDescription().getName(), result);
|
||||
result.onInitialize();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@@ -27,7 +27,7 @@ public abstract class JavaPlugin implements Plugin {
|
||||
* @param plugin File containing this plugin
|
||||
* @param cLoader ClassLoader which holds this plugin
|
||||
*/
|
||||
protected JavaPlugin(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File plugin, ClassLoader cLoader) {
|
||||
public JavaPlugin(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File plugin, ClassLoader cLoader) {
|
||||
loader = pluginLoader;
|
||||
server = instance;
|
||||
file = plugin;
|
||||
|
@@ -28,7 +28,7 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
|
||||
public Plugin loadPlugin(File file) throws InvalidPluginException {
|
||||
JavaPlugin result = null;
|
||||
PluginDescriptionFile description = new PluginDescriptionFile("Sample Plugin", "org.bukkit.plugin.sample.main");
|
||||
PluginDescriptionFile description = new PluginDescriptionFile("Sample Plugin", "com.dinnerbone.bukkit.sample.SamplePlugin");
|
||||
|
||||
if (!file.exists()) {
|
||||
throw new InvalidPluginException(new FileNotFoundException(String.format("%s does not exist", file.getPath())));
|
||||
@@ -36,7 +36,7 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
|
||||
try {
|
||||
ClassLoader loader = URLClassLoader.newInstance(new URL[]{file.toURI().toURL()}, getClass().getClassLoader());
|
||||
Class<?> jarClass = Class.forName(description.getMain());
|
||||
Class<?> jarClass = Class.forName(description.getMain(), true, loader);
|
||||
Class<? extends JavaPlugin> plugin = jarClass.asSubclass(JavaPlugin.class);
|
||||
Constructor<? extends JavaPlugin> constructor = plugin.getConstructor(PluginLoader.class, Server.class, PluginDescriptionFile.class, File.class, ClassLoader.class);
|
||||
|
||||
|
Reference in New Issue
Block a user