當前位置: 首頁>>代碼示例>>Java>>正文


Java PluginEnableEvent類代碼示例

本文整理匯總了Java中org.bukkit.event.server.PluginEnableEvent的典型用法代碼示例。如果您正苦於以下問題:Java PluginEnableEvent類的具體用法?Java PluginEnableEvent怎麽用?Java PluginEnableEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PluginEnableEvent類屬於org.bukkit.event.server包,在下文中一共展示了PluginEnableEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: enablePlugin

import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
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));
    }
}
 
開發者ID:CyberdyneCC,項目名稱:Thermos-Bukkit,代碼行數:26,代碼來源:JavaPluginLoader.java

示例2: loaderEnablePlugin

import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
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));
       }
}
 
開發者ID:DevotedMC,項目名稱:ExilePearl,代碼行數:22,代碼來源:TestPluginManager.java

示例3: onPluginEnable

import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@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);
}
 
開發者ID:xize,項目名稱:xEssentials_old_Source,代碼行數:19,代碼來源:TPS.java

示例4: onPluginEnable

import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@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);
}
 
開發者ID:weaondara,項目名稱:BungeePerms,代碼行數:18,代碼來源:EssentialsBridge.java

示例5: onPluginEnable

import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@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)
        {
        }
    }
}
 
開發者ID:weaondara,項目名稱:BungeePerms,代碼行數:23,代碼來源:BridgeManager.java

示例6: onPluginEnable

import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@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));
        }
    }
}
 
開發者ID:Realmcraft,項目名稱:Vault,代碼行數:19,代碼來源:Permission_Xperms.java

示例7: onPluginEnable

import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@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));
        }
    }
}
 
開發者ID:Realmcraft,項目名稱:Vault,代碼行數:20,代碼來源:Permission_PermissionsEx.java

示例8: onPluginEnable

import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@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();
    }
}
 
開發者ID:AuthMe,項目名稱:AuthMeReloaded,代碼行數:26,代碼來源:ServerListener.java

示例9: enablePlugin

import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@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));
    }
}
 
開發者ID:caoli5288,項目名稱:economy,代碼行數:15,代碼來源:SubPluginLoader.java

示例10: onPluginEnable

import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@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();
    }
}
 
開發者ID:MineGaming,項目名稱:cubit,代碼行數:10,代碼來源:PluginLoadListener.java

示例11: PluginHookMgr

import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
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));
}
 
開發者ID:MyzelYam,項目名稱:SuperVanish,代碼行數:8,代碼來源:PluginHookMgr.java

示例12: onPluginEnable

import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@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);
    }
}
 
開發者ID:gustav9797,項目名稱:PowerfulPerms,代碼行數:12,代碼來源:PowerfulPerms.java

示例13: onPluginEnable

import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@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);
    }
}
 
開發者ID:tastybento,項目名稱:beaconz,代碼行數:10,代碼來源:OurServerListener.java

示例14: onPluginEnable

import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@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();
}
 
開發者ID:Chatterbox,項目名稱:hooks,代碼行數:8,代碼來源:ServerListener.java

示例15: onPluginEnable

import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@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();
}
 
開發者ID:Chatterbox,項目名稱:Chatterbox,代碼行數:8,代碼來源:ServerListener.java


注:本文中的org.bukkit.event.server.PluginEnableEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。