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