Skip to content

Commit

Permalink
GH-879 Prevent counting online players with vanish in %eternalcore_on…
Browse files Browse the repository at this point in the history
…line% (#887)
  • Loading branch information
P1otrulla authored and vLuckyyy committed Jan 12, 2025
1 parent 015a8be commit a0bf9f6
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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())
)
);
}

}

0 comments on commit a0bf9f6

Please sign in to comment.