diff --git a/paper-api/.gitignore b/paper-api/.gitignore index 863c54ba7c..9ba47d064d 100644 --- a/paper-api/.gitignore +++ b/paper-api/.gitignore @@ -3,4 +3,9 @@ /nbproject /build.xml /manifest.mf -/dist \ No newline at end of file +/dist +/sample/test +/sample/build.xml +/sample/build +/sample/dist +/sample/nbproject \ No newline at end of file diff --git a/paper-api/sample/src/com/dinnerbone/bukkit/sample/SamplePlugin.java b/paper-api/sample/src/com/dinnerbone/bukkit/sample/SamplePlugin.java new file mode 100644 index 0000000000..8f5445d445 --- /dev/null +++ b/paper-api/sample/src/com/dinnerbone/bukkit/sample/SamplePlugin.java @@ -0,0 +1,28 @@ + +package com.dinnerbone.bukkit.sample; + +import java.io.File; +import org.bukkit.Server; +import org.bukkit.plugin.PluginDescriptionFile; +import org.bukkit.plugin.PluginLoader; +import org.bukkit.plugin.java.JavaPlugin; + +/** + * Sample plugin for Bukkit + * + * @author Dinnerbone + */ +public class SamplePlugin extends JavaPlugin { + public SamplePlugin(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File plugin, ClassLoader cLoader) { + super(pluginLoader, instance, desc, plugin, cLoader); + System.out.println("Johnny five is alive!"); + } + + public void onDisable() { + System.out.println("Goodbye world!"); + } + + public void onEnable() { + System.out.println("Hello world!"); + } +} diff --git a/paper-api/src/org/bukkit/plugin/Plugin.java b/paper-api/src/org/bukkit/plugin/Plugin.java index a097945107..e9097cdbde 100644 --- a/paper-api/src/org/bukkit/plugin/Plugin.java +++ b/paper-api/src/org/bukkit/plugin/Plugin.java @@ -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(); } diff --git a/paper-api/src/org/bukkit/plugin/PluginManager.java b/paper-api/src/org/bukkit/plugin/PluginManager.java index 7a3997969a..d35d91df13 100644 --- a/paper-api/src/org/bukkit/plugin/PluginManager.java +++ b/paper-api/src/org/bukkit/plugin/PluginManager.java @@ -110,7 +110,6 @@ public final class PluginManager { if (result != null) { plugins.add(result); lookupNames.put(result.getDescription().getName(), result); - result.onInitialize(); } return result; diff --git a/paper-api/src/org/bukkit/plugin/java/JavaPlugin.java b/paper-api/src/org/bukkit/plugin/java/JavaPlugin.java index 1b8dd2f59b..e2fa61c14e 100644 --- a/paper-api/src/org/bukkit/plugin/java/JavaPlugin.java +++ b/paper-api/src/org/bukkit/plugin/java/JavaPlugin.java @@ -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; diff --git a/paper-api/src/org/bukkit/plugin/java/JavaPluginLoader.java b/paper-api/src/org/bukkit/plugin/java/JavaPluginLoader.java index bd6d0f86e0..3eb517fffd 100644 --- a/paper-api/src/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/paper-api/src/org/bukkit/plugin/java/JavaPluginLoader.java @@ -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 plugin = jarClass.asSubclass(JavaPlugin.class); Constructor constructor = plugin.getConstructor(PluginLoader.class, Server.class, PluginDescriptionFile.class, File.class, ClassLoader.class);