mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-07 16:49:12 +00:00
Overload valid_arg_length
This commit is contained in:
@@ -4,16 +4,17 @@ import org.apollo.game.model.entity.Player
|
|||||||
* Checks whether the amount of arguments provided is correct, sending the player the specified
|
* Checks whether the amount of arguments provided is correct, sending the player the specified
|
||||||
* message if not.
|
* message if not.
|
||||||
*/
|
*/
|
||||||
fun valid_arg_length(args: Array<String>, length: Any, player: Player, message: String): Boolean {
|
fun valid_arg_length(args: Array<String>, length: IntRange, player: Player, message: String): Boolean {
|
||||||
val valid = when (length) {
|
val valid = length.contains(args.size)
|
||||||
is Int -> length == args.size
|
|
||||||
is IntRange -> length.contains(args.size)
|
|
||||||
else -> {
|
|
||||||
throw IllegalArgumentException("length must be one of the following: Int, IntRange")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
player.sendMessage(message)
|
player.sendMessage(message)
|
||||||
}
|
}
|
||||||
return valid
|
return valid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the amount of arguments provided is correct, sending the player the specified
|
||||||
|
* message if not.
|
||||||
|
*/
|
||||||
|
fun valid_arg_length(args: Array<String>, length: Int, player: Player, message: String)
|
||||||
|
= valid_arg_length(args, IntRange(length, length), player, message)
|
||||||
Reference in New Issue
Block a user