Skip to content

Commit

Permalink
fix config
Browse files Browse the repository at this point in the history
  • Loading branch information
a3510377 committed Nov 7, 2023
1 parent 6547fa8 commit f81a3ea
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 47 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ repositories {
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
maven {
url 'https://masa.dy.fi/maven'
}
maven {
url 'https://masa.dy.fi/maven'
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@

import java.util.Map;

public class InfoCommand implements CarpetExtension, ModInitializer {
public class CarpetPrometheus implements CarpetExtension, ModInitializer {
public static final Logger LOGGER = LogManager.getLogger("info-command");
public static MinecraftServer server;
public final Prometheus prometheus;

public InfoCommand() {
public CarpetPrometheus() {
prometheus = new Prometheus();
}

@Override
public void onInitialize() {
CarpetServer.manageExtension(new InfoCommand());
CarpetServer.manageExtension(this);
}

@Override
Expand All @@ -37,7 +37,7 @@ public void registerCommands(CommandDispatcher<ServerCommandSource> dispatcher)

@Override
public void onServerLoaded(MinecraftServer server) {
InfoCommand.server = server;
CarpetPrometheus.server = server;
this.prometheus.start();
}

Expand All @@ -59,7 +59,7 @@ public Map<String, String> canHasTranslations(String lang) {
}

private record OnConfigChange(
InfoCommand infoCommand
CarpetPrometheus infoCommand
) implements TriConsumer<ServerCommandSource, ParsedRule<?>, String> {

@Override
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/carpet_prometheus/Prometheus.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public Prometheus() {

@Override
public void run() {
if (InfoCommand.server == null || !InfoCommandSettings.prometheusEnable) return;
if (CarpetPrometheus.server == null || !InfoCommandSettings.prometheusEnable) return;

for (Metric metric : this.getMetrics()) {
try {
metric.update(InfoCommand.server);
metric.update(CarpetPrometheus.server);
} catch (Exception e) {
InfoCommand.LOGGER.error("Error updating metric " + metric.getName(), e);
CarpetPrometheus.LOGGER.error("Error updating metric " + metric.getName(), e);
}
}
}
Expand All @@ -48,13 +48,13 @@ public void start() {
metricUpdateLoop.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
if (InfoCommand.server == null || !InfoCommandSettings.prometheusEnable) return;
if (CarpetPrometheus.server == null || !InfoCommandSettings.prometheusEnable) return;

for (Metric metric : getMetrics()) {
try {
metric.update(InfoCommand.server);
metric.update(CarpetPrometheus.server);
} catch (Exception e) {
InfoCommand.LOGGER.error("Error updating metric " + metric.getName(), e);
CarpetPrometheus.LOGGER.error("Error updating metric " + metric.getName(), e);
}
}
}
Expand All @@ -66,7 +66,7 @@ public void run() {
.registry(registry)
.buildAndStart();
} catch (Exception e) {
InfoCommand.LOGGER.error("Start HttpServer error:", e);
CarpetPrometheus.LOGGER.error("Start HttpServer error:", e);
}
}

Expand Down
58 changes: 26 additions & 32 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
{
"schemaVersion": 1,
"id": "carpet_prometheus",
"version": "${version}",
"name": "carpet_prometheus",
"description": "This is an example description! Tell everyone what your mod is about!",
"authors": [
"Me!"
],
"contact": {
"homepage": "https://fabricmc.net/",
"sources": "https://github.com/FabricMC/fabric-example-mod"
},
"license": "CC0-1.0",
"icon": "assets/carpet_prometheus/icon.png",
"environment": "*",
"entrypoints": {
"main": [
"com.carpet_prometheus.InfoCommand"
]
},
"mixins": [
"carpet_prometheus.mixins.json"
],
"depends": {
"fabricloader": ">=0.14.24",
"minecraft": "~1.17.1",
"java": ">=17",
"fabric": "*"
},
"suggests": {
"another-mod": "*"
}
"schemaVersion": 1,
"id": "carpet_prometheus",
"version": "${version}",
"name": "carpet_prometheus",
"description": "This is an example description! Tell everyone what your mod is about!",
"authors": [
"Me!"
],
"contact": {
"homepage": "https://fabricmc.net/",
"sources": "https://github.com/FabricMC/fabric-example-mod"
},
"license": "CC0-1.0",
"icon": "assets/carpet_prometheus/icon.png",
"environment": "*",
"entrypoints": {
"main": [
"com.carpet_prometheus.CarpetPrometheus"
]
},
"mixins": [
"carpet_prometheus.mixins.json"
],
"depends": {
"minecraft": "1.17.x"
}
}

0 comments on commit f81a3ea

Please sign in to comment.