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

View File

@@ -52,6 +52,13 @@ fun Player.activateBooster(booster: Booster): Boolean {
Bukkit.broadcastMessage(activationMessage)
}
for (expiryCommand in booster.activationCommands) {
Bukkit.dispatchCommand(
Bukkit.getConsoleSender(),
expiryCommand.replace("%player%", booster.active?.player?.name ?: "")
)
}
ServerProfile.load().write(
booster.expiryTimeKey,
(booster.duration.toDouble() * 50) + System.currentTimeMillis()

View File

@@ -36,6 +36,13 @@ class BoostersPlugin : LibReforgePlugin(2036, 14269, "&e") {
Bukkit.broadcastMessage(expiryMessage)
}
for (expiryCommand in booster.expiryMessages) {
Bukkit.dispatchCommand(
Bukkit.getConsoleSender(),
expiryCommand.replace("%player%", booster.active?.player?.name ?: "")
)
}
Bukkit.getServer().expireBooster(booster)
}
}

View File

@@ -89,6 +89,10 @@ class Booster(
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 {
return ItemStackBuilder(Items.lookup(config.getString("gui.item")))
.setDisplayName(config.getFormattedString("gui.name"))

View File

@@ -7,6 +7,9 @@ boosters:
args:
multiplier: 1.5
conditions: []
commands:
activation: []
expiry: []
messages:
activation:
- ""
@@ -45,6 +48,9 @@ boosters:
args:
multiplier: 2
conditions: []
commands:
activation: []
expiry: []
messages:
activation:
- ""
@@ -83,6 +89,9 @@ boosters:
args:
multiplier: 2
conditions: []
commands:
activation: []
expiry: []
messages:
activation:
- ""