Added activation/expiry commands

This commit is contained in:
Auxilor
2022-04-29 22:33:26 +01:00
parent 14bceadb12
commit 0b5ad55a21
4 changed files with 27 additions and 0 deletions
@@ -52,6 +52,13 @@ fun Player.activateBooster(booster: Booster): Boolean {
Bukkit.broadcastMessage(activationMessage) Bukkit.broadcastMessage(activationMessage)
} }
for (expiryCommand in booster.activationCommands) {
Bukkit.dispatchCommand(
Bukkit.getConsoleSender(),
expiryCommand.replace("%player%", booster.active?.player?.name ?: "")
)
}
ServerProfile.load().write( ServerProfile.load().write(
booster.expiryTimeKey, booster.expiryTimeKey,
(booster.duration.toDouble() * 50) + System.currentTimeMillis() (booster.duration.toDouble() * 50) + System.currentTimeMillis()
@@ -36,6 +36,13 @@ class BoostersPlugin : LibReforgePlugin(2036, 14269, "&e") {
Bukkit.broadcastMessage(expiryMessage) Bukkit.broadcastMessage(expiryMessage)
} }
for (expiryCommand in booster.expiryMessages) {
Bukkit.dispatchCommand(
Bukkit.getConsoleSender(),
expiryCommand.replace("%player%", booster.active?.player?.name ?: "")
)
}
Bukkit.getServer().expireBooster(booster) Bukkit.getServer().expireBooster(booster)
} }
} }
@@ -89,6 +89,10 @@ class Booster(
val expiryMessages: List<String> = config.getFormattedStrings("messages.expiry") val expiryMessages: List<String> = config.getFormattedStrings("messages.expiry")
val activationCommands: List<String> = config.getFormattedStrings("commands.activation")
val expiryCommands: List<String> = config.getFormattedStrings("commands.expiry")
fun getGuiItem(player: Player): ItemStack { fun getGuiItem(player: Player): ItemStack {
return ItemStackBuilder(Items.lookup(config.getString("gui.item"))) return ItemStackBuilder(Items.lookup(config.getString("gui.item")))
.setDisplayName(config.getFormattedString("gui.name")) .setDisplayName(config.getFormattedString("gui.name"))
@@ -7,6 +7,9 @@ boosters:
args: args:
multiplier: 1.5 multiplier: 1.5
conditions: [] conditions: []
commands:
activation: []
expiry: []
messages: messages:
activation: activation:
- "" - ""
@@ -45,6 +48,9 @@ boosters:
args: args:
multiplier: 2 multiplier: 2
conditions: [] conditions: []
commands:
activation: []
expiry: []
messages: messages:
activation: activation:
- "" - ""
@@ -83,6 +89,9 @@ boosters:
args: args:
multiplier: 2 multiplier: 2
conditions: [] conditions: []
commands:
activation: []
expiry: []
messages: messages:
activation: activation:
- "" - ""