org.bukkit.command.TabCompleter Java Examples

The following examples show how to use org.bukkit.command.TabCompleter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CombatLogX.java    From CombatLogX with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void registerCommand(String commandName, CommandExecutor executor, String description, String usage, String... aliases) {
    PluginCommand command = getCommand(commandName);
    if(command == null) {
        forceRegisterCommand(commandName, executor, description, usage, aliases);
        return;
    }
    command.setExecutor(executor);

    if(executor instanceof TabCompleter) {
        TabCompleter completer = (TabCompleter) executor;
        command.setTabCompleter(completer);
    }

    if(executor instanceof Listener) {
        Listener listener = (Listener) executor;
        PluginManager manager = Bukkit.getPluginManager();
        manager.registerEvents(listener, this);
    }
}
 
Example #2
Source File: BukkitCommand.java    From intake with GNU Lesser General Public License v3.0 5 votes vote down vote up
public BukkitCommand(
    Plugin plugin, CommandExecutor executor, TabCompleter completer, CommandMapping command) {
  super(
      command.getPrimaryAlias(),
      command.getDescription().getShortDescription(),
      "/" + command.getPrimaryAlias() + " " + command.getDescription().getUsage(),
      Lists.newArrayList(command.getAllAliases()));
  this.plugin = plugin;
  this.executor = executor;
  this.completer = completer;
  this.permissions = command.getDescription().getPermissions();
  super.setPermission(Joiner.on(';').join(permissions));
}
 
Example #3
Source File: CommandMapUtil.java    From helper with MIT License 5 votes vote down vote up
/**
 * Registers a CommandExecutor with the server
 *
 * @param plugin the plugin instance
 * @param command the command instance
 * @param permission the command permission
 * @param permissionMessage the message sent when the sender doesn't the required permission
 * @param description the command description
 * @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, String permission, String permissionMessage, String description, @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());
            if (permission != null) {
               cmd.setPermission(permission);
               if (permissionMessage != null) {
                   cmd.setPermissionMessage(permissionMessage);
               }
            }
            if (description != null) {
                cmd.setDescription(description);
            }

            cmd.setExecutor(command);
            if (command instanceof TabCompleter) {
                cmd.setTabCompleter((TabCompleter) command);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return command;
}
 
Example #4
Source File: ConfigCommand.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
@Override
public TabCompleter getTabCompleter() {
    return new AbstractTabCompleter() {
        @Override
        protected List<String> getTabList(CommandSender commandSender, String term) {
            return CONFIGS;
        }
    };
}
 
Example #5
Source File: ShopSubCommand.java    From ShopChest with MIT License 4 votes vote down vote up
public ShopSubCommand(String name, boolean playerCommand, CommandExecutor executor, TabCompleter tabCompleter) {
    this.name = name;
    this.playerCommand = playerCommand;
    this.executor = executor;
    this.tabCompleter = tabCompleter;
}
 
Example #6
Source File: CommandWrapperImpl.java    From NovaGuilds with GNU General Public License v3.0 4 votes vote down vote up
@Override
public TabCompleter getTabCompleter() {
	return tabCompleter;
}
 
Example #7
Source File: CommandWrapperImpl.java    From NovaGuilds with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setTabCompleter(TabCompleter tabCompleter) {
	this.tabCompleter = tabCompleter;
}
 
Example #8
Source File: Command.java    From NovaGuilds with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setTabCompleter(TabCompleter tabCompleter) {
	throw new IllegalArgumentException("Not allowed for built in commands");
}
 
Example #9
Source File: GetIslandDataCommand.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
@Override
public TabCompleter getTabCompleter() {
    return tabCompleter;
}
 
Example #10
Source File: ImportCommand.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
@Override
public TabCompleter getTabCompleter() {
    return completer;
}
 
Example #11
Source File: SetIslandDataCommand.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
@Override
public TabCompleter getTabCompleter() {
    return tabCompleter;
}
 
Example #12
Source File: AdminCommand.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
public AdminCommand(final uSkyBlock plugin, ConfirmHandler confirmHandler, AnimationHandler animationHandler) {
    super("usb", null, marktr("Ultimate SkyBlock Admin"));
    OnlinePlayerTabCompleter playerCompleter = new OnlinePlayerTabCompleter();
    TabCompleter challengeCompleter = new ChallengeTabCompleter();
    TabCompleter allPlayerCompleter = new AllPlayerTabCompleter(playerCompleter);
    TabCompleter biomeCompleter = new BiomeTabCompleter();
    addTab("oplayer", playerCompleter);
    addTab("player", allPlayerCompleter);
    addTab("island", allPlayerCompleter);
    addTab("leader", allPlayerCompleter);
    addTab("challenge", challengeCompleter);
    addTab("biome", biomeCompleter);
    addTab("rank", new RankTabCompleter(plugin));
    add(new ReloadCommand());
    add(new ImportCommand());
    add(new GenTopTenCommand(plugin));
    //add(new RegisterIslandToPlayerCommand());
    add(new AdminChallengeCommand(plugin));
    add(new OrphanCommand(plugin));
    add(new AdminIslandCommand(plugin, confirmHandler));
    add(new PurgeCommand(plugin));
    add(new GotoIslandCommand(plugin));
    add(new AbstractPlayerInfoCommand("info", "usb.admin.info", marktr("show player-information")) {
        @Override
        protected void doExecute(CommandSender sender, PlayerInfo playerInfo) {
            sender.sendMessage(playerInfo.toString());
        }
    });
    add(new FlatlandFixCommand(plugin));
    add(new DebugCommand(plugin));
    add(new WGCommand(plugin));
    add(new VersionCommand(plugin));
    add(new CooldownCommand(plugin));
    add(new PerkCommand(plugin));
    add(new LanguageCommand(plugin));
    add(new FlushCommand(plugin));
    add(new JobsCommand(plugin));
    add(new ConfigCommand(plugin));
    add(new DocumentCommand(plugin, "doc", "usb.admin.doc"));
    add(new RegionCommand(plugin, animationHandler));
    add(new SetMaintenanceCommand(plugin));
    add(new NBTCommand());
    add(new ProtectAllCommand(plugin));
    add(new ChunkCommand(plugin));
}
 
Example #13
Source File: Command.java    From NovaGuilds with GNU General Public License v3.0 3 votes vote down vote up
/**
 * The constructor
 *
 * @param permission     the permission
 * @param genericCommand the generic command string
 * @param usageMessage   the usage message
 * @param tabCompleter   tab completer instance
 * @param flags          command flags
 */
private Command(Class<? extends CommandExecutor> commandExecutorClass, Permission permission, String genericCommand, MessageWrapper usageMessage, TabCompleter tabCompleter, Flag... flags) {
	this.permission = permission;
	this.usageMessage = usageMessage;
	this.genericCommand = genericCommand;
	this.tabCompleter = tabCompleter;
	this.clazz = commandExecutorClass;
	Collections.addAll(this.flags, flags);
}
 
Example #14
Source File: CommandWrapper.java    From NovaGuilds with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Gets tab completer
 *
 * @return tab completer instance
 */
TabCompleter getTabCompleter();
 
Example #15
Source File: CommandWrapper.java    From NovaGuilds with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Sets the tab completer
 *
 * @param tabCompleter tab completer
 */
void setTabCompleter(TabCompleter tabCompleter);
 
Example #16
Source File: Command.java    From NovaGuilds with GNU General Public License v3.0 2 votes vote down vote up
/**
 * The constructor
 *
 * @param permission     the permission
 * @param genericCommand the generic command string
 * @param tabCompleter   tab completer instance
 * @param flags          command flags
 */
private Command(Class<? extends CommandExecutor> commandExecutorClass, Permission permission, String genericCommand, TabCompleter tabCompleter, Flag... flags) {
	this(commandExecutorClass, permission, genericCommand, null, tabCompleter, flags);
}