Skip to content

Commit a6b7fe5

Browse files
committed
StringArrayArgument now is deprecated.
Signed-off-by: Pavel Erokhin (MairwunNx) <MairwunNx@gmail.com>
1 parent 7947a61 commit a6b7fe5

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/main/kotlin/com/mairwunnx/projectessentials/core/api/v1/commands/arguments/StringArrayArgument.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,25 @@ import java.util.concurrent.CompletableFuture
1212
/**
1313
* String argument type class, for commands.
1414
*
15+
* **It probably not work, this must not use by other modules!**
16+
*
17+
* *Will removed in next major version.*
18+
*
1519
* @param array array with accepted values for command.
1620
* @since 2.0.0-SNAPSHOT.1.
1721
*/
22+
@Deprecated("Use custom arguments, this unified argument type and may not work.")
1823
class StringArrayArgument(private val array: List<String>) : ArgumentType<String> {
1924
override fun parse(reader: StringReader): String {
2025
val value = reader.readUnquotedString()
2126
return if (value in array) {
2227
array.find { it == value } ?: value
23-
} else {
24-
throw IllegalArgumentException("No value found for name $value in array.")
25-
}
28+
} else throw IllegalArgumentException("No value found for name $value in array.")
2629
}
2730

2831
override fun <S> listSuggestions(
29-
context: CommandContext<S>,
30-
builder: SuggestionsBuilder
31-
): CompletableFuture<Suggestions> = ISuggestionProvider.suggest(array.sorted(), builder)
32+
context: CommandContext<S>, builder: SuggestionsBuilder
33+
): CompletableFuture<Suggestions> = ISuggestionProvider.suggest(array, builder)
3234

3335
companion object {
3436
/**

0 commit comments

Comments
 (0)