Added amount to /boosters give

This commit is contained in:
Auxilor
2022-02-11 09:24:48 +00:00
parent e7b9b0f31c
commit 91e5140c6f
2 changed files with 25 additions and 2 deletions

View File

@@ -51,7 +51,7 @@ class Booster(
return ItemStackBuilder(Items.lookup(config.getString("gui.item")))
.setDisplayName(config.getFormattedString("gui.name"))
.addLoreLines(
config.getFormattedStrings("gui.lore", StringUtils.FormatOption.WITHOUT_PLACEHOLDERS)
config.getStrings("gui.lore")
.map { it.replace("%amount%", player.getAmountOfBooster(this).toString()) }
.formatEco(player)
)

View File

@@ -36,6 +36,12 @@ class CommandGive(plugin: EcoPlugin) :
return
}
var amount = 1
if (args.size >= 3) {
amount = args[2].toIntOrNull() ?: amount
}
this.plugin.scheduler.runAsync {
@Suppress("DEPRECATION")
val player = Bukkit.getOfflinePlayer(args[0])
@@ -45,13 +51,14 @@ class CommandGive(plugin: EcoPlugin) :
}
this.plugin.scheduler.run {
player.setAmountOfBooster(booster, player.getAmountOfBooster(booster) + 1)
player.setAmountOfBooster(booster, player.getAmountOfBooster(booster) + amount)
}
sender.sendMessage(
plugin.langYml.getMessage("gave-booster", StringUtils.FormatOption.WITHOUT_PLACEHOLDERS)
.replace("%player%", player.name ?: return@runAsync)
.replace("%booster%", booster.id)
.replace("%amount%", amount.toString())
)
}
}
@@ -77,6 +84,22 @@ class CommandGive(plugin: EcoPlugin) :
return completions
}
if (args.size == 3) {
StringUtil.copyPartialMatches(
args[1],
listOf(
"1",
"2",
"3",
"4",
"5",
"10"
),
completions
)
return completions
}
return emptyList()
}
}