Added %boosters_active% and %boosters_active_player% placeholders

This commit is contained in:
Auxilor
2022-02-13 15:52:56 +00:00
parent 56b70ed59d
commit 498e6f3058
3 changed files with 33 additions and 6 deletions
@@ -31,7 +31,7 @@ class BoostersPlugin : LibReforgePlugin(0, 14269, "&e") {
.formatEco(formatPlaceholders = false) .formatEco(formatPlaceholders = false)
} else { } else {
return@PlaceholderEntry this.langYml.getString("active-placeholder") return@PlaceholderEntry this.langYml.getString("active-placeholder")
.replace("%player%", Bukkit.getOfflinePlayer(booster.player).savedDisplayName) .replace("%player%", booster.player.savedDisplayName)
.replace("%booster%", booster.booster.name) .replace("%booster%", booster.booster.name)
.formatEco(formatPlaceholders = false) .formatEco(formatPlaceholders = false)
} }
@@ -40,6 +40,28 @@ class BoostersPlugin : LibReforgePlugin(0, 14269, "&e") {
) )
) )
PlaceholderManager.registerPlaceholder(
PlaceholderEntry(
this,
"active",
{
BoosterUtils.getActiveBooster()?.booster?.id ?: ""
},
false
)
)
PlaceholderManager.registerPlaceholder(
PlaceholderEntry(
this,
"active_player",
{
BoosterUtils.getActiveBooster()?.player?.savedDisplayName ?: ""
},
false
)
)
this.registerHolderProvider { ListUtils.toSingletonList(BoosterUtils.getActiveBooster()?.booster) } this.registerHolderProvider { ListUtils.toSingletonList(BoosterUtils.getActiveBooster()?.booster) }
} }
@@ -12,9 +12,11 @@ import com.willfp.eco.util.formatEco
import com.willfp.libreforge.Holder import com.willfp.libreforge.Holder
import com.willfp.libreforge.conditions.Conditions import com.willfp.libreforge.conditions.Conditions
import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.Effects
import org.bukkit.Bukkit
import org.bukkit.OfflinePlayer
import org.bukkit.entity.Player import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack import org.bukkit.inventory.ItemStack
import java.util.UUID import java.util.*
/* /*
Stored externally to fix the weirdest bug of all time, that I don't understand. Stored externally to fix the weirdest bug of all time, that I don't understand.
@@ -104,5 +106,8 @@ class Booster(
data class ActivatedBooster( data class ActivatedBooster(
val booster: Booster, val booster: Booster,
val player: UUID private val uuid: UUID
) ) {
val player: OfflinePlayer
get() = Bukkit.getOfflinePlayer(uuid)
}
@@ -1,8 +1,8 @@
package com.willfp.boosters.gui package com.willfp.boosters.gui
import com.willfp.boosters.BoosterUtils
import com.willfp.boosters.BoostersPlugin import com.willfp.boosters.BoostersPlugin
import com.willfp.boosters.activateBooster import com.willfp.boosters.activateBooster
import com.willfp.boosters.activeBooster
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.eco.core.config.updating.ConfigUpdater import com.willfp.eco.core.config.updating.ConfigUpdater
@@ -23,7 +23,7 @@ object BoosterGUI {
return SlotHandler { event, _, _ -> return SlotHandler { event, _, _ ->
val player = event.whoClicked.tryAsPlayer() ?: return@SlotHandler val player = event.whoClicked.tryAsPlayer() ?: return@SlotHandler
if (activeBooster != null) { if (BoosterUtils.getActiveBooster() != null) {
player.sendMessage(plugin.langYml.getMessage("already-active")) player.sendMessage(plugin.langYml.getMessage("already-active"))
player.playSound( player.playSound(
player.location, player.location,