Improves tab-completion when loading books with spaces
This commit is contained in:
@@ -13,7 +13,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -139,22 +138,14 @@ public class CommandLoad implements TabExecutor {
|
||||
protected List<String> doTabCompletion(@NotNull CommandSender sender, @NotNull String[] arguments, boolean loadPublic) {
|
||||
int argumentCount = arguments.length;
|
||||
if (argumentCount == 1) {
|
||||
//Return list of books
|
||||
return TabCompletionHelper.filterMatchingContains(BooksWithoutBorders.getAvailableBooks(sender, loadPublic),
|
||||
arguments[0]);
|
||||
} else if (argumentCount == 2) {
|
||||
//Number of copies
|
||||
return TabCompletionHelper.filterMatchingStartsWith(TabCompletionTypeHelper.getBooleansAndNumbers(1, 3), arguments[1]);
|
||||
} else if (argumentCount == 3) {
|
||||
//Signed
|
||||
try {
|
||||
Integer.parseInt(arguments[1]);
|
||||
return TabCompletionHelper.filterMatchingStartsWith(TabCompletionTypeHelper.getBooleans(), arguments[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return TabCompletionHelper.filterMatchingContains(BooksWithoutBorders.getAvailableBooks(sender, loadPublic), arguments[0]);
|
||||
} else if (isBoolean(arguments[argumentCount - 2])) {
|
||||
return List.of();
|
||||
} else if (isInt(arguments[argumentCount - 2])) {
|
||||
return TabCompletionHelper.filterMatchingStartsWith(TabCompletionTypeHelper.getBooleans(), arguments[argumentCount - 1]);
|
||||
} else {
|
||||
return TabCompletionHelper.filterMatchingStartsWith(TabCompletionTypeHelper.getBooleansAndNumbers(1, 3), arguments[argumentCount - 1]);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user