本文整理汇总了Java中org.bukkit.plugin.java.JavaPluginLoader类的典型用法代码示例。如果您正苦于以下问题:Java JavaPluginLoader类的具体用法?Java JavaPluginLoader怎么用?Java JavaPluginLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JavaPluginLoader类属于org.bukkit.plugin.java包,在下文中一共展示了JavaPluginLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadPlugins
import org.bukkit.plugin.java.JavaPluginLoader; //导入依赖的package包/类
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();
}
}
示例2: loadPlugins
import org.bukkit.plugin.java.JavaPluginLoader; //导入依赖的package包/类
public void loadPlugins() {
pluginManager.registerInterface(JavaPluginLoader.class);
File pluginFolder = new File("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(NetherServer.class.getName()).log(Level.SEVERE, ex.getMessage() + " initializing " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
}
}
} else {
pluginFolder.mkdir();
}
}
示例3: loadPlugins
import org.bukkit.plugin.java.JavaPluginLoader; //导入依赖的package包/类
public void loadPlugins() {
// Clear the command map
commandMap.clearCommands();
// Clear plugins and prepare to load
pluginManager.clearPlugins();
pluginManager.registerInterface(JavaPluginLoader.class);
// Call onLoad methods
for (Plugin plugin : pluginManager.loadPlugins(Constants.pluginsDir)) {
try {
getLogger().info(String.format("Loading %s", plugin.getDescription().getFullName()));
plugin.onLoad();
} catch (Exception ex) {
getLogger().log(Level.SEVERE,
ex.getMessage() + " initializing " + plugin.getDescription().getFullName() +
" (Is it up to date?)", ex);
}
}
}
示例4: setUpPlugin
import org.bukkit.plugin.java.JavaPluginLoader; //导入依赖的package包/类
@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));
}
示例5: setUpPlugin
import org.bukkit.plugin.java.JavaPluginLoader; //导入依赖的package包/类
@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);
}
示例6: getJavaLoaders
import org.bukkit.plugin.java.JavaPluginLoader; //导入依赖的package包/类
/**
* Retrieve loaders field from JavaPluginLoader instance
* @param pm plugin manager to search for JavaPluginLoader in (if necessary)
* @return loaders field retrieved
*/
@SuppressWarnings("unchecked")
public static Map<String, ?> getJavaLoaders(PluginManager pm) {
if (javaLoaders != null)
return javaLoaders;
getJavaPluginLoader(pm);
if (javapluginloader == null)
return null;
try {
Field fieldLoaders = JavaPluginLoader.class.getDeclaredField("loaders");
fieldLoaders.setAccessible(true);
javaLoaders = (Map<String, ?>) fieldLoaders.get(javapluginloader);
return javaLoaders;
} catch (Throwable t) {
t.printStackTrace();
return null;
}
}
示例7: loadPlugins
import org.bukkit.plugin.java.JavaPluginLoader; //导入依赖的package包/类
private void loadPlugins() {
File pluginsDir = new File("plugins");
if (!pluginsDir.isDirectory()) {
getLogger().info("Creating plugins directory");
if (!pluginsDir.mkdir()) {
getLogger().severe("Failed to create plugins directory");
System.exit(-1);
}
}
pluginManager.registerInterface(JavaPluginLoader.class);
logger.info("Loading plugins...");
pluginManager.loadPlugins(pluginsDir);
getLogger().info("Loaded "+pluginManager.getPlugins().length+" plugins");
for (Plugin plugin : pluginManager.getPlugins()) {
getLogger().info("Enabling plugin " + plugin);
pluginManager.enablePlugin(plugin);
}
}
示例8: loadPlugins
import org.bukkit.plugin.java.JavaPluginLoader; //导入依赖的package包/类
public void loadPlugins() {
if (pluginsDir.isDirectory()) {
// Clear plugins and prepare to load
pluginManager.clearPlugins();
pluginManager.registerInterface(JavaPluginLoader.class);
// Call onLoad methods
for (Plugin plugin : pluginManager.loadPlugins(pluginsDir)) {
try {
getLogger().info(String.format("Loading %s", plugin.getDescription().getFullName()));
plugin.onLoad();
} catch (RuntimeException ex) {
getLogger().log(Level.SEVERE,
ex.getMessage() + " initializing " + plugin.getDescription().getFullName()
+ " (Is it up to date?)", ex);
}
}
} else {
if (!pluginsDir.mkdir()) {
logger.log(Level.SEVERE, "Could not create plugins directory: " + pluginsDir);
}
}
}
示例9: initAuthMe
import org.bukkit.plugin.java.JavaPluginLoader; //导入依赖的package包/类
@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);
}
示例10: setUp
import org.bukkit.plugin.java.JavaPluginLoader; //导入依赖的package包/类
@Before
public void setUp()
{
MockitoAnnotations.initMocks(this);
// Initialize the Mock server.
JavaPluginLoader mockPluginLoader = new JavaPluginLoader(mockServer);
Whitebox.setInternalState(mockPluginLoader, "server", mockServer);
when(mockServer.getName()).thenReturn("TestBukkit");
Logger.getLogger("Minecraft").setParent(TestUtil.logger);
when(mockServer.getLogger()).thenReturn(TestUtil.logger);
// Return a fake PDF file.
PluginDescriptionFile pdf = PowerMockito.spy(new PluginDescriptionFile("PrisonPicks", "1.3.4-Test",
"com.philderbeast.prisonpicks.PrisonPicks"));
when(pdf.getAuthors()).thenReturn(new ArrayList<String>());
pickCommands = new PickCommands();
// MOCKS BELOW HERE
when(player.getUniqueId()).thenReturn(UUID.fromString("e3078d5d-8943-420c-8366-4aa51e212df3"));
when(player.getInventory()).thenReturn(playerInventory);
PowerMockito.mockStatic(Bukkit.class);
when(Bukkit.getPlayer(anyString())).thenReturn(player);
when(Bukkit.getItemFactory()).thenReturn(itemFactory);
when(itemFactory.getItemMeta(Material.DIAMOND_PICKAXE)).thenReturn(itemMeta);
}
示例11: BukkitServer
import org.bukkit.plugin.java.JavaPluginLoader; //导入依赖的package包/类
public BukkitServer(SpongeBukkitMod mod, MinecraftServer server)
{
this.mod = Preconditions.checkNotNull(mod);
this.server = Preconditions.checkNotNull(server);
this.commandMap = new BukkitCommandMap(this);
this.pluginManager = new SimplePluginManager(this,this.commandMap);
this.pluginManager.registerInterface(JavaPluginLoader.class);
}
示例12: BukkitPlugin
import org.bukkit.plugin.java.JavaPluginLoader; //导入依赖的package包/类
/**
* Constructor for testing.
*/
protected BukkitPlugin(JavaPluginLoader loader, PluginDescriptionFile description,
File dataFolder, File file) {
super(loader, description, dataFolder, file);
Nucleus._plugin = this;
}
示例13: NucleusPlugin
import org.bukkit.plugin.java.JavaPluginLoader; //导入依赖的package包/类
/**
* Constructor for testing.
*/
protected NucleusPlugin(JavaPluginLoader loader, PluginDescriptionFile description,
File dataFolder, File file) {
super(loader, description, dataFolder, file);
_isTesting = true;
try {
onInit();
}
catch (Throwable e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
示例14: MockPlugin
import org.bukkit.plugin.java.JavaPluginLoader; //导入依赖的package包/类
protected MockPlugin(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file)
{
super(loader, description, dataFolder, file);
}
示例15: PluginManagerMock
import org.bukkit.plugin.java.JavaPluginLoader; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public PluginManagerMock(ServerMock server)
{
this.server = server;
loader = new JavaPluginLoader(this.server);
}