Removes some redundancy between tab completers
This commit is contained in:
@ -1,10 +1,8 @@
|
||||
package net.knarcraft.paidsigns.command;
|
||||
|
||||
import net.knarcraft.paidsigns.utility.TabCompleteHelper;
|
||||
import net.knarcraft.paidsigns.utility.Tokenizer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -14,7 +12,7 @@ import java.util.List;
|
||||
/**
|
||||
* The tab completer for the add paid sign condition command
|
||||
*/
|
||||
public class AddConditionTabCompleter implements TabCompleter {
|
||||
public class AddConditionTabCompleter extends TokenizedTabCompleter {
|
||||
|
||||
private List<String> lineIndices;
|
||||
private List<String> stringsToMatch;
|
||||
@ -25,12 +23,10 @@ public class AddConditionTabCompleter implements TabCompleter {
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias,
|
||||
@NotNull String[] args) {
|
||||
super.onTabComplete(sender, command, alias, args);
|
||||
if (lineIndices == null) {
|
||||
initializeValues();
|
||||
}
|
||||
|
||||
List<String> arguments = Tokenizer.tokenize(String.join(" ", args));
|
||||
int argumentSize = args[args.length - 1].isEmpty() ? arguments.size() : arguments.size() - 1;
|
||||
if (argumentSize < 1) {
|
||||
return TabCompleteHelper.getPaidSignNames();
|
||||
} else if (argumentSize < 2) {
|
||||
|
Reference in New Issue
Block a user