Skip to content

Commit

Permalink
Fix place holders not working when no player specified
Browse files Browse the repository at this point in the history
Fixes #21
  • Loading branch information
quantiom committed Sep 13, 2022
1 parent ce7c3c2 commit 59fd58a
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 59fd58a

Please sign in to comment.