From 953b8a4bb3ca3d1974d944ed27d90c421fea72f6 Mon Sep 17 00:00:00 2001
From: Piotr Zych <77621271+P1otrulla@users.noreply.github.com>
Date: Sun, 12 Jan 2025 16:33:49 +0100
Subject: [PATCH] Prevent counting online players with vanish

---
 .../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())
+            )
+        );
     }
-
 }