Tab completion

This commit is contained in:
ZeroEpoch1969
2019-01-28 21:57:41 -07:00
parent d7931793f1
commit 5b2334c60f
25 changed files with 632 additions and 22 deletions

View File

@ -1,9 +1,8 @@
package me.totalfreedom.totalfreedommod.command;
import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User;
import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import lombok.Getter;
@ -28,7 +27,6 @@ public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
public static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
public static final String PLAYER_NOT_FOUND = ChatColor.GRAY + "Player not found!";
//
@Getter
@ -74,13 +72,27 @@ public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod
}
}
protected abstract boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole);
/*@Override
public List<String> tabComplete(CommandSender sender, Command command, String alias, String[] args)
{
return Arrays.asList("x", "d");
return null;
}*/
// Doesn't need to do any starts-with checks
protected List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) {
return null;
}
@Override
public List<String> tabComplete(CommandSender sender, Command command, String alias, String[] args)
{
List<String> options = getTabCompleteOptions(sender, command, alias, args);
if (options == null) {
return null;
}
return StringUtil.copyPartialMatches(args[args.length - 1], options, Lists.<String>newArrayList());
}
protected abstract boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole);
protected void checkConsole()
{