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

View File

@@ -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) }
}

View File

@@ -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)
}

View File

@@ -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,