Skip to content

Commit

Permalink
refactor: add/improve some constructors in AbstractStellarCommand & S…
Browse files Browse the repository at this point in the history
…tellarCommand
  • Loading branch information
StillLutto committed Nov 30, 2024
1 parent a67a3b6 commit 1db2682
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 6 additions & 1 deletion api/src/main/kotlin/com/undefined/stellar/StellarCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ val registrars = mapOf(
"1.20.6" to com.undefined.stellar.v1_20_6.BrigadierCommandRegistrar
)

class StellarCommand(name: String, vararg aliases: String) : AbstractStellarCommand<StellarCommand>(name) {
class StellarCommand(name: String, description: String = "", vararg aliases: String = arrayOf()) : AbstractStellarCommand<StellarCommand>(name, description) {

constructor(name: String, vararg aliases: String) : this(name, "", aliases = aliases)
constructor(name: String, aliases: List<String>) : this(name, "", aliases = aliases.toTypedArray())

init {
this.aliases.addAll(aliases)
}
Expand All @@ -30,4 +34,5 @@ class StellarCommand(name: String, vararg aliases: String) : AbstractStellarComm
return registrar.parseAndReturnCancelled(sender, input)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ import org.bukkit.entity.Player
import org.bukkit.plugin.java.JavaPlugin

@Suppress("UNCHECKED_CAST")
abstract class AbstractStellarCommand<T>(val name: String) : SubCommandHandler() {
abstract class AbstractStellarCommand<T>(val name: String, var description: String = "", var usage: String = "") : SubCommandHandler() {

override fun getBase(): AbstractStellarCommand<*> = this

val aliases: MutableList<String> = mutableListOf()
var description: String = ""
var usage: String = ""
val failureMessages: MutableList<Component> = mutableListOf()
val globalFailureMessages: MutableList<Component> = mutableListOf()
val failureExecutions: MutableList<CustomStellarExecution<*, Any>> = mutableListOf()
Expand Down

0 comments on commit 1db2682

Please sign in to comment.