From 59fd58a52f8d081e3ab1caab12a1387ece5d627c Mon Sep 17 00:00:00 2001 From: quantiom Date: Tue, 13 Sep 2022 15:46:38 -0400 Subject: [PATCH] Fix place holders not working when no player specified Fixes #21 --- .../advancedvanish/hook/impl/PlaceHolderApiHook.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/PlaceHolderApiHook.kt b/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/PlaceHolderApiHook.kt index 792c843..7010e5f 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/PlaceHolderApiHook.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/PlaceHolderApiHook.kt @@ -21,14 +21,14 @@ class PlaceHolderApiHook : IHook { override fun persist() = true override fun canRegister() = true - override fun onPlaceholderRequest(player: Player, params: String): String? { + override fun onPlaceholderRequest(player: Player?, params: String): String? { return when (params.lowercase()) { - isVanishedPlaceholder -> if (player.isVanished()) "Yes" else "No" - vanishedPlayersPlaceholder -> { - val players = AdvancedVanishAPI.vanishedPlayers.map(Bukkit::getPlayer).map { it!! }.joinToString(", ", transform = Player::getName) - - if (players.isEmpty()) "None" else players - } + isVanishedPlaceholder -> if (player?.isVanished() == true) "Yes" else "No" + vanishedPlayersPlaceholder -> AdvancedVanishAPI.vanishedPlayers + .map(Bukkit::getPlayer) + .map { it!! } + .joinToString(", ", transform = Player::getName) + .ifEmpty { "None" } playerCountPlaceholder -> (Bukkit.getOnlinePlayers().size - AdvancedVanishAPI.vanishedPlayers.size).toString() else -> null }