From a0bf9f660cfbab46cd0c9d75a723b71085c828d5 Mon Sep 17 00:00:00 2001 From: Piotr Zych <77621271+P1otrulla@users.noreply.github.com> Date: Sun, 12 Jan 2025 20:12:56 +0100 Subject: [PATCH] GH-879 Prevent counting online players with vanish in %eternalcore_online% (#887) --- .../core/placeholder/PlaceholdersSetup.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/placeholder/PlaceholdersSetup.java b/eternalcore-core/src/main/java/com/eternalcode/core/placeholder/PlaceholdersSetup.java index 0ae46f863..1ddc827ce 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/placeholder/PlaceholdersSetup.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/placeholder/PlaceholdersSetup.java @@ -1,6 +1,7 @@ package com.eternalcode.core.placeholder; import com.eternalcode.core.configuration.implementation.PlaceholdersConfiguration; +import com.eternalcode.core.feature.vanish.VanishService; import com.eternalcode.core.injector.annotations.component.Controller; import com.eternalcode.core.publish.event.EternalInitializeEvent; import com.eternalcode.core.publish.Subscribe; @@ -16,10 +17,14 @@ void setUp(PlaceholderRegistry placeholderRegistry, PlaceholdersConfiguration pl }); } - @Subscribe(EternalInitializeEvent.class) - void setUpPlaceholders(PlaceholderRegistry placeholderRegistry, Server server) { - placeholderRegistry.registerPlaceholder(PlaceholderReplacer.of("online", player -> String.valueOf(server.getOnlinePlayers().size()))); + void setUpPlaceholders(PlaceholderRegistry placeholderRegistry, Server server, VanishService vanishService) { + placeholderRegistry.registerPlaceholder(PlaceholderReplacer.of("online", player -> String.valueOf( + server.getOnlinePlayers() + .stream() + .filter(onlinePlayer -> !vanishService.isVanished(onlinePlayer)) + .count()) + ) + ); } - }