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


Java PluginCommand.getPlugin方法代码示例

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


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

示例1: getCommand

import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
/**
 * Gets the command with the given name, specific to this plugin. Commands
 * need to be registered in the {@link PluginDescriptionFile#getCommands()
 * PluginDescriptionFile} to exist at runtime.
 *
 * @param name name or alias of the command
 * @return the plugin command if found, otherwise null
 */
public PluginCommand getCommand(String name) {
    String alias = name.toLowerCase();
    PluginCommand command = getServer().getPluginCommand(alias);

    if (command == null || command.getPlugin() != this) {
        command = getServer().getPluginCommand(description.getName().toLowerCase() + ":" + alias);
    }

    if (command != null && command.getPlugin() == this) {
        return command;
    } else {
        return null;
    }
}
 
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:23,代码来源:JavaPlugin.java

示例2: getCommand

import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
/**
 * Gets the command with the given name, specific to this plugin
 *
 * @param name Name or alias of the command
 * @return PluginCommand if found, otherwise null
 */
public PluginCommand getCommand(String name) {
    String alias = name.toLowerCase();
    PluginCommand command = getServer().getPluginCommand(alias);

    if ((command != null) && (command.getPlugin() != this)) {
        command = getServer().getPluginCommand(getDescription().getName().toLowerCase() + ":" + alias);
    }

    if ((command != null) && (command.getPlugin() == this)) {
        return command;
    } else {
        return null;
    }
}
 
开发者ID:cyberlis,项目名称:pploader,代码行数:21,代码来源:PythonPlugin.java

示例3: removeOperation

import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
@Operation(aliases = {"del"})
public Parameter removeOperation(Parameter dummy, Context ctx, StringParameter command) {
	String cmd = command.asString(ctx);
	org.bukkit.command.Command bcmd = getCommandFromServer(Bukkit.getServer(), cmd);
	if ( ! ( bcmd instanceof PluginCommand ) ) return Parameter.from(false);
	PluginCommand pcmd = (PluginCommand) bcmd;
	if ( pcmd.getPlugin() != ParchmentPluginLite.instance() ) Parameter.from(false);
	boolean result = removeCommandFromServer(Bukkit.getServer(), cmd);
	Debug.info("Remove %s from map = %s", cmd, result ? "true" : "false");
	return Parameter.from(result);
}
 
开发者ID:basicer,项目名称:parchment,代码行数:12,代码来源:Command.java

示例4: listOperation

import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
@Operation()
public Parameter listOperation(Parameter dummy, Context ctx) {
	ArrayList<Parameter> result = new ArrayList<Parameter>();
	for ( org.bukkit.command.Command bcmd : getServerCommandMap(Bukkit.getServer()).getCommands() ) {
		if ( ! ( bcmd instanceof PluginCommand ) ) continue;
		PluginCommand pcmd = (PluginCommand) bcmd;
		if ( pcmd.getPlugin() != ParchmentPluginLite.instance() ) continue;
		if ( pcmd.getExecutor() instanceof ParchmentCommandExecutor ) continue;
		result.add(Parameter.from(pcmd.getName()));
	}
	return ListParameter.from(result);
}
 
开发者ID:basicer,项目名称:parchment,代码行数:13,代码来源:Command.java

示例5: getCommand

import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
/**
 * Gets the command with the given name, specific to this plugin. Commands
 * need to be registered in the {@link PluginDescriptionFile#getCommands()
 * PluginDescriptionFile} to exist at runtime.
 *
 * @param name name or alias of the command
 * @return the plugin command if found, otherwise null
 */
public PluginCommand getCommand(String name) {
    String alias = name.toLowerCase();
    PluginCommand command = getServer().getPluginCommand(alias);

    if ((command != null) && (command.getPlugin() != this)) {
        command = getServer().getPluginCommand(description.getName().toLowerCase() + ":" + alias);
    }

    if ((command != null) && (command.getPlugin() == this)) {
        return command;
    } else {
        return null;
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-API,代码行数:23,代码来源:JavaPlugin.java

示例6: unloadPlugin

import org.bukkit.command.PluginCommand; //导入方法依赖的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

示例7: unloadPlugin

import org.bukkit.command.PluginCommand; //导入方法依赖的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.command.PluginCommand.getPlugin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。