9
0
mirror of https://github.com/Auxilor/EcoBits.git synced 2025-12-19 15:09:19 +00:00
This commit is contained in:
Auxilor
2023-05-02 15:44:31 +01:00
parent 55af7fac86
commit 93c4a66bf4

View File

@@ -13,7 +13,7 @@ import org.bukkit.util.StringUtil
class CommandBalance(
plugin: EcoPlugin,
currency: Currency? = null
private val currency: Currency? = null
) : Subcommand(
plugin,
"balance",
@@ -21,12 +21,14 @@ class CommandBalance(
true
) {
override fun onExecute(player: Player, args: List<String>) {
if (this.currency == null) {
if (args.isEmpty()) {
player.sendMessage(plugin.langYml.getMessage("must-specify-currency"))
return
}
}
val currency = Currencies.getByID(args[0].lowercase())
val currency = this.currency ?: Currencies.getByID(args[0].lowercase())
if (currency == null) {
player.sendMessage(plugin.langYml.getMessage("invalid-currency"))
@@ -43,6 +45,7 @@ class CommandBalance(
override fun tabComplete(sender: CommandSender, args: List<String>): List<String> {
val completions = mutableListOf<String>()
if (this.currency == null) {
if (args.isEmpty()) {
Currencies.values().map { it.id }
}
@@ -54,6 +57,7 @@ class CommandBalance(
completions
)
}
}
return completions
}