diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/BoostersPlugin.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/BoostersPlugin.kt index a72548e..118e220 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/BoostersPlugin.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/BoostersPlugin.kt @@ -31,7 +31,7 @@ class BoostersPlugin : LibReforgePlugin(0, 14269, "&e") { .formatEco(formatPlaceholders = false) } else { return@PlaceholderEntry this.langYml.getString("active-placeholder") - .replace("%player%", Bukkit.getOfflinePlayer(booster.player).savedDisplayName) + .replace("%player%", booster.player.savedDisplayName) .replace("%booster%", booster.booster.name) .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) } } 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 3dddb31..2fc7f86 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 @@ -12,9 +12,11 @@ import com.willfp.eco.util.formatEco import com.willfp.libreforge.Holder import com.willfp.libreforge.conditions.Conditions import com.willfp.libreforge.effects.Effects +import org.bukkit.Bukkit +import org.bukkit.OfflinePlayer import org.bukkit.entity.Player 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. @@ -104,5 +106,8 @@ class Booster( data class ActivatedBooster( val booster: Booster, - val player: UUID -) + private val uuid: UUID +) { + val player: OfflinePlayer + get() = Bukkit.getOfflinePlayer(uuid) +} diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/gui/BoosterGUI.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/gui/BoosterGUI.kt index b4f3903..d8c8d22 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/gui/BoosterGUI.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/gui/BoosterGUI.kt @@ -1,8 +1,8 @@ package com.willfp.boosters.gui +import com.willfp.boosters.BoosterUtils import com.willfp.boosters.BoostersPlugin import com.willfp.boosters.activateBooster -import com.willfp.boosters.activeBooster import com.willfp.boosters.boosters.Booster import com.willfp.boosters.boosters.Boosters import com.willfp.eco.core.config.updating.ConfigUpdater @@ -23,7 +23,7 @@ object BoosterGUI { return SlotHandler { event, _, _ -> val player = event.whoClicked.tryAsPlayer() ?: return@SlotHandler - if (activeBooster != null) { + if (BoosterUtils.getActiveBooster() != null) { player.sendMessage(plugin.langYml.getMessage("already-active")) player.playSound( player.location,