org.bukkit.plugin.PluginLoader Java Examples

The following examples show how to use org.bukkit.plugin.PluginLoader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RuntimePluginLoader.java    From PGM with GNU Affero General Public License v3.0 7 votes vote down vote up
@SuppressWarnings("unchecked")
public Plugin loadPlugin(PluginDescriptionFile plugin) throws UnknownDependencyException {
  final SimplePluginManager manager = (SimplePluginManager) server.getPluginManager();
  try {
    final File file = new File("plugins", plugin.getName());
    final Class[] init =
        new Class[] {
          PluginLoader.class, Server.class, PluginDescriptionFile.class, File.class, File.class
        };
    final JavaPlugin instance =
        (JavaPlugin)
            Class.forName(plugin.getMain())
                .getConstructor(init)
                .newInstance(this, server, plugin, file, file);

    readField(SimplePluginManager.class, manager, List.class, "plugins").add(instance);
    readField(SimplePluginManager.class, manager, Map.class, "lookupNames")
        .put(instance.getName().toLowerCase(), instance);

    return instance;
  } catch (Throwable t) {
    throw new UnknownDependencyException(
        t, "Unable to load plugin: " + plugin.getName() + " (" + plugin.getMain() + ")");
  }
}
 
Example #2
Source File: PGMPlugin.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
public PGMPlugin(
    PluginLoader loader,
    Server server,
    PluginDescriptionFile description,
    File dataFolder,
    File file) {
  super(loader, server, description, dataFolder, file);
}
 
Example #3
Source File: JavaPlugin.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
final void init(PluginLoader loader, Server server, PluginDescriptionFile description, File dataFolder, File file, ClassLoader classLoader) {
    this.loader = loader;
    this.server = server;
    this.file = file;
    this.description = description;
    this.dataFolder = dataFolder;
    this.classLoader = classLoader;
    this.configFile = new File(dataFolder, "config.yml");
    this.logger = new PluginLogger(this);
}
 
Example #4
Source File: InternalPlugin.java    From TabooLib with MIT License 4 votes vote down vote up
@Override
public PluginLoader getPluginLoader() {
    return InternalPluginLoader.getLoader();
}
 
Example #5
Source File: LoggedPluginManager.java    From VoxelGamesLibv2 with MIT License 4 votes vote down vote up
@Override
public void registerInterface(Class<? extends PluginLoader> loader)
        throws IllegalArgumentException {
    delegate.registerInterface(loader);
}
 
Example #6
Source File: ClassesTest.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings({"resource", "deprecation"})
	@Before
	public void before() throws Exception {
		
		final File dataDir = new File("build/resources/");
		final File jar = new File("build/", "skript.jar");
		assumeTrue(jar.exists());
		
		final Logger l = Logger.getLogger(getClass().getCanonicalName());
		l.setParent(SkriptLogger.LOGGER);
		l.setLevel(Level.WARNING);
		
		final Server s = createMock(Server.class);
		s.getLogger();
		expectLastCall().andReturn(l).anyTimes();
		s.isPrimaryThread();
		expectLastCall().andReturn(true).anyTimes();
		s.getName();
		expectLastCall().andReturn("Whatever").anyTimes();
		s.getVersion();
		expectLastCall().andReturn("2.0").anyTimes();
		s.getBukkitVersion();
		expectLastCall().andReturn("2.0").anyTimes();
		replay(s);
		
		Bukkit.setServer(s);
		
		final Skript skript = (Skript) ObjenesisHelper.newInstance(Skript.class); // bypass the class loader check
		final Field instance = Skript.class.getDeclaredField("instance");
		instance.setAccessible(true);
		instance.set(null, skript);
		
		final PluginDescriptionFile pdf = new PluginDescriptionFile(new FileInputStream(new File(dataDir, "plugin.yml")));
		
//	    final void init(PluginLoader loader, Server server, PluginDescriptionFile description, File dataFolder, File file, ClassLoader classLoader) {
		final Method init = JavaPlugin.class.getDeclaredMethod("init", PluginLoader.class, Server.class, PluginDescriptionFile.class, File.class, File.class, ClassLoader.class);
		init.setAccessible(true);
		init.invoke(skript, new JavaPluginLoader(s), s, pdf, dataDir, jar, getClass().getClassLoader());
		
		Skript.getAddonInstance().loadClasses("ch.njol.skript", "entity");
		new JavaClasses();
		new BukkitClasses();
		new BukkitEventValues();
		new SkriptClasses();
		
		final Field r = Skript.class.getDeclaredField("acceptRegistrations");
		r.setAccessible(true);
		r.set(null, false);
		Classes.onRegistrationsStop();
	}
 
Example #7
Source File: BootstrapedPlugin.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public PluginLoader getPluginLoader() {
    return delegate.getPluginLoader();
}
 
Example #8
Source File: LoggedPluginManager.java    From NovaGuilds with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void registerInterface(Class<? extends PluginLoader> loader) throws IllegalArgumentException {
	delegate.registerInterface(loader);
}
 
Example #9
Source File: JavaPlugin.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Gets the associated PluginLoader responsible for this plugin
 *
 * @return PluginLoader that controls this plugin
 */
@Override
public final PluginLoader getPluginLoader() {
    return loader;
}