diff --git a/src/main/java/io/graversen/rust/rcon/DefaultRustRconService.java b/src/main/java/io/graversen/rust/rcon/DefaultRustRconService.java index 604beeb..7aa0157 100644 --- a/src/main/java/io/graversen/rust/rcon/DefaultRustRconService.java +++ b/src/main/java/io/graversen/rust/rcon/DefaultRustRconService.java @@ -119,7 +119,7 @@ public List players() { @Override public List teams() { - return null; + return rustTeams.get(); } @Override @@ -154,6 +154,7 @@ protected void configure() { registerInternalTask(rustTeamsEmitTask, Duration.ofMinutes(5), Duration.ofSeconds(10)); registerRustDiagnosticsListener(); registerRustPlayerEventListener(); + registerRustTeamsEventListener(); } protected ScheduledExecutorService createScheduledExecutorService() { @@ -248,6 +249,11 @@ private void registerRustPlayerEventListener() { registerEvents(new RustPlayerEventListener(rustPlayers::set)); } + private void registerRustTeamsEventListener() { + log.info("Registering {}", RustTeamsEventListener.class.getSimpleName()); + registerEvents(new RustTeamsEventListener(rustTeams::set)); + } + private void runConfigure() { log.info("Running internal configuration hook"); configure(); diff --git a/src/main/java/io/graversen/rust/rcon/RustPlayerEventListener.java b/src/main/java/io/graversen/rust/rcon/RustPlayerEventListener.java index 8f65265..bfb203e 100644 --- a/src/main/java/io/graversen/rust/rcon/RustPlayerEventListener.java +++ b/src/main/java/io/graversen/rust/rcon/RustPlayerEventListener.java @@ -20,7 +20,7 @@ public class RustPlayerEventListener { private final @NonNull Consumer> rustPlayersConsumer; @Subscribe - public void onServerInfo(RustPlayersEvent rustPlayersEvent) { + public void onRustPlayers(RustPlayersEvent rustPlayersEvent) { final var rustPlayers = mapRustPlayers().apply(rustPlayersEvent); rustPlayersConsumer.accept(rustPlayers); } diff --git a/src/main/java/io/graversen/rust/rcon/RustTeamsEventListener.java b/src/main/java/io/graversen/rust/rcon/RustTeamsEventListener.java new file mode 100644 index 0000000..392febb --- /dev/null +++ b/src/main/java/io/graversen/rust/rcon/RustTeamsEventListener.java @@ -0,0 +1,20 @@ +package io.graversen.rust.rcon; + +import com.google.common.eventbus.Subscribe; +import io.graversen.rust.rcon.event.server.RustTeamsEvent; +import lombok.AccessLevel; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +import java.util.List; +import java.util.function.Consumer; + +@RequiredArgsConstructor(access = AccessLevel.PACKAGE) +public class RustTeamsEventListener { + private final @NonNull Consumer> rustTeamsConsumer; + + @Subscribe + public void onRustTeams(RustTeamsEvent rustTeamsEvent) { + rustTeamsConsumer.accept(rustTeamsEvent.getRustTeams()); + } +}