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


Java PluginIdentifiableCommand类代码示例

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


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

示例1: register

import org.bukkit.command.PluginIdentifiableCommand; //导入依赖的package包/类
@Override
public boolean register(String label, String fallbackPrefix, Command command) {
    // TODO: Label
    // TODO: Fallback prefix

    Object plugin = Pore.getPlugin();
    if (command instanceof PluginIdentifiableCommand) {
        plugin = Pore.getPlugin(((PluginIdentifiableCommand) command).getPlugin());
    }

    List<String> aliases = Lists.newArrayList(command.getAliases());
    String name = command.getName();
    if (!name.equals(label)) {
        aliases.add(0, label);
    }
    aliases.add(0, name);

    Optional<CommandMapping> result = handle.register(plugin, new PoreCommandCallable(command), aliases);
    if (result.isPresent()) {
        command.register(this);
        return true;
    } else {
        return false;
    }
}
 
开发者ID:LapisBlue,项目名称:Pore,代码行数:26,代码来源:PoreCommandMap.java

示例2: inject

import org.bukkit.command.PluginIdentifiableCommand; //导入依赖的package包/类
public static void inject(Plugin toInjectPlugin) {
        PluginManager pluginManager = Bukkit.getPluginManager();
        SimpleCommandMap commandMap = Reflection
                .getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class).get(pluginManager);
        for (Command command : commandMap.getCommands()) {
            if (command instanceof PluginCommand) {
                PluginIdentifiableCommand pluginCommand = (PluginIdentifiableCommand) command;
                Plugin plugin = pluginCommand.getPlugin();
                if (plugin.equals(toInjectPlugin)) {
                    FieldAccessor<CommandExecutor> executorField = Reflection
                            .getField(PluginCommand.class, "executor", CommandExecutor.class);
                    FieldAccessor<TabCompleter> completerField = Reflection
                            .getField(PluginCommand.class, "completer", TabCompleter.class);

                    CommandExecutor executor = executorField.get(pluginCommand);
                    TabCompleter completer = completerField.get(pluginCommand);

                    CommandInjector commandInjector = new CommandInjector(executor, completer);

                    executorField.set(pluginCommand, commandInjector);
                    completerField.set(pluginCommand, commandInjector);
                }
            }

            //idea: inject also vanilla commands?
//            if (command instanceof VanillaCommand) {
//
//            }
        }
    }
 
开发者ID:games647,项目名称:LagMonitor,代码行数:31,代码来源:CommandInjector.java

示例3: uninject

import org.bukkit.command.PluginIdentifiableCommand; //导入依赖的package包/类
public static void uninject(Plugin toUninject) {
    PluginManager pluginManager = Bukkit.getPluginManager();
    SimpleCommandMap commandMap = Reflection
            .getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class).get(pluginManager);
    for (Command command : commandMap.getCommands()) {
        if (command instanceof PluginCommand) {
            PluginIdentifiableCommand pluginCommand = (PluginIdentifiableCommand) command;
            Plugin plugin = pluginCommand.getPlugin();
            if (plugin.equals(toUninject)) {
                FieldAccessor<CommandExecutor> executorField = Reflection
                        .getField(PluginCommand.class, "executor", CommandExecutor.class);
                FieldAccessor<TabCompleter> completerField = Reflection
                        .getField(PluginCommand.class, "completer", TabCompleter.class);

                CommandExecutor executor = executorField.get(pluginCommand);
                if (executor instanceof CommandInjector) {
                    executorField.set(pluginCommand, ((CommandInjector) executor).originalExecutor);
                }

                TabCompleter completer = completerField.get(pluginCommand);
                if (completer instanceof CommandInjector) {
                    completerField.set(pluginCommand, ((CommandInjector) completer).originalCompleter);
                }
            }
        }
    }
}
 
开发者ID:games647,项目名称:LagMonitor,代码行数:28,代码来源:CommandInjector.java

示例4: registerCommand

import org.bukkit.command.PluginIdentifiableCommand; //导入依赖的package包/类
/**
 * Attempts to register a command with the corresponding server's command map. Note that this method uses Reflection
 * to access the command map and may fail due to that. The command map is cached once retrieved.
 *
 * @param command the command to register
 * @throws IllegalStateException if retrieval of the command map fails
 * @deprecated This method always uses the static fallback prefix "mtc". Prefer {@link #registerCommand(Command,
 * String)}.
 */
@Deprecated
public <T extends Command & PluginIdentifiableCommand> void registerCommand(T command) throws IllegalStateException {
    registerCommand(command, "mtc");
}
 
开发者ID:xxyy,项目名称:intake-spigot,代码行数:14,代码来源:CommandRegistrationManager.java


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