From c59bf2569a42f7193f59cd813393628654b7a6d7 Mon Sep 17 00:00:00 2001 From: grzybeek Date: Sat, 18 Jun 2022 17:18:01 +0200 Subject: [PATCH] Add %boosters_active_list% placeholder which displays active boosters names comma separated. --- .../com/willfp/boosters/boosters/Booster.kt | 20 +++++++++++++++++++ .../core-plugin/src/main/resources/lang.yml | 1 + 2 files changed, 21 insertions(+) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/boosters/Booster.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/boosters/Booster.kt index 3aec029..146426f 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/boosters/Booster.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/boosters/Booster.kt @@ -196,6 +196,26 @@ class Booster( "${hh}:${mm}:${ss}" } ) + + PlaceholderManager.registerPlaceholder( + PlayerlessPlaceholder( + plugin, + "active_list", + ) { + var activeList = mutableListOf() + + for(active in Bukkit.getServer().activeBoosters){ + activeList.add(active.booster.name) + } + + var outputString = plugin.langYml.getString("no-currently-active-list").formatEco(formatPlaceholders = false) + if (activeList.size > 0) { + outputString = activeList.joinToString(", ") + } + + outputString + } + ) } override fun equals(other: Any?): Boolean { diff --git a/eco-core/core-plugin/src/main/resources/lang.yml b/eco-core/core-plugin/src/main/resources/lang.yml index 868c958..b536f0a 100644 --- a/eco-core/core-plugin/src/main/resources/lang.yml +++ b/eco-core/core-plugin/src/main/resources/lang.yml @@ -18,4 +18,5 @@ messages: cannot-transmit: "&cYou can't transmit here!" no-currently-active: "&cNot Active!" +no-currently-active-list: "&cThere isn't any booster active!" active-placeholder: "&fThanks %player% &ffor activating %booster%&f!"