Skip to content

Commit

Permalink
set 'text' argument as optional in setsign command
Browse files Browse the repository at this point in the history
  • Loading branch information
apyrr committed Nov 15, 2022
1 parent c8e3f00 commit 283f178
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/main/kotlin/me/apyr/chatemotes/commands/SetSignCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.bukkit.event.block.SignChangeEvent
class SetSignCommand : ChatEmotesCommand {
override val name: String = "setsign"
override val description: String = "modify a line on the sign"
override val usage: String = "<1-4> <text>"
override val usage: String = "<1-4> [text]"

override fun onCommand(sender: CommandSender, args: List<String>) {
if (sender !is Player) {
Expand All @@ -24,7 +24,6 @@ class SetSignCommand : ChatEmotesCommand {
val line: Int = (checkArgument(args.getOrNull(0)).toIntOrNull() ?: 1)
.coerceAtLeast(1)
.coerceAtMost(4)
checkArgument(args.getOrNull(1))
val text: String = args.drop(1).joinToString(" ")

val sign: Block = sender.getTargetBlock(null, 5)
Expand Down Expand Up @@ -55,7 +54,7 @@ class SetSignCommand : ChatEmotesCommand {
override fun onTabComplete(sender: CommandSender, args: List<String>): List<String> {
return when {
args.size == 1 && args[0].isEmpty() -> listOf("<1-4>")
args.size == 2 && args[1].isEmpty() -> listOf("<text>")
args.size == 2 && args[1].isEmpty() -> listOf("[text]")
else -> emptyList()
}
}
Expand Down

0 comments on commit 283f178

Please sign in to comment.