org.bukkit.plugin.java.JavaPluginLoader Java Examples
The following examples show how to use
org.bukkit.plugin.java.JavaPluginLoader.
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: CraftServer.java From Kettle with GNU General Public License v3.0 | 6 votes |
public void loadPlugins() { Transformer.init(); pluginManager.registerInterface(JavaPluginLoader.class); File pluginFolder = (File) console.options.valueOf("plugins"); if (pluginFolder.exists()) { Plugin[] plugins = pluginManager.loadPlugins(pluginFolder); for (Plugin plugin : plugins) { try { String message = String.format("Loading %s", plugin.getDescription().getFullName()); plugin.getLogger().info(message); plugin.onLoad(); } catch (Throwable ex) { Logger.getLogger(CraftServer.class.getName()).log(Level.SEVERE, ex.getMessage() + " initializing " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex); } } } else { pluginFolder.mkdir(); } }
Example #2
Source File: PerWorldInventoryInitializationTest.java From PerWorldInventory with GNU General Public License v3.0 | 6 votes |
@Before public void setUpPlugin() throws IOException { dataFolder = temporaryFolder.newFolder(); // Wire various Bukkit components setField(Bukkit.class, "server", null, server); given(server.getLogger()).willReturn(mock(Logger.class)); given(server.getScheduler()).willReturn(mock(BukkitScheduler.class)); given(server.getPluginManager()).willReturn(pluginManager); given(server.getVersion()).willReturn("1.9.4-RC1"); // SettingsManager always returns the default given(settings.getProperty(any(Property.class))).willAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { return ((Property<?>) invocation.getArguments()[0]).getDefaultValue(); } }); // PluginDescriptionFile is final and so cannot be mocked PluginDescriptionFile descriptionFile = new PluginDescriptionFile( "PerWorldInventory", "N/A", PerWorldInventory.class.getCanonicalName()); JavaPluginLoader pluginLoader = new JavaPluginLoader(server); plugin = new PerWorldInventory(pluginLoader, descriptionFile, dataFolder, null); setField(JavaPlugin.class, "logger", plugin, mock(PluginLogger.class)); }
Example #3
Source File: PerworldInventoryCommandHandlingTest.java From PerWorldInventory with GNU General Public License v3.0 | 6 votes |
@Before public void setUpPlugin() throws IOException { File dataFolder = temporaryFolder.newFolder(); // Set mock server setField(Bukkit.class, "server", null, server); given(server.getLogger()).willReturn(mock(Logger.class)); // PluginDescriptionFile is final and so cannot be mocked PluginDescriptionFile descriptionFile = new PluginDescriptionFile( "PerWorldInventory", "N/A", PerWorldInventory.class.getCanonicalName()); JavaPluginLoader pluginLoader = new JavaPluginLoader(server); plugin = new PerWorldInventory(pluginLoader, descriptionFile, dataFolder, null); setField(JavaPlugin.class, "logger", plugin, mock(PluginLogger.class)); Injector injector = new InjectorBuilder().addDefaultHandlers("me.gnat008.perworldinventory").create(); injector.register(PermissionManager.class, permissionManager); injector.register(ConvertCommand.class, convertCommand); injector.register(HelpCommand.class, helpCommand); injector.register(PerWorldInventoryCommand.class, pwiCommand); injector.register(ReloadCommand.class, reloadCommand); injector.register(SetWorldDefaultCommand.class, setWorldDefaultsCommand); injector.register(VersionCommand.class, versionCommand); plugin.registerCommands(injector); TestHelper.setField(PerWorldInventory.class, "permissionManager", plugin, permissionManager); }
Example #4
Source File: CraftServer.java From Thermos with GNU General Public License v3.0 | 6 votes |
public void loadPlugins() { pluginManager.registerInterface(JavaPluginLoader.class); File pluginFolder = (File) console.options.valueOf("plugins"); if (pluginFolder.exists()) { Plugin[] plugins = pluginManager.loadPlugins(pluginFolder); for (Plugin plugin : plugins) { try { String message = String.format("Loading %s", plugin.getDescription().getFullName()); plugin.getLogger().info(message); plugin.onLoad(); } catch (Throwable ex) { Logger.getLogger(CraftServer.class.getName()).log(Level.SEVERE, ex.getMessage() + " initializing " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex); } } } else { pluginFolder.mkdir(); } }
Example #5
Source File: PerWorldInventoryInitializationTest.java From PerWorldInventory with GNU General Public License v3.0 | 6 votes |
@Before public void setUpPlugin() throws IOException { dataFolder = temporaryFolder.newFolder(); // Wire various Bukkit components setField(Bukkit.class, "server", null, server); given(server.getLogger()).willReturn(mock(Logger.class)); given(server.getScheduler()).willReturn(mock(BukkitScheduler.class)); given(server.getPluginManager()).willReturn(pluginManager); given(server.getVersion()).willReturn("1.9.4-RC1"); // SettingsManager always returns the default given(settings.getProperty(any(Property.class))).willAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { return ((Property<?>) invocation.getArguments()[0]).getDefaultValue(); } }); // PluginDescriptionFile is final and so cannot be mocked PluginDescriptionFile descriptionFile = new PluginDescriptionFile( "PerWorldInventory", "N/A", PerWorldInventory.class.getCanonicalName()); JavaPluginLoader pluginLoader = new JavaPluginLoader(server); plugin = new PerWorldInventory(pluginLoader, descriptionFile, dataFolder, null); setField(JavaPlugin.class, "logger", plugin, mock(PluginLogger.class)); }
Example #6
Source File: PerworldInventoryCommandHandlingTest.java From PerWorldInventory with GNU General Public License v3.0 | 6 votes |
@Before public void setUpPlugin() throws IOException { File dataFolder = temporaryFolder.newFolder(); // Set mock server setField(Bukkit.class, "server", null, server); given(server.getLogger()).willReturn(mock(Logger.class)); // PluginDescriptionFile is final and so cannot be mocked PluginDescriptionFile descriptionFile = new PluginDescriptionFile( "PerWorldInventory", "N/A", PerWorldInventory.class.getCanonicalName()); JavaPluginLoader pluginLoader = new JavaPluginLoader(server); plugin = new PerWorldInventory(pluginLoader, descriptionFile, dataFolder, null); setField(JavaPlugin.class, "logger", plugin, mock(PluginLogger.class)); Injector injector = new InjectorBuilder().addDefaultHandlers("me.gnat008.perworldinventory").create(); injector.register(PermissionManager.class, permissionManager); injector.register(ConvertCommand.class, convertCommand); injector.register(HelpCommand.class, helpCommand); injector.register(PerWorldInventoryCommand.class, pwiCommand); injector.register(ReloadCommand.class, reloadCommand); injector.register(SetWorldDefaultCommand.class, setWorldDefaultsCommand); injector.register(VersionCommand.class, versionCommand); plugin.registerCommands(injector); TestHelper.setField(PerWorldInventory.class, "permissionManager", plugin, permissionManager); }
Example #7
Source File: AuthMeInitializationTest.java From AuthMeReloaded with GNU General Public License v3.0 | 6 votes |
@Before public void initAuthMe() throws IOException { dataFolder = temporaryFolder.newFolder(); File settingsFile = new File(dataFolder, "config.yml"); JavaPluginLoader pluginLoader = new JavaPluginLoader(server); Files.copy(TestHelper.getJarFile(TestHelper.PROJECT_ROOT + "config.test.yml"), settingsFile); // Mock / wire various Bukkit components given(server.getLogger()).willReturn(Logger.getAnonymousLogger()); ReflectionTestUtils.setField(Bukkit.class, null, "server", server); given(server.getPluginManager()).willReturn(pluginManager); // PluginDescriptionFile is final: need to create a sample one PluginDescriptionFile descriptionFile = new PluginDescriptionFile( "AuthMe", "N/A", AuthMe.class.getCanonicalName()); // Initialize AuthMe authMe = new AuthMe(pluginLoader, descriptionFile, dataFolder, null); }
Example #8
Source File: RuntimePluginLoader.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
public RuntimePluginLoader(Server server) { this.server = checkNotNull(server); this.loader = new JavaPluginLoader(server); }
Example #9
Source File: InternalPluginLoader.java From TabooLib with MIT License | 4 votes |
public static JavaPluginLoader getJavaLoader() { return loader; }
Example #10
Source File: ClassesTest.java From Skript with GNU General Public License v3.0 | 4 votes |
@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 #11
Source File: PerWorldInventory.java From PerWorldInventory with GNU General Public License v3.0 | 4 votes |
protected PerWorldInventory(final JavaPluginLoader loader, final PluginDescriptionFile description, final File dataFolder, final File file) { super(loader, description, dataFolder, file); }
Example #12
Source File: SlimefunPlugin.java From Slimefun4 with GNU General Public License v3.0 | 4 votes |
public SlimefunPlugin(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) { super(loader, description, dataFolder, file); minecraftVersion = MinecraftVersion.UNIT_TEST; }
Example #13
Source File: PerWorldInventory.java From PerWorldInventory with GNU General Public License v3.0 | 4 votes |
protected PerWorldInventory(final JavaPluginLoader loader, final PluginDescriptionFile description, final File dataFolder, final File file) { super(loader, description, dataFolder, file); }
Example #14
Source File: AuthMe.java From AuthMeReloaded with GNU General Public License v3.0 | 4 votes |
@VisibleForTesting AuthMe(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) { super(loader, description, dataFolder, file); }
Example #15
Source File: Main.java From EnchantmentsEnhance with GNU General Public License v3.0 | 3 votes |
/** * Mocking constructor. * * @param loader * @param description * @param dataFolder * @param file */ protected Main( JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) { super(loader, description, dataFolder, file); }