Java 类org.bukkit.plugin.java.JavaPluginLoader 实例源码

项目:Uranium    文件:CraftServer.java   
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();
    }
}
项目:netherrack    文件:NetherServer.java   
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();
       }
}
项目:ThermosRebased    文件:CraftServer.java   
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();
    }
}
项目:Thermos    文件:CraftServer.java   
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();
    }
}
项目:KCauldron    文件:CraftServer.java   
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();
    }
}
项目:CauldronGit    文件:CraftServer.java   
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();
    }
}
项目:CanaryBukkit    文件:CanaryServer.java   
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);
        }
    }
}
项目:Cauldron-Old    文件:CraftServer.java   
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();
    }
}
项目:DiffUtils    文件:CraftServer_188.java   
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();
    }
}
项目:DiffUtils    文件:CraftServer_1710.java   
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();
    }
}
项目:Cauldron-Reloaded    文件:CraftServer.java   
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();
    }
}
项目:PerWorldInventory    文件:PerWorldInventoryInitializationTest.java   
@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));
}
项目:PerWorldInventory    文件:PerworldInventoryCommandHandlingTest.java   
@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);
}
项目:FFoKC    文件:CraftServer.java   
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();
    }
}
项目:CraftBukkit    文件:CraftServer.java   
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();
    }
}
项目:Craftbukkit    文件:CraftServer.java   
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();
    }
}
项目:pploader    文件:ReflectionHelper.java   
/**
 * 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;
    }
}
项目:Almura-Server    文件:CraftServer.java   
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();
    }
}
项目:Tweakkit-Server    文件:CraftServer.java   
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();
    }
}
项目:PerWorldInventory    文件:PerWorldInventoryInitializationTest.java   
@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));
}
项目:PerWorldInventory    文件:PerworldInventoryCommandHandlingTest.java   
@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);
}
项目:Cauldron    文件:CraftServer.java   
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();
    }
}
项目:Junket    文件:ServerImpl.java   
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);
    }
}
项目:Pore    文件:PoreServer.java   
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);
        }
    }
}
项目:SpigotSource    文件:CraftServer.java   
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();
    }
}
项目:AuthMeReloaded    文件:AuthMeInitializationTest.java   
@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);
}
项目:Craft-city    文件:CraftServer.java   
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();
    }
}
项目:MCPBukkit    文件:CraftServer.java   
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();
    }
}
项目:prisonPicks    文件:PickCommandsTest.java   
@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);

}
项目:SpongeBukkit    文件:BukkitServer.java   
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);
}
项目:NucleusFramework    文件:BukkitPlugin.java   
/**
 * Constructor for testing.
*/
protected BukkitPlugin(JavaPluginLoader loader, PluginDescriptionFile description,
                       File dataFolder, File file) {
    super(loader, description, dataFolder, file);

    Nucleus._plugin = this;
}
项目:NucleusFramework    文件:NucleusPlugin.java   
/**
 * 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);
    }
}
项目:MockBukkit    文件:MockPlugin.java   
protected MockPlugin(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file)
{
    super(loader, description, dataFolder, file);
}
项目:MockBukkit    文件:PluginManagerMock.java   
@SuppressWarnings("deprecation")
public PluginManagerMock(ServerMock server)
{
    this.server = server;
    loader = new JavaPluginLoader(this.server);
}
项目:MockBukkit    文件:TestPlugin.java   
protected TestPlugin(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file)
{
    super(loader, description, dataFolder, file);
}
项目:Skript    文件:ClassesTest.java   
@SuppressWarnings({"resource", "deprecation"})
    @Before
    public void before() throws Exception {

        final File dataDir = new File("target/classes/");
        final File jar = new File("target/", "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();
    }
项目:ExilePearl    文件:ExilePearlPlugin.java   
protected ExilePearlPlugin(final JavaPluginLoader loader, final PluginDescriptionFile description, final File dataFolder, final File file) {
    super(loader, description, dataFolder, file);
core = CorePluginFactory.createCore(this);
  }
项目:PerWorldInventory    文件:PerWorldInventory.java   
protected PerWorldInventory(final JavaPluginLoader loader, final PluginDescriptionFile description,
                            final File dataFolder, final File file) {
    super(loader, description, dataFolder, file);
}
项目:PerWorldInventory    文件:PerWorldInventory.java   
protected PerWorldInventory(final JavaPluginLoader loader, final PluginDescriptionFile description,
                            final File dataFolder, final File file) {
    super(loader, description, dataFolder, file);
}
项目:BedrockAPI    文件:JavaPlugin.java   
protected JavaPlugin(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) {
}