Merge pull request #38 from AddstarMC/master
Add active_ids_list placeholder and fix activation command replacement
This commit is contained in:
@@ -6,7 +6,6 @@ import com.willfp.boosters.boosters.ActivatedBooster
|
|||||||
import com.willfp.boosters.boosters.Booster
|
import com.willfp.boosters.boosters.Booster
|
||||||
import com.willfp.boosters.boosters.Boosters
|
import com.willfp.boosters.boosters.Boosters
|
||||||
import com.willfp.boosters.boosters.activateBooster
|
import com.willfp.boosters.boosters.activateBooster
|
||||||
import com.willfp.eco.core.data.ServerProfile
|
|
||||||
import com.willfp.eco.core.data.profile
|
import com.willfp.eco.core.data.profile
|
||||||
import org.bukkit.Bukkit
|
import org.bukkit.Bukkit
|
||||||
import org.bukkit.OfflinePlayer
|
import org.bukkit.OfflinePlayer
|
||||||
@@ -53,10 +52,10 @@ fun Player.activateBooster(booster: Booster): Boolean {
|
|||||||
Bukkit.broadcastMessage(activationMessage)
|
Bukkit.broadcastMessage(activationMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (expiryCommand in booster.activationCommands) {
|
for (activationCommand in booster.activationCommands) {
|
||||||
Bukkit.dispatchCommand(
|
Bukkit.dispatchCommand(
|
||||||
Bukkit.getConsoleSender(),
|
Bukkit.getConsoleSender(),
|
||||||
expiryCommand.replace("%player%", booster.active?.player?.name ?: "")
|
activationCommand.replace("%player%", this.name ?: "")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -222,6 +222,27 @@ class Booster(
|
|||||||
outputString
|
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 {
|
override fun getID(): String {
|
||||||
|
|||||||
@@ -16,4 +16,5 @@ messages:
|
|||||||
|
|
||||||
no-currently-active: "&cNot Active!"
|
no-currently-active: "&cNot Active!"
|
||||||
no-currently-active-list: "&cThere isn't any booster 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!"
|
active-placeholder: "&fThanks %player% &ffor activating %booster%&f!"
|
||||||
|
|||||||
Reference in New Issue
Block a user