Java 类org.bukkit.event.server.PluginEnableEvent 实例源码

项目:Thermos-Bukkit    文件:JavaPluginLoader.java   
public void enablePlugin(final Plugin plugin) {
    Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");

    if (!plugin.isEnabled()) {
        plugin.getLogger().info("Enabling " + plugin.getDescription().getFullName());

        JavaPlugin jPlugin = (JavaPlugin) plugin;

        String pluginName = jPlugin.getDescription().getName();

        if (!loaders.containsKey(pluginName)) {
            loaders.put(pluginName, (PluginClassLoader) jPlugin.getClassLoader());
        }

        try {
            jPlugin.setEnabled(true);
        } catch (Throwable ex) {
            server.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
        }

        // Perhaps abort here, rather than continue going, but as it stands,
        // an abort is not possible the way it's currently written
        server.getPluginManager().callEvent(new PluginEnableEvent(plugin));
    }
}
项目:ExilePearl    文件:TestPluginManager.java   
private void loaderEnablePlugin(Plugin plugin) {
       if (!plugin.isEnabled()) {
           plugin.getLogger().info("Enabling " + plugin.getDescription().getFullName());

           JavaPlugin jPlugin = (JavaPlugin) plugin;

           try {                
            Field f = JavaPlugin.class.getDeclaredField("isEnabled");
            f.setAccessible(true);
            boolean enabled = f.getBoolean(jPlugin);
            if (!enabled) {
                f.setBoolean(jPlugin, true);
                jPlugin.onEnable();
            }
           } catch (Throwable ex) {
               server.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
           }

           server.getPluginManager().callEvent(new PluginEnableEvent(plugin));
       }
}
项目:CauldronGit    文件:JavaPluginLoader.java   
public void enablePlugin(final Plugin plugin) {
    Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");

    if (!plugin.isEnabled()) {
        plugin.getLogger().info("Enabling " + plugin.getDescription().getFullName());

        JavaPlugin jPlugin = (JavaPlugin) plugin;

        String pluginName = jPlugin.getDescription().getName();

        if (!loaders.containsKey(pluginName)) {
            loaders.put(pluginName, (PluginClassLoader) jPlugin.getClassLoader());
        }

        try {
            jPlugin.setEnabled(true);
        } catch (Throwable ex) {
            server.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
        }

        // Perhaps abort here, rather than continue going, but as it stands,
        // an abort is not possible the way it's currently written
        server.getPluginManager().callEvent(new PluginEnableEvent(plugin));
    }
}
项目:Cauldron    文件:JavaPluginLoader.java   
public void enablePlugin(final Plugin plugin) {
    Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");

    if (!plugin.isEnabled()) {
        plugin.getLogger().info("Enabling " + plugin.getDescription().getFullName());

        JavaPlugin jPlugin = (JavaPlugin) plugin;

        String pluginName = jPlugin.getDescription().getName();

        if (!loaders.containsKey(pluginName)) {
            loaders.put(pluginName, (PluginClassLoader) jPlugin.getClassLoader());
        }

        try {
            jPlugin.setEnabled(true);
        } catch (Throwable ex) {
            server.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
        }

        // Perhaps abort here, rather than continue going, but as it stands,
        // an abort is not possible the way it's currently written
        server.getPluginManager().callEvent(new PluginEnableEvent(plugin));
    }
}
项目:Cauldron    文件:JavaPluginLoader.java   
public void enablePlugin(final Plugin plugin) {
    Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");

    if (!plugin.isEnabled()) {
        plugin.getLogger().info("Enabling " + plugin.getDescription().getFullName());

        JavaPlugin jPlugin = (JavaPlugin) plugin;

        String pluginName = jPlugin.getDescription().getName();

        if (!loaders.containsKey(pluginName)) {
            loaders.put(pluginName, (PluginClassLoader) jPlugin.getClassLoader());
        }

        try {
            jPlugin.setEnabled(true);
        } catch (Throwable ex) {
            server.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
        }

        // Perhaps abort here, rather than continue going, but as it stands,
        // an abort is not possible the way it's currently written
        server.getPluginManager().callEvent(new PluginEnableEvent(plugin));
    }
}
项目:Cauldron    文件:JavaPluginLoader.java   
public void enablePlugin(final Plugin plugin) {
    Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");

    if (!plugin.isEnabled()) {
        plugin.getLogger().info("Enabling " + plugin.getDescription().getFullName());

        JavaPlugin jPlugin = (JavaPlugin) plugin;

        String pluginName = jPlugin.getDescription().getName();

        if (!loaders.containsKey(pluginName)) {
            loaders.put(pluginName, (PluginClassLoader) jPlugin.getClassLoader());
        }

        try {
            jPlugin.setEnabled(true);
        } catch (Throwable ex) {
            server.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
        }

        // Perhaps abort here, rather than continue going, but as it stands,
        // an abort is not possible the way it's currently written
        server.getPluginManager().callEvent(new PluginEnableEvent(plugin));
    }
}
项目:xEssentials_old_Source    文件:TPS.java   
@EventHandler
public void onPluginEnable(PluginEnableEvent e) {
    Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(xEssentials.getPlugin(), new Runnable() {
        long sec;
        int ticks;
        @Override
        public void run() {
            sec = System.currentTimeMillis() / 1000;
            if (second == sec) {
                ticks++; 
            } else {
                second = sec;
                tps = tps == 0 ? ticks : (tps + ticks) / 2;
                ticks = 0;
            }
        }
    }, 21, 1);
}
项目:Spigot-API    文件:JavaPluginLoader.java   
public void enablePlugin(final Plugin plugin) {
    Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");

    if (!plugin.isEnabled()) {
        plugin.getLogger().info("Enabling " + plugin.getDescription().getFullName());

        JavaPlugin jPlugin = (JavaPlugin) plugin;

        String pluginName = jPlugin.getDescription().getName();

        if (!loaders.containsKey(pluginName)) {
            loaders.put(pluginName, (PluginClassLoader) jPlugin.getClassLoader());
        }

        try {
            jPlugin.setEnabled(true);
        } catch (Throwable ex) {
            server.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
        }

        // Perhaps abort here, rather than continue going, but as it stands,
        // an abort is not possible the way it's currently written
        server.getPluginManager().callEvent(new PluginEnableEvent(plugin));
    }
}
项目:BungeePerms    文件:EssentialsBridge.java   
@EventHandler
public void onPluginEnable(final PluginEnableEvent e)
{
    if (!e.getPlugin().getName().equalsIgnoreCase("Essentials"))
    {
        return;
    }
    Runnable r = new Runnable()
    {
        @Override
        public void run()
        {
            inject(e.getPlugin());
        }
    };
    Bukkit.getScheduler().runTask(BukkitPlugin.getInstance(), r);
}
项目:BungeePerms    文件:BridgeManager.java   
@EventHandler
public void onPluginEnable(PluginEnableEvent e)
{
    for (Map.Entry<Class<? extends Bridge>, String> entry : brigdesmap.entrySet())
    {
        try
        {
            Class.forName(entry.getValue());
            for (Bridge b : bridges)
            {
                if (b.getClass().getName().equals(entry.getKey().getName()))
                {
                    throw new Exception();
                }
            }
            createBridge(entry.getKey(), entry.getValue()).enable();
        }
        catch (Exception ex)
        {
        }
    }
}
项目:Vault    文件:Permission_Xperms.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {           
    if(permission == null){
        Plugin perms = plugin.getServer().getPluginManager().getPlugin("Xperms");
        if(perms != null){
            try{
                if(Double.valueOf(perms.getDescription().getVersion()) < 1.1){
                    log.info(String.format("[%s] [Permission] %s Current version is not compatible with vault! Please Update!", plugin.getDescription().getName(), name));
                }
            } catch(NumberFormatException e){
                // version is first release, numbered 1.0.0
                log.info(String.format("[%s] [Permission] %s Current version is not compatibe with vault! Please Update!", plugin.getDescription().getName(), name));
            }
            permission.perms = (Main) perms;
            log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
        }
    }
}
项目:Vault    文件:Permission_PermissionsEx.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
    if (permission.permission == null) {
        Plugin perms = plugin.getServer().getPluginManager().getPlugin("PermissionsEx");

        if (perms != null) {
            try {
                if (Double.valueOf(perms.getDescription().getVersion()) < 1.16) {
                    log.info(String.format("[%s][Permission] %s below 1.16 is not compatible with Vault! Falling back to SuperPerms only mode. PLEASE UPDATE!", plugin.getDescription().getName(), name));
                    return;
                }
            } catch (NumberFormatException e) {
                // Do nothing
            }
            permission.permission = (PermissionsEx) perms;
            log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), permission.name));
        }
    }
}
项目:Bukkit-JavaDoc    文件:JavaPluginLoader.java   
public void enablePlugin(final Plugin plugin) {
    Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");

    if (!plugin.isEnabled()) {
        plugin.getLogger().info("Enabling " + plugin.getDescription().getFullName());

        JavaPlugin jPlugin = (JavaPlugin) plugin;

        String pluginName = jPlugin.getDescription().getName();

        if (!loaders.containsKey(pluginName)) {
            loaders.put(pluginName, (PluginClassLoader) jPlugin.getClassLoader());
        }

        try {
            jPlugin.setEnabled(true);
        } catch (Throwable ex) {
            server.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
        }

        // Perhaps abort here, rather than continue going, but as it stands,
        // an abort is not possible the way it's currently written
        server.getPluginManager().callEvent(new PluginEnableEvent(plugin));
    }
}
项目:AuthMeReloaded    文件:ServerListener.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onPluginEnable(PluginEnableEvent event) {
    // Make sure the plugin instance isn't null
    if (event.getPlugin() == null) {
        return;
    }

    final String pluginName = event.getPlugin().getName();

    // Call the onPluginEnable method in the permissions manager
    permissionsManager.onPluginEnable(pluginName);

    if ("Essentials".equalsIgnoreCase(pluginName)) {
        pluginHookService.tryHookToEssentials();
    } else if ("Multiverse-Core".equalsIgnoreCase(pluginName)) {
        pluginHookService.tryHookToMultiverse();
    } else if ("EssentialsSpawn".equalsIgnoreCase(pluginName)) {
        spawnLoader.loadEssentialsSpawn();
    } else if ("CMI".equalsIgnoreCase(pluginName)) {
        pluginHookService.tryHookToCmi();
        spawnLoader.loadCmiSpawn();
    } else if ("ProtocolLib".equalsIgnoreCase(pluginName)) {
        protocolLibService.setup();
    }
}
项目:economy    文件:SubPluginLoader.java   
@Override
public void enablePlugin(Plugin plugin) {
    valid(plugin);
    if (!plugin.isEnabled()) {
        plugin.getLogger().info("Enabling " + plugin.getDescription().getFullName());
        SubPlugin sub = (SubPlugin) plugin;
        try {
            sub.setEnabled(true);
        } catch (Exception e) {
            Bukkit.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", e);
        }
        Bukkit.getPluginManager().callEvent(new PluginEnableEvent(plugin));
    }
}
项目:cubit    文件:PluginLoadListener.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
    Plugin p = event.getPlugin();
    String name = p.getDescription().getName();
    if (name.equals("dynmap") || name.equals("WorldGuard")) {
        if (this.cubitDynmap.dynmap.isEnabled() && CubitBukkitPlugin.inst().getWorldGuardPlugin().isEnabled())
            this.cubitDynmap.initialize();
    }
}
项目:SuperVanish    文件:PluginHookMgr.java   
public PluginHookMgr(SuperVanish plugin) {
    this.plugin = plugin;
    plugin.getServer().getPluginManager().registerEvents(this, plugin);
    for (Plugin alreadyEnabledPlugin : Bukkit.getPluginManager().getPlugins())
        if (alreadyEnabledPlugin.isEnabled())
            onPluginEnable(new PluginEnableEvent(alreadyEnabledPlugin));
}
项目:PowerfulPerms    文件:PowerfulPerms.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent e) {
    if (e.getPlugin().getName().equals("PlaceholderAPI")) {
        Bukkit.getLogger().info(consolePrefix + "Found PlaceholderAPI. Using custom chat format.");
        placeholderAPIEnabled = true;
    } else if (e.getPlugin().getName().equals("Importer")) {
        Bukkit.getLogger().info(consolePrefix + "Found Importer. Enabling Importer integration.");
        ImporterHook importerHook = new ImporterHook();
        importerHook.hook(this);
    }
}
项目:beaconz    文件:OurServerListener.java   
@EventHandler(priority=EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
    Plugin p = event.getPlugin();
    String name = p.getDescription().getName();
    if(name.equals("dynmap")) {
        if(dynmap.isEnabled())
            activate(dynmap);
    }
}
项目:hooks    文件:ServerListener.java   
@EventHandler(ignoreCancelled = true)
public void onPluginEnable(final PluginEnableEvent event) {
    final Plugin plugin = event.getPlugin();
    if (!plugin.getName().equals("Vault")) return;
    this.factionsHook.deinit();
    this.factionsHook.init();
}
项目:Chatterbox    文件:ServerListener.java   
@EventHandler(ignoreCancelled = true)
public void onPluginEnable(final PluginEnableEvent event) {
    final Plugin plugin = event.getPlugin();
    if (!plugin.getName().equals("Vault")) return;
    this.vaultHook.deinit();
    this.vaultHook.init();
}
项目:plot2dynmap    文件:Main.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(final PluginEnableEvent event) {
    final Plugin p = event.getPlugin();
    final String name = p.getDescription().getName();
    if (name.equals("dynmap")) {
        if (this.dynmap.isEnabled() && this.plot2.isEnabled()) {
            initialize();
        }
    }
}
项目:SurvivalGamesX    文件:ServerListener.java   
@EventHandler(priority = EventPriority.LOW)
public void onPluginEnable(PluginEnableEvent event) {
    if (event.getPlugin() != plugin) {
        // Try to load again!
        Perms.onOtherPluginEnable();
        plugin.getTreasury().onOtherPluginEnable();
    }
}
项目:pploader    文件:PythonPluginLoader.java   
public void enablePlugin(Plugin plugin) {
    if (!(plugin instanceof PythonPlugin)) {
        throw new IllegalArgumentException("Plugin is not associated with this PluginLoader");
    }

    if (!plugin.isEnabled()) {
        PythonPlugin pyPlugin = (PythonPlugin) plugin;

        String pluginName = pyPlugin.getDescription().getName();

        if (!loadedplugins.contains(pluginName))
            loadedplugins.add(pluginName);

        try {
            pyPlugin.setEnabled(true);
        } catch (Throwable ex) {
            server.getLogger().log(Level.SEVERE,
                    "Error occurred while enabling " + plugin.getDescription().getFullName()
                            + " (Is it up to date?): " + ex.getMessage(),
                    ex);
        }

        // Perhaps abort here, rather than continue going, but as it stands,
        // an abort is not possible the way it's currently written
        server.getPluginManager().callEvent(new PluginEnableEvent(plugin));
    }
}
项目:StarQuestCode    文件:RecyclerListener.java   
@EventHandler
public void onPluginEnable(PluginEnableEvent enableEvent){
    if(check == 0){
        BukkitTask task = new RecyclerTask(this.plugin).runTask(this.plugin);
        check = 1;
    }
}
项目:SwornPermissions    文件:ServerListener.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event)
{
    if (plugin.isUpdated())
    {
        long start = System.currentTimeMillis();
        plugin.getLogHandler().log("Plugin {0} enabled. Performing permission update.", event.getPlugin());

        plugin.getPermissionHandler().update();

        plugin.getLogHandler().log("Permissions updated. Took {0} ms.", System.currentTimeMillis() - start);
    }
}
项目:Stoa    文件:WorldGuardUtil.java   
@EventHandler(priority = EventPriority.MONITOR)
void onPluginEnable(PluginEnableEvent event) {
    if (ENABLED || !event.getPlugin().getName().equals("WorldGuard")) return;
    try {
        ENABLED = event.getPlugin() instanceof WorldGuardPlugin;
    } catch (Exception ignored) {
    }
}
项目:SkinChanger    文件:EventListener.java   
@EventHandler
public void onPluginEnable(PluginEnableEvent event) {
    if (!Main.getInstance().isPluginEnabled() && event.getPlugin().getDescription().getName().equals("ProtocolLib")) {
        Main.getInstance().setPluginEnabled(true);
        Main.getInstance().enablePlugin();
    }
}
项目:RoyalEconomy    文件:VaultConnector.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(final PluginEnableEvent event) {
    if (this.economy.economy == null) {
        final Plugin ec = event.getPlugin();
        if (ec.getClass().getName().equals("org.royaldev.royaleconomy.RoyalEconomy")) {
            final String version = ec.getDescription().getVersion();
            VaultConnector.this.name += version;
            this.economy.economy = (RoyalEconomy) ec;
            VaultConnector.this.plugin.getLogger().info("Hooked into Vault!");
        }
    }
}
项目:Almura-API    文件:JavaPluginLoader.java   
public void enablePlugin(final Plugin plugin) {
    if (!(plugin instanceof JavaPlugin)) {
        throw new IllegalArgumentException("Plugin is not associated with this PluginLoader");
    }

    if (!plugin.isEnabled()) {
        String message = String.format("Enabling %s", plugin.getDescription().getFullName());
        plugin.getLogger().info(message);

        JavaPlugin jPlugin = (JavaPlugin) plugin;

        String pluginName = jPlugin.getDescription().getName();

        if (!loaders.containsKey(pluginName)) {
            loaders.put(pluginName, (PluginClassLoader) jPlugin.getClassLoader());
        }

        try {
            jPlugin.setEnabled(true);
        } catch (Throwable ex) {
            server.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
        }

        // Perhaps abort here, rather than continue going, but as it stands,
        // an abort is not possible the way it's currently written
        server.getPluginManager().callEvent(new PluginEnableEvent(plugin));
    }
}
项目:DemigodsRPG    文件:WorldGuardUtil.java   
@EventHandler(priority = EventPriority.MONITOR)
void onPluginEnable(PluginEnableEvent event) {
    if (ENABLED || !event.getPlugin().getName().equals("WorldGuard")) return;
    try {
        ENABLED = event.getPlugin() instanceof WorldGuardPlugin;
    } catch (Exception ignored) {
    }
}
项目:Controllable-Mobs-API    文件:ControllableMobsAPIPlugin.java   
@EventHandler
public void onPluginEnabled(PluginEnableEvent event) {
    if(event.getPlugin()==this) return;
    PluginDescriptionFile desc = event.getPlugin().getDescription();
    String name = this.getName();
    if( this.containsIgnoreCase(desc.getDepend(), name) || this.containsIgnoreCase(desc.getSoftDepend(), name)) {
        this.usedBy.add(desc.getFullName());
    }
}
项目:BungeePerms    文件:EssentialsBridge.java   
@Override
public void disable()
{
    Plugin plugin = Bukkit.getPluginManager().getPlugin("Essentials");
    if (plugin != null)
    {
        uninject(plugin);
    }

    PluginEnableEvent.getHandlerList().unregister(this);
    PluginDisableEvent.getHandlerList().unregister(this);
}
项目:BungeePerms    文件:Permission_BungeePerms.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event)
{
    if (perms == null)
    {
        Plugin p = event.getPlugin();
        if (p.getDescription().getName().equals("BungeePerms"))
        {
            perms = BungeePerms.getInstance();
            log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
        }
    }
}
项目:BungeePerms    文件:VaultBridge.java   
@Override
public void disable()
{
    Plugin plugin = Bukkit.getPluginManager().getPlugin("Vault");
    if (plugin != null)
    {
        uninject(plugin);
    }

    PluginEnableEvent.getHandlerList().unregister(this);
    PluginDisableEvent.getHandlerList().unregister(this);
}
项目:BungeePerms    文件:VaultBridge.java   
@EventHandler
public void onPluginEnable(PluginEnableEvent e)
{
    if (!e.getPlugin().getName().equalsIgnoreCase("vault"))
    {
        return;
    }
    inject(e.getPlugin());
}
项目:BungeePerms    文件:Chat_BungeePerms.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event)
{
    if (perms == null)
    {
        Plugin p = event.getPlugin();
        if (p.getDescription().getName().equals("BungeePerms"))
        {
            perms = BungeePerms.getInstance();
            log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), name));
        }
    }
}
项目:BungeePerms    文件:WorldEditBridge.java   
@Override
public void disable()
{
    Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldEdit");
    if (plugin != null)
    {
        uninject(plugin);
    }

    PluginEnableEvent.getHandlerList().unregister(this);
    PluginDisableEvent.getHandlerList().unregister(this);
}
项目:BungeePerms    文件:WorldEditBridge.java   
@EventHandler
public void onPluginEnable(PluginEnableEvent e)
{
    if (!e.getPlugin().getName().equalsIgnoreCase("worldedit"))
    {
        return;
    }
    inject(e.getPlugin());
}
项目:BungeePerms    文件:BridgeManager.java   
public void disable()
{
    PluginEnableEvent.getHandlerList().unregister((Listener) this);
    for (Bridge b : bridges)
    {
        b.disable();
    }
}