当前位置: 首页>>代码示例>>Java>>正文


Java JavaPluginLoader类代码示例

本文整理汇总了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();
    }
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:21,代码来源:CraftServer.java

示例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();
       }
}
 
开发者ID:netherrack,项目名称:netherrack,代码行数:21,代码来源:NetherServer.java

示例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);
        }
    }
}
 
开发者ID:CanaryBukkitTeam,项目名称:CanaryBukkit,代码行数:21,代码来源:CanaryServer.java

示例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));
}
 
开发者ID:Gnat008,项目名称:PerWorldInventory,代码行数:27,代码来源:PerWorldInventoryInitializationTest.java

示例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);
}
 
开发者ID:Gnat008,项目名称:PerWorldInventory,代码行数:27,代码来源:PerworldInventoryCommandHandlingTest.java

示例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;
    }
}
 
开发者ID:cyberlis,项目名称:pploader,代码行数:26,代码来源:ReflectionHelper.java

示例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);
    }
}
 
开发者ID:deathcap,项目名称:Junket,代码行数:21,代码来源:ServerImpl.java

示例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);
        }
    }
}
 
开发者ID:LapisBlue,项目名称:Pore,代码行数:24,代码来源:PoreServer.java

示例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);
}
 
开发者ID:AuthMe,项目名称:AuthMeReloaded,代码行数:20,代码来源:AuthMeInitializationTest.java

示例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);

}
 
开发者ID:ThePhilderbeast,项目名称:prisonPicks,代码行数:31,代码来源:PickCommandsTest.java

示例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);
}
 
开发者ID:SpongeBukkit,项目名称:SpongeBukkit,代码行数:9,代码来源:BukkitServer.java

示例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;
}
 
开发者ID:JCThePants,项目名称:NucleusFramework,代码行数:10,代码来源:BukkitPlugin.java

示例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);
    }
}
 
开发者ID:JCThePants,项目名称:NucleusFramework,代码行数:17,代码来源:NucleusPlugin.java

示例14: MockPlugin

import org.bukkit.plugin.java.JavaPluginLoader; //导入依赖的package包/类
protected MockPlugin(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file)
{
	super(loader, description, dataFolder, file);
}
 
开发者ID:seeseemelk,项目名称:MockBukkit,代码行数:5,代码来源:MockPlugin.java

示例15: PluginManagerMock

import org.bukkit.plugin.java.JavaPluginLoader; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public PluginManagerMock(ServerMock server)
{
	this.server = server;
	loader = new JavaPluginLoader(this.server);
}
 
开发者ID:seeseemelk,项目名称:MockBukkit,代码行数:7,代码来源:PluginManagerMock.java


注:本文中的org.bukkit.plugin.java.JavaPluginLoader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。