Add ability to disable spark metrics

This commit is contained in:
RuscalWorld 2021-05-25 21:25:49 +03:00
parent c56b315c3e
commit 2506639051
No known key found for this signature in database
GPG key ID: 4F53776031D128ED
3 changed files with 18 additions and 3 deletions

View file

@ -30,12 +30,15 @@ public class FabricExporter implements ModInitializer {
MetricUpdater metricUpdater = new MetricUpdater(this);
metricUpdater.registerMetric(new OnlinePlayers());
metricUpdater.registerMetric(new TicksPerSecond());
metricUpdater.registerMetric(new MillisPerTick());
metricUpdater.registerMetric(new Entities());
metricUpdater.registerMetric(new LoadedChunks());
metricUpdater.registerMetric(new TotalLoadedChunks());
if (this.getConfig().shouldUseSpark()) {
metricUpdater.registerMetric(new TicksPerSecond());
metricUpdater.registerMetric(new MillisPerTick());
}
Timer timer = new Timer();
ServerLifecycleEvents.SERVER_STARTING.register(this::setServer);

View file

@ -7,6 +7,7 @@ import java.util.Properties;
public class MainConfig extends Config {
private int port;
private int updateInterval;
private boolean useSpark;
public MainConfig(String name) {
super(name);
@ -19,6 +20,8 @@ public class MainConfig extends Config {
String updateIntervalString = properties.getProperty("update-interval", "1000");
this.setUpdateInterval(ConvertUtil.intToStringOrDefault(updateIntervalString, 1000));
this.setShouldUseSpark(properties.getProperty("use-spark", "true").equalsIgnoreCase("true"));
}
public int getPort() {
@ -36,4 +39,12 @@ public class MainConfig extends Config {
public void setUpdateInterval(int updateInterval) {
this.updateInterval = updateInterval;
}
public boolean shouldUseSpark() {
return useSpark;
}
public void setShouldUseSpark(boolean useSpark) {
this.useSpark = useSpark;
}
}

View file

@ -1,2 +1,3 @@
server-port=25585
update-interval=1000
update-interval=1000
use-spark=true