Skip to content

Commit

Permalink
Register stats config options
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsNature committed Sep 22, 2023
1 parent 8b61352 commit b7786ef
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Boolean> MOTD = Option.<Boolean>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<Boolean> ICON = Option.<Boolean>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<Boolean> VERSION = Option.<Boolean>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<Boolean> PLUGINS = Option.<Boolean>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<Boolean> PLATFORM_TYPE = Option.<Boolean>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<Boolean> PLATFORM_VERSION = Option.<Boolean>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<Boolean> HEARTBEAT_PERFORMANCE = Option.<Boolean>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<Boolean> HEARTBEAT_COUNTS = Option.<Boolean>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();

/**
Expand All @@ -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();

Expand Down

0 comments on commit b7786ef

Please sign in to comment.