diff --git a/src/main/java/app/entities/server/BaseServer.java b/src/main/java/app/entities/server/BaseServer.java index 37d58bc..ab54e97 100644 --- a/src/main/java/app/entities/server/BaseServer.java +++ b/src/main/java/app/entities/server/BaseServer.java @@ -17,25 +17,35 @@ public abstract class BaseServer { private ExecutorService executorServices_query; @JsonIgnore private ExecutorService executorServices_rcon; + @JsonIgnore + private SourceRconClient sourceRconClient; + @JsonIgnore + private SourceQueryClient sourceQueryClient; @JsonIgnore public SourceRconClient GetSourceRconClient() { if (executorServices_rcon == null) executorServices_rcon = Executors.newCachedThreadPool(); - SourceRconOptions options = SourceRconOptions.builder() - .option(FailsafeOptions.FAILSAFE_RATELIMIT_TYPE, RateLimitType.SMOOTH) - .option(GeneralOptions.THREAD_EXECUTOR_SERVICE, executorServices_rcon) - .build(); - return new SourceRconClient(options); + if (sourceRconClient == null) { + SourceRconOptions options = SourceRconOptions.builder() + .option(FailsafeOptions.FAILSAFE_RATELIMIT_TYPE, RateLimitType.SMOOTH) + .option(GeneralOptions.THREAD_EXECUTOR_SERVICE, executorServices_rcon) + .build(); + sourceRconClient = new SourceRconClient(options); + } + return sourceRconClient; } @JsonIgnore public SourceQueryClient GetSourceQueryClient() { if (executorServices_query == null) executorServices_query = Executors.newCachedThreadPool(); - SourceQueryOptions options = SourceQueryOptions.builder() - .option(FailsafeOptions.FAILSAFE_RATELIMIT_TYPE, RateLimitType.SMOOTH) - .option(GeneralOptions.THREAD_EXECUTOR_SERVICE, executorServices_query) - .build(); - return new SourceQueryClient(options); + if (sourceQueryClient == null) { + SourceQueryOptions options = SourceQueryOptions.builder() + .option(FailsafeOptions.FAILSAFE_RATELIMIT_TYPE, RateLimitType.SMOOTH) + .option(GeneralOptions.THREAD_EXECUTOR_SERVICE, executorServices_query) + .build(); + sourceQueryClient = new SourceQueryClient(options); + } + return sourceQueryClient; } }