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


Java TabCompleter類代碼示例

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


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

示例1: registerCommand

import org.bukkit.command.TabCompleter; //導入依賴的package包/類
/**
 * Registers a CommandExecutor with the server
 *
 * @param plugin the plugin instance
 * @param command the command instance
 * @param aliases the command aliases
 * @param <T> the command executor class type
 * @return the command executor
 */
@Nonnull
public static <T extends CommandExecutor> T registerCommand(@Nonnull Plugin plugin, @Nonnull T command, @Nonnull String... aliases) {
    Preconditions.checkArgument(aliases.length != 0, "No aliases");
    for (String alias : aliases) {
        try {
            PluginCommand cmd = COMMAND_CONSTRUCTOR.newInstance(alias, plugin);

            getCommandMap().register(plugin.getDescription().getName(), cmd);
            getKnownCommandMap().put(plugin.getDescription().getName().toLowerCase() + ":" + alias.toLowerCase(), cmd);
            getKnownCommandMap().put(alias.toLowerCase(), cmd);
            cmd.setLabel(alias.toLowerCase());

            cmd.setExecutor(command);
            if (command instanceof TabCompleter) {
                cmd.setTabCompleter((TabCompleter) command);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return command;
}
 
開發者ID:lucko,項目名稱:helper,代碼行數:32,代碼來源:CommandMapUtil.java

示例2: inject

import org.bukkit.command.TabCompleter; //導入依賴的package包/類
/**
 * 
 * @author jiongjionger,Vlvxingze
 */

public static void inject(Plugin plg) {
	if (plg != null) {
		try {
			SimpleCommandMap simpleCommandMap = Reflection.getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class).get(Bukkit.getPluginManager());
			for (Command command : simpleCommandMap.getCommands()) {
				if (command instanceof PluginCommand) {
					PluginCommand pluginCommand = (PluginCommand) command;
					if (plg.equals(pluginCommand.getPlugin())) {
						FieldAccessor<CommandExecutor> commandField = Reflection.getField(PluginCommand.class, "executor", CommandExecutor.class);
						FieldAccessor<TabCompleter> tabField = Reflection.getField(PluginCommand.class, "completer", TabCompleter.class);
						CommandInjector commandInjector = new CommandInjector(plg, commandField.get(pluginCommand), tabField.get(pluginCommand));
						commandField.set(pluginCommand, commandInjector);
						tabField.set(pluginCommand, commandInjector);
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
開發者ID:GelandiAssociation,項目名稱:EscapeLag,代碼行數:27,代碼來源:CommandInjector.java

示例3: uninject

import org.bukkit.command.TabCompleter; //導入依賴的package包/類
public static void uninject(Plugin plg) {
	if (plg != null) {
		try {
			SimpleCommandMap simpleCommandMap = Reflection.getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class).get(Bukkit.getPluginManager());
			for (Command command : simpleCommandMap.getCommands()) {
				if (command instanceof PluginCommand) {
					PluginCommand pluginCommand = (PluginCommand) command;
					if (plg.equals(pluginCommand.getPlugin())) {
						FieldAccessor<CommandExecutor> commandField = Reflection.getField(PluginCommand.class, "executor", CommandExecutor.class);
						FieldAccessor<TabCompleter> tabField = Reflection.getField(PluginCommand.class, "completer", TabCompleter.class);
						CommandExecutor executor = commandField.get(pluginCommand);
						if (executor instanceof CommandInjector) {
							commandField.set(pluginCommand, ((CommandInjector) executor).getCommandExecutor());
						}
						TabCompleter completer = tabField.get(pluginCommand);
						if (completer instanceof CommandInjector) {
							tabField.set(pluginCommand, ((CommandInjector) executor).getTabCompleter());
						}
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
開發者ID:GelandiAssociation,項目名稱:EscapeLag,代碼行數:27,代碼來源:CommandInjector.java

示例4: onEnable

import org.bukkit.command.TabCompleter; //導入依賴的package包/類
@Override
public void onEnable() {
    instance = this;
    funcMgr = new FunctionManager(this);
    cfg = new Configuration(this);
    cfg.load();
    i18n = new I18n(this, cfg.language);
    cmd = new CommandHandler(this, i18n);
    script = new ScriptsManager(this);
    getCommand(PLUGIN_COMMAND_NAME).setExecutor(cmd);
    getCommand(PLUGIN_COMMAND_NAME).setTabCompleter((TabCompleter) cmd);
    funcMgr.registerTriggerListeners();
}
 
開發者ID:NyaaCat,項目名稱:GenericTools,代碼行數:14,代碼來源:GenericTools.java

示例5: loadCommands

import org.bukkit.command.TabCompleter; //導入依賴的package包/類
@SuppressWarnings("unchecked")
private void loadCommands() {
    InputStream resource = getResource("META-INF/.pl.commands.yml");
    if (resource == null)
        return;

    yamlParser.parse(resource, CommandsFile.class).blockingGet().getCommands().forEach((command, handler) -> {
        PluginCommand bukkitCmd = getCommand(command);
        if (bukkitCmd == null)
            throw new IllegalStateException("could not find command '" + command + "' for plugin...");

        Class<?> handlerType;
        try {
            handlerType = Class.forName(handler.handler);
        } catch (ClassNotFoundException e) {
            throw new IllegalStateException("could not find class " + handler + " for command " + command + "!", e);
        }

        if (!JCmd.class.isAssignableFrom(handlerType)) {
            if (!CommandExecutor.class.isAssignableFrom(handlerType))
                throw new IllegalStateException(handlerType.getName() + " is not a valid handler class, does not extend JCmd");

            CommandExecutor instance = (CommandExecutor) injector.get().getInstance(handlerType);
            bukkitCmd.setExecutor(instance);
            if (instance instanceof TabCompleter)
                bukkitCmd.setTabCompleter((TabCompleter) instance);

        } else {
            Class<? extends JCmd> commandType = (Class<? extends JCmd>) handlerType;

            JCommandExecutor executor = new JCommandExecutor(commandType, injector);

            bukkitCmd.setExecutor(executor);
            bukkitCmd.setTabCompleter(executor);
        }

        getLogger().info("loaded command /" + command + " => " + handlerType.getSimpleName());
    });
}
 
開發者ID:Twister915,項目名稱:pl,代碼行數:40,代碼來源:JPl.java

示例6: tabComplete

import org.bukkit.command.TabCompleter; //導入依賴的package包/類
@Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws CommandException, IllegalArgumentException {
	Validate.notNull(sender, "Sender cannot be null");
	Validate.notNull(args, "Arguments cannot be null");
	Validate.notNull(alias, "Alias cannot be null");

	List<String> completions = null;

	try {
		if (this.completer != null) {
			completions = this.completer.onTabComplete(sender, this, alias, args);
		}

		if (completions == null && this.executor instanceof TabCompleter) {
			completions = ((TabCompleter) this.executor).onTabComplete(sender, this, alias, args);
		}
	}
	catch (Throwable ex) {
		StringBuilder message = new StringBuilder();
		message.append("Unhandled exception during tab completion for command '/").append(alias).append(' ');

		for (String arg : args) {
			message.append(arg).append(' ');
		}

		message.deleteCharAt(message.length() - 1).append("' in plugin ").append(this.owningPlugin.getDescription().getFullName());

		throw new CommandException(message.toString(), ex);
	}

	if (completions == null) {
		return super.tabComplete(sender, alias, args);
	}

	return completions;
}
 
開發者ID:ijoeleoli,項目名稱:ServerCommons,代碼行數:37,代碼來源:BukkitCommand.java

示例7: tabComplete

import org.bukkit.command.TabCompleter; //導入依賴的package包/類
@Override
public java.util.List<String> tabComplete(CommandSender sender, String alias, String[] args) throws CommandException, IllegalArgumentException {
	Validate.notNull(sender, "Sender cannot be null");
	Validate.notNull(args, "Arguments cannot be null");
	Validate.notNull(alias, "Alias cannot be null");

	List<String> completions = null;
	try {
		if (completer != null) {
			completions = completer.onTabComplete(sender, this, alias, args);
		}
		if (completions == null && executor instanceof TabCompleter) {
			completions = ((TabCompleter) executor).onTabComplete(sender, this, alias, args);
		}
	} catch (Throwable ex) {
		StringBuilder message = new StringBuilder();
		message.append("Unhandled exception during tab completion for command '/").append(alias).append(' ');
		for (String arg : args) {
			message.append(arg).append(' ');
		}
		message.deleteCharAt(message.length() - 1).append("' in plugin ")
				.append(owningPlugin.getDescription().getFullName());
		throw new CommandException(message.toString(), ex);
	}

	if (completions == null) {
		return super.tabComplete(sender, alias, args);
	}
	return completions;
}
 
開發者ID:HuliPvP,項目名稱:Chambers,代碼行數:31,代碼來源:BukkitCommand.java

示例8: registerCommand

import org.bukkit.command.TabCompleter; //導入依賴的package包/類
private void registerCommand(String command, CommandExecutor executor, TabCompleter tabCompleter) {
	if (tabCompleter == null && !(executor instanceof TabCompleter))
		throw new UnsupportedOperationException();
	
	PluginCommand commandObject = this.getCommand(command);
	if (commandObject == null) return;
	
	commandObject.setExecutor(executor);
	commandObject.setTabCompleter(tabCompleter != null ? tabCompleter : (TabCompleter) executor);
}
 
開發者ID:2008Choco,項目名稱:DragonEggDrop,代碼行數:11,代碼來源:DragonEggDrop.java

示例9: onEnable

import org.bukkit.command.TabCompleter; //導入依賴的package包/類
@Override
public void onEnable() {
    instance = this;
    cfg = new Configuration(this);
    cfg.load();
    i18n = new I18n(this, cfg.language);
    commandHandler = new CommandHandler(this, i18n);
    getCommand("nyaautils").setExecutor(commandHandler);
    getCommand("nyaautils").setTabCompleter((TabCompleter) commandHandler);
    lpListener = new LootProtectListener(this);
    dpListener = new DropProtectListener(this);
    dsListener = new DamageStatListener(this);
    elytraEnhanceListener = new ElytraEnhanceListener(this);
    teleport = new Teleport(this);
    exhibitionListener = new ExhibitionListener(this);
    mailboxListener = new MailboxListener(this);
    fuelManager = new FuelManager(this);
    timerManager = new TimerManager(this);
    timerListener = new TimerListener(this);
    worldEditPlugin = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit");
    realmListener = new RealmListener(this);
    try {
        systemBalance = NyaaComponent.get(ISystemBalance.class);
    } catch (ComponentNotAvailableException e) {
        systemBalance = null;
    }
    ess = (IEssentials) getServer().getPluginManager().getPlugin("Essentials");
    particleTask = new ParticleTask(this);
    particleListener = new ParticleListener(this);
    signEditListener = new SignEditListener(this);
}
 
開發者ID:NyaaCat,項目名稱:NyaaUtils,代碼行數:32,代碼來源:NyaaUtils.java

示例10: tabComplete

import org.bukkit.command.TabCompleter; //導入依賴的package包/類
@Override
public List<String> tabComplete( CommandSender sender, String alias, String[] args )
        throws CommandException, IllegalArgumentException {
    checkNotNull( sender );
    checkNotNull( alias );
    checkNotNull( args );

    List<String> completions = null;
    try {
        // if we have a completer, get the completions from it
        if ( completer != null ) {
            completions = completer.onTabComplete( sender, this, alias, args );
        }
        // if not succeeded, try bukkits completer
        if ( completions == null && executor instanceof TabCompleter ) {
            completions = ( (TabCompleter) executor ).onTabComplete( sender, this, alias, args );
        }
    } catch ( Throwable ex ) {
        StringBuilder message = new StringBuilder();
        message.append( "Unhandled exception during tab completion for command '/" ).append( alias ).append( ' ' );
        for ( String arg : args ) {
            message.append( arg ).append( ' ' );
        }
        message.deleteCharAt( message.length() - 1 ).append( "' in plugin " )
                .append( plugin.getDescription().getFullName() );
        throw new CommandException( message.toString(), ex );
    }

    if ( completions == null ) {
        return super.tabComplete( sender, alias, args );
    }
    return completions;
}
 
開發者ID:Devintia,項目名稱:Commons,代碼行數:34,代碼來源:CommandWrapper.java

示例11: inject

import org.bukkit.command.TabCompleter; //導入依賴的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

示例12: uninject

import org.bukkit.command.TabCompleter; //導入依賴的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

示例13: newCommand

import org.bukkit.command.TabCompleter; //導入依賴的package包/類
/**
 * コマンド登録メソッド
 *
 * @param pluginInstance  プラグイン
 * @param prefix          prefix
 * @param commandName     コマンド名
 * @param aliases         コマンドの他の名前
 * @param using           コマンドの使用方法
 * @param description     コマンドの説明文
 * @param permission      コマンドの権限
 * @param commandExecutor コマンドの実行クラスのインスタンス
 * @param tabInstance     タブ補間のインスタンス
 */
public static void newCommand(Plugin pluginInstance, String prefix, String commandName, List<String> aliases, String using, String description, String permission, CommandExecutor commandExecutor, TabCompleter tabInstance) {
    CommandFactory factory = new CommandFactory(pluginInstance, commandName);
    factory.setAliases((aliases == null ? new ArrayList<>(0) : aliases));
    factory.setDescription((description == null ? "" : description));
    factory.setUsage((using == null ? "" : using));
    factory.setPermission((permission == null ? "" : permission));
    if (commandExecutor != null) {
        factory.setExecutor(commandExecutor);
    }
    if (tabInstance != null) {
        factory.setTabCompleter(tabInstance);
    }
    factory.register();
}
 
開發者ID:niwaniwa,項目名稱:WhiteEggCore,代碼行數:28,代碼來源:CommandFactory.java

示例14: getTabCompleter

import org.bukkit.command.TabCompleter; //導入依賴的package包/類
@Override
public TabCompleter getTabCompleter() {
    return new AbstractTabCompleter() {
        @Override
        protected List<String> getTabList(CommandSender commandSender, String term) {
            return CONFIGS;
        }
    };
}
 
開發者ID:rlf,項目名稱:uSkyBlock,代碼行數:10,代碼來源:ConfigGUICommand.java

示例15: tabComplete

import org.bukkit.command.TabCompleter; //導入依賴的package包/類
@Override
public List<String> tabComplete(CommandSender sender, String alias,
		String[] args) throws CommandException,
		IllegalArgumentException {
	Validate.notNull(sender, "Sender cannot be null");
	Validate.notNull(args, "Arguments cannot be null");
	Validate.notNull(alias, "Alias cannot be null");

	List<String> completions = null;
	try {
		if (completer != null) {
			completions = completer.onTabComplete(sender, this, alias,
					args);
		}
		if (completions == null && executor instanceof TabCompleter) {
			completions = ((TabCompleter) executor).onTabComplete(
					sender, this, alias, args);
		}
	} catch (Throwable ex) {
		StringBuilder message = new StringBuilder();
		message.append(
				"Unhandled exception during tab completion for command '/")
				.append(alias).append(' ');
		for (String arg : args) {
			message.append(arg).append(' ');
		}
		message.deleteCharAt(message.length() - 1)
				.append("' in plugin ")
				.append(owningPlugin.getDescription().getFullName());
		throw new CommandException(message.toString(), ex);
	}

	if (completions == null) {
		return super.tabComplete(sender, alias, args);
	}
	return completions;
}
 
開發者ID:skavrx,項目名稱:PartyLobby,代碼行數:38,代碼來源:CommandFramework.java


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