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.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -139,23 +138,15 @@ public class CommandLoad implements TabExecutor {
|
|||||||
protected List<String> doTabCompletion(@NotNull CommandSender sender, @NotNull String[] arguments, boolean loadPublic) {
|
protected List<String> doTabCompletion(@NotNull CommandSender sender, @NotNull String[] arguments, boolean loadPublic) {
|
||||||
int argumentCount = arguments.length;
|
int argumentCount = arguments.length;
|
||||||
if (argumentCount == 1) {
|
if (argumentCount == 1) {
|
||||||
//Return list of books
|
return TabCompletionHelper.filterMatchingContains(BooksWithoutBorders.getAvailableBooks(sender, loadPublic), arguments[0]);
|
||||||
return TabCompletionHelper.filterMatchingContains(BooksWithoutBorders.getAvailableBooks(sender, loadPublic),
|
} else if (isBoolean(arguments[argumentCount - 2])) {
|
||||||
arguments[0]);
|
return List.of();
|
||||||
} else if (argumentCount == 2) {
|
} else if (isInt(arguments[argumentCount - 2])) {
|
||||||
//Number of copies
|
return TabCompletionHelper.filterMatchingStartsWith(TabCompletionTypeHelper.getBooleans(), arguments[argumentCount - 1]);
|
||||||
return TabCompletionHelper.filterMatchingStartsWith(TabCompletionTypeHelper.getBooleansAndNumbers(1, 3), arguments[1]);
|
} else {
|
||||||
} else if (argumentCount == 3) {
|
return TabCompletionHelper.filterMatchingStartsWith(TabCompletionTypeHelper.getBooleansAndNumbers(1, 3), arguments[argumentCount - 1]);
|
||||||
//Signed
|
|
||||||
try {
|
|
||||||
Integer.parseInt(arguments[1]);
|
|
||||||
return TabCompletionHelper.filterMatchingStartsWith(TabCompletionTypeHelper.getBooleans(), arguments[2]);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merges all arguments to a string with spaces
|
* Merges all arguments to a string with spaces
|
||||||
|
Reference in New Issue
Block a user