Add active_ids_list placeholder

This commit is contained in:
addstar
2023-12-26 16:20:45 +11:00
parent eef658aee3
commit 13cf5d8b16
3 changed files with 24 additions and 3 deletions

View File

@@ -6,7 +6,6 @@ import com.willfp.boosters.boosters.ActivatedBooster
import com.willfp.boosters.boosters.Booster
import com.willfp.boosters.boosters.Boosters
import com.willfp.boosters.boosters.activateBooster
import com.willfp.eco.core.data.ServerProfile
import com.willfp.eco.core.data.profile
import org.bukkit.Bukkit
import org.bukkit.OfflinePlayer
@@ -53,10 +52,10 @@ fun Player.activateBooster(booster: Booster): Boolean {
Bukkit.broadcastMessage(activationMessage)
}
for (expiryCommand in booster.activationCommands) {
for (activationCommand in booster.activationCommands) {
Bukkit.dispatchCommand(
Bukkit.getConsoleSender(),
expiryCommand.replace("%player%", booster.active?.player?.name ?: "")
activationCommand.replace("%player%", this.name ?: "")
)
}

View File

@@ -222,6 +222,27 @@ class Booster(
outputString
}
)
PlaceholderManager.registerPlaceholder(
PlayerlessPlaceholder(
plugin,
"active_ids_list",
) {
var activeList = mutableListOf<String>()
for (active in Bukkit.getServer().activeBoosters) {
activeList.add(active.booster.getID())
}
var outputString =
plugin.langYml.getString("no-currently-active-ids-list").formatEco(formatPlaceholders = false)
if (activeList.size > 0) {
outputString = activeList.joinToString(",")
}
outputString
}
)
}
override fun getID(): String {

View File

@@ -16,4 +16,5 @@ messages:
no-currently-active: "&cNot Active!"
no-currently-active-list: "&cThere isn't any booster active!"
no-currently-active-ids-list: "None"
active-placeholder: "&fThanks %player% &ffor activating %booster%&f!"