From b7786ef2f52124ad272870ea03d9b10e5255d4de Mon Sep 17 00:00:00 2001 From: ItsNature Date: Fri, 22 Sep 2023 14:49:24 +0200 Subject: [PATCH] Register stats config options --- .../module/serverrule/ServerRuleModule.java | 24 +++++++------- .../apollo/stats/ApolloStatsManager.java | 33 ++++++++++++++----- 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/api/src/main/java/com/lunarclient/apollo/module/serverrule/ServerRuleModule.java b/api/src/main/java/com/lunarclient/apollo/module/serverrule/ServerRuleModule.java index db5f3299..79a6a2de 100644 --- a/api/src/main/java/com/lunarclient/apollo/module/serverrule/ServerRuleModule.java +++ b/api/src/main/java/com/lunarclient/apollo/module/serverrule/ServerRuleModule.java @@ -167,18 +167,18 @@ public final class ServerRuleModule extends ApolloModule { ServerRuleModule() { this.registerOptions( - COMPETITIVE_GAME, - COMPETITIVE_COMMANDS, - DISABLE_SHADERS, - DISABLE_CHUNK_RELOADING, - DISABLE_BROADCASTING, - ANTI_PORTAL_TRAPS, - OVERRIDE_BRIGHTNESS, - BRIGHTNESS, - OVERRIDE_NAMETAG_RENDER_DISTANCE, - NAMETAG_RENDER_DISTANCE, - OVERRIDE_MAX_CHAT_LENGTH, - MAX_CHAT_LENGTH + ServerRuleModule.COMPETITIVE_GAME, + ServerRuleModule.COMPETITIVE_COMMANDS, + ServerRuleModule.DISABLE_SHADERS, + ServerRuleModule.DISABLE_CHUNK_RELOADING, + ServerRuleModule.DISABLE_BROADCASTING, + ServerRuleModule.ANTI_PORTAL_TRAPS, + ServerRuleModule.OVERRIDE_BRIGHTNESS, + ServerRuleModule.BRIGHTNESS, + ServerRuleModule.OVERRIDE_NAMETAG_RENDER_DISTANCE, + ServerRuleModule.NAMETAG_RENDER_DISTANCE, + ServerRuleModule.OVERRIDE_MAX_CHAT_LENGTH, + ServerRuleModule.MAX_CHAT_LENGTH ); } diff --git a/common/src/main/java/com/lunarclient/apollo/stats/ApolloStatsManager.java b/common/src/main/java/com/lunarclient/apollo/stats/ApolloStatsManager.java index dadd721f..699ab48e 100644 --- a/common/src/main/java/com/lunarclient/apollo/stats/ApolloStatsManager.java +++ b/common/src/main/java/com/lunarclient/apollo/stats/ApolloStatsManager.java @@ -24,6 +24,7 @@ package com.lunarclient.apollo.stats; import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.option.Option; import com.lunarclient.apollo.option.SimpleOption; import io.leangen.geantyref.TypeToken; @@ -35,46 +36,46 @@ */ public final class ApolloStatsManager { - private static final String CONFIG_PREFIX = "mcstats."; + private static final String CONFIG_PREFIX = "mcstats"; public static final SimpleOption MOTD = Option.builder() .comment("Set to 'true' to send your server IP address to MCStats, otherwise 'false'.") - .node(CONFIG_PREFIX + "address").type(TypeToken.get(Boolean.class)) + .node(CONFIG_PREFIX, "address").type(TypeToken.get(Boolean.class)) .defaultValue(true).build(); public static final SimpleOption ICON = Option.builder() .comment("Set to 'true' to send your server icon to MCStats, otherwise 'false'.") - .node(CONFIG_PREFIX + "icon").type(TypeToken.get(Boolean.class)) + .node(CONFIG_PREFIX, "icon").type(TypeToken.get(Boolean.class)) .defaultValue(true).build(); public static final SimpleOption VERSION = Option.builder() .comment("Set to 'true' to send your server version to MCStats, otherwise 'false'.") - .node(CONFIG_PREFIX + "version").type(TypeToken.get(Boolean.class)) + .node(CONFIG_PREFIX, "version").type(TypeToken.get(Boolean.class)) .defaultValue(true).build(); public static final SimpleOption PLUGINS = Option.builder() .comment("Set to 'true' to send your server plugins to MCStats, otherwise 'false'.") - .node(CONFIG_PREFIX + "plugins").type(TypeToken.get(Boolean.class)) + .node(CONFIG_PREFIX, "plugins").type(TypeToken.get(Boolean.class)) .defaultValue(true).build(); public static final SimpleOption PLATFORM_TYPE = Option.builder() .comment("Set to 'true' to send your server platform type to MCStats, otherwise 'false'.") - .node(CONFIG_PREFIX + "platform-type").type(TypeToken.get(Boolean.class)) + .node(CONFIG_PREFIX, "platform-type").type(TypeToken.get(Boolean.class)) .defaultValue(true).build(); public static final SimpleOption PLATFORM_VERSION = Option.builder() .comment("Set to 'true' to send your server platform version to MCStats, otherwise 'false'.") - .node(CONFIG_PREFIX + "platform-version").type(TypeToken.get(Boolean.class)) + .node(CONFIG_PREFIX, "platform-version").type(TypeToken.get(Boolean.class)) .defaultValue(true).build(); public static final SimpleOption HEARTBEAT_PERFORMANCE = Option.builder() .comment("Set to 'true' to send your server cpu and ram usage to MCStats, otherwise 'false'.") - .node(CONFIG_PREFIX + "performance").type(TypeToken.get(Boolean.class)) + .node(CONFIG_PREFIX, "performance").type(TypeToken.get(Boolean.class)) .defaultValue(true).build(); public static final SimpleOption HEARTBEAT_COUNTS = Option.builder() .comment("Set to 'true' to send your server player count to MCStats, otherwise 'false'.") - .node(CONFIG_PREFIX + "counts").type(TypeToken.get(Boolean.class)) + .node(CONFIG_PREFIX, "counts").type(TypeToken.get(Boolean.class)) .defaultValue(true).build(); /** @@ -83,11 +84,25 @@ public final class ApolloStatsManager { * @since 1.0.0 */ public ApolloStatsManager() { + this.registerConfigOptions(); this.handleServerStartStats(); new ApolloStatsThread(); } + private void registerConfigOptions() { + ApolloManager.registerOptions( + ApolloStatsManager.MOTD, + ApolloStatsManager.ICON, + ApolloStatsManager.VERSION, + ApolloStatsManager.PLUGINS, + ApolloStatsManager.PLATFORM_TYPE, + ApolloStatsManager.PLATFORM_VERSION, + ApolloStatsManager.HEARTBEAT_PERFORMANCE, + ApolloStatsManager.HEARTBEAT_COUNTS + ); + } + private void handleServerStartStats() { ApolloStats stats = Apollo.getPlatform().getStats();