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


Java PluginManager.getPlugins方法代码示例

本文整理汇总了Java中org.bukkit.plugin.PluginManager.getPlugins方法的典型用法代码示例。如果您正苦于以下问题:Java PluginManager.getPlugins方法的具体用法?Java PluginManager.getPlugins怎么用?Java PluginManager.getPlugins使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.plugin.PluginManager的用法示例。


在下文中一共展示了PluginManager.getPlugins方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: displayMinecraftInfo

import org.bukkit.plugin.PluginManager; //导入方法依赖的package包/类
private void displayMinecraftInfo(CommandSender sender) {
    //minecraft specific
    sender.sendMessage(PRIMARY_COLOR + "TPS: " + SECONDARY_COLOR + plugin.getTpsHistoryTask().getLastSample());

    TrafficReader trafficReader = plugin.getTrafficReader();
    if (trafficReader != null) {
        String formattedIncoming = readableByteCount(trafficReader.getIncomingBytes().get());
        String formattedOutgoing = readableByteCount(trafficReader.getOutgoingBytes().get());
        sender.sendMessage(PRIMARY_COLOR + "Incoming Traffic: " + SECONDARY_COLOR + formattedIncoming);
        sender.sendMessage(PRIMARY_COLOR + "Outgoing Traffic: " + SECONDARY_COLOR + formattedOutgoing);
    }

    PluginManager pluginManager = Bukkit.getPluginManager();
    Plugin[] plugins = pluginManager.getPlugins();
    sender.sendMessage(PRIMARY_COLOR + "Loaded Plugins: "
            + SECONDARY_COLOR + getEnabledPlugins(plugins) + '/' + plugins.length);

    int onlinePlayers = Bukkit.getOnlinePlayers().size();
    int maxPlayers = Bukkit.getMaxPlayers();
    sender.sendMessage(PRIMARY_COLOR + "Players: " + SECONDARY_COLOR + onlinePlayers + '/' + maxPlayers);

    displayWorldInfo(sender);
    sender.sendMessage(PRIMARY_COLOR + "Server version: " + SECONDARY_COLOR + Bukkit.getVersion());
}
 
开发者ID:games647,项目名称:LagMonitor,代码行数:25,代码来源:SystemCommand.java

示例2: setPermsSystem

import org.bukkit.plugin.PluginManager; //导入方法依赖的package包/类
public void setPermsSystem() {
	PluginManager pm = Bukkit.getServer().getPluginManager();
	for(Plugin pl : pm.getPlugins()){
		if(pl.isEnabled()){
			String plName = pl.getName();
			if(app.contains(plName)){
				permsPlugin = pm.getPlugin(plName);
			}
		}
	}
}
 
开发者ID:DiscowZombie,项目名称:UltimateTs,代码行数:12,代码来源:PermsManager.java

示例3: getPluginWithNotExactName

import org.bukkit.plugin.PluginManager; //导入方法依赖的package包/类
public static Plugin getPluginWithNotExactName(String name)
{
	PluginManager pm = Bukkit.getPluginManager();
	for (Plugin plug : pm.getPlugins())
	{
		if (plug.getName().matches("(?i)^" + name + ".*"))
		{
			return plug;
		}
	}
	
	return null;
}
 
开发者ID:leonardosnt,项目名称:OldBukkit,代码行数:14,代码来源:LsMagnata.java

示例4: unloadPlugin

import org.bukkit.plugin.PluginManager; //导入方法依赖的package包/类
/**
 * Unloads the specified plugin.
 *
 * @param pluginName The name of the plugin to unload.
 * @return True if the specified plugin was unloaded, false otherwise.
 */
private boolean unloadPlugin(String pluginName)
		throws Exception {
	PluginManager manager = getServer().getPluginManager();
	SimplePluginManager spmanager = (SimplePluginManager) manager;
	if (spmanager != null) {
		Field pluginsField = spmanager.getClass().getDeclaredField("plugins");
		pluginsField.setAccessible(true);
		List<Plugin> plugins = (List) pluginsField.get(spmanager);
		
		Field lookupNamesField = spmanager.getClass().getDeclaredField("lookupNames");
		lookupNamesField.setAccessible(true);
		Map<String, Plugin> lookupNames = (Map) lookupNamesField.get(spmanager);
		
		Field commandMapField = spmanager.getClass().getDeclaredField("commandMap");
		commandMapField.setAccessible(true);
		SimpleCommandMap commandMap = (SimpleCommandMap) commandMapField.get(spmanager);
		
		Field knownCommandsField;
		Map<String, Command> knownCommands = null;
		if (commandMap != null) {
			knownCommandsField = commandMap.getClass().getDeclaredField("knownCommands");
			knownCommandsField.setAccessible(true);
			knownCommands = (Map) knownCommandsField.get(commandMap);
		}
		Plugin plugin;
		Iterator<Map.Entry<String, Command>> it;
		for (Plugin plugin1 : manager.getPlugins()) {
			if (plugin1.getDescription().getName().equalsIgnoreCase(pluginName)) {
				manager.disablePlugin(plugin1);
				if ((plugins != null) && (plugins.contains(plugin1))) {
					plugins.remove(plugin1);
				}
				if ((lookupNames != null) && (lookupNames.containsKey(pluginName))) {
					lookupNames.remove(pluginName);
				}
				if (commandMap != null) {
					for (it = knownCommands.entrySet().iterator(); it.hasNext(); ) {
						Map.Entry<String, Command> entry = it.next();
						if ((entry.getValue() instanceof PluginCommand)) {
							PluginCommand command = (PluginCommand) entry.getValue();
							if (command.getPlugin() == plugin1) {
								command.unregister(commandMap);
								it.remove();
							}
						}
					}
				}
			}
		}
	} else {
		return true;
	}
	return true;
}
 
开发者ID:mastercake10,项目名称:TimeIsMoney,代码行数:61,代码来源:Main.java

示例5: unloadPlugin

import org.bukkit.plugin.PluginManager; //导入方法依赖的package包/类
private boolean unloadPlugin(String pluginName)
  throws Exception
{
  PluginManager manager = getServer().getPluginManager();
  SimplePluginManager spmanager = (SimplePluginManager)manager;

  if (spmanager != null) {
    Field pluginsField = spmanager.getClass().getDeclaredField("plugins");
    pluginsField.setAccessible(true);
    List plugins = (List)pluginsField.get(spmanager);

    Field lookupNamesField = spmanager.getClass().getDeclaredField("lookupNames");
    lookupNamesField.setAccessible(true);
    Map lookupNames = (Map)lookupNamesField.get(spmanager);

    Field commandMapField = spmanager.getClass().getDeclaredField("commandMap");
    commandMapField.setAccessible(true);
    SimpleCommandMap commandMap = (SimpleCommandMap)commandMapField.get(spmanager);

    Field knownCommandsField = null;
    Map knownCommands = null;

    if (commandMap != null) {
      knownCommandsField = commandMap.getClass().getDeclaredField("knownCommands");
      knownCommandsField.setAccessible(true);
      knownCommands = (Map)knownCommandsField.get(commandMap);
    }
    Iterator it;
    for (Plugin plugin: manager.getPlugins())
      if (plugin.getDescription().getName().equalsIgnoreCase(pluginName)) {
        manager.disablePlugin(plugin);

        if ((plugins != null) && (plugins.contains(plugin))) {
          plugins.remove(plugin);
        }

        if ((lookupNames != null) && (lookupNames.containsKey(pluginName))) {
          lookupNames.remove(pluginName);
        }

        if (commandMap != null)
          for (it = knownCommands.entrySet().iterator(); it.hasNext(); ) {
            Map.Entry entry = (Map.Entry)it.next();

            if ((entry.getValue() instanceof PluginCommand)) {
              PluginCommand command = (PluginCommand)entry.getValue();

              if (command.getPlugin() == plugin) {
                command.unregister(commandMap);
                it.remove();
              }
            }
          }
      }
  }
  else
  {
    getServer().getLogger().warning(pluginName + " is already unloaded.");
    return true;
  }
  
  getServer().getLogger().info("Unloaded " + pluginName + " successfully!");

  return true;
}
 
开发者ID:cyberlis,项目名称:pploader,代码行数:66,代码来源:PythonLoader.java


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