Updated to eco placeholder system

This commit is contained in:
Auxilor
2022-04-17 13:16:36 +01:00
parent 380886934f
commit a3be5f1e20
2 changed files with 39 additions and 50 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ allprojects {
}
dependencies {
compileOnly 'com.willfp:eco:6.33.0'
compileOnly 'com.willfp:eco:6.30.0'
implementation 'com.willfp:libreforge:3.34.0'
compileOnly 'org.jetbrains:annotations:23.0.0'
@@ -9,8 +9,8 @@ import com.willfp.eco.core.data.ServerProfile
import com.willfp.eco.core.data.keys.PersistentDataKey
import com.willfp.eco.core.data.keys.PersistentDataKeyType
import com.willfp.eco.core.data.profile
import com.willfp.eco.core.integrations.placeholder.PlaceholderEntry
import com.willfp.eco.core.integrations.placeholder.PlaceholderManager
import com.willfp.eco.core.placeholder.PlayerlessPlaceholder
import com.willfp.eco.util.ListUtils
import com.willfp.eco.util.formatEco
import com.willfp.eco.util.savedDisplayName
@@ -73,77 +73,68 @@ class BoostersPlugin : LibReforgePlugin(2036, 14269, "&e") {
override fun handleEnableAdditional() {
PlaceholderManager.registerPlaceholder(
PlaceholderEntry(
PlayerlessPlaceholder(
this,
"booster_info",
{
val booster = activeBooster
if (booster == null) {
return@PlaceholderEntry this.langYml.getString("no-currently-active")
return@PlayerlessPlaceholder this.langYml.getString("no-currently-active")
.formatEco(formatPlaceholders = false)
} else {
return@PlaceholderEntry this.langYml.getString("active-placeholder")
return@PlayerlessPlaceholder this.langYml.getString("active-placeholder")
.replace("%player%", booster.player.savedDisplayName)
.replace("%booster%", booster.booster.name)
.formatEco(formatPlaceholders = false)
}
},
false
}
)
)
PlaceholderManager.registerPlaceholder(
PlaceholderEntry(
PlayerlessPlaceholder(
this,
"active",
{
) {
activeBooster?.booster?.id ?: ""
},
false
)
}
)
PlaceholderManager.registerPlaceholder(
PlaceholderEntry(
PlayerlessPlaceholder(
this,
"active_name",
{
"active_name"
) {
activeBooster?.booster?.name ?: ""
},
false
)
}
)
PlaceholderManager.registerPlaceholder(
PlaceholderEntry(
PlayerlessPlaceholder(
this,
"active_player",
{
) {
activeBooster?.player?.savedDisplayName ?: ""
},
false
)
}
)
PlaceholderManager.registerPlaceholder(
PlaceholderEntry(
PlayerlessPlaceholder(
this,
"seconds_remaining",
{
"seconds_remaining"
) {
secondsLeft.toString()
},
false
)
}
)
PlaceholderManager.registerPlaceholder(
PlaceholderEntry(
PlayerlessPlaceholder(
this,
"time_remaining",
{
"time_remaining"
) {
if (secondsLeft <= 0) {
return@PlaceholderEntry "00:00:00"
return@PlayerlessPlaceholder "00:00:00"
}
// if you've seen this code on the internet, no you haven't. shush
@@ -156,9 +147,7 @@ class BoostersPlugin : LibReforgePlugin(2036, 14269, "&e") {
val ss = (if (seconds < 10) "0" else "") + seconds
"${hh}:${mm}:${ss}"
},
false
)
}
)
this.registerHolderProvider { ListUtils.toSingletonList(activeBooster?.booster as Holder) }