Skip to content

Commit

Permalink
Added try catch to a prometheus method to avoid console spam
Browse files Browse the repository at this point in the history
  • Loading branch information
Dioswilson committed Feb 4, 2022
1 parent 0b3e5af commit ad9ff52
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions carpetmodSrc/carpet/CarpetSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
public class CarpetSettings {
public static boolean locked = false;

public static final String carpetVersion = "v21_12_27";
public static final String carpetVersion = "v22_01_27";
public static final String minecraftVersion = "1.12.2";
public static final String mcpMappings = "39-1.12";

Expand Down Expand Up @@ -623,7 +623,7 @@ private static boolean validateBlockEventSerializer(boolean value) {
@Rule(desc = "Redstone dust algorithm", category = {EXPERIMENTAL, OPTIMIZATIONS}, extra = {
"Fast redstone dust by Theosib",
"Random redstone dust to test if your contraption is locational",
"Modern aims to mimic 1.15's signal decrement to improve lag efficiency"
"Modern aims to mimic 1.15's signal decrement to improve lag efficiencya"
})
public static RedstoneDustAlgorithm redstoneDustAlgorithm = RedstoneDustAlgorithm.vanilla;

Expand Down
28 changes: 16 additions & 12 deletions carpetmodSrc/carpet/prometheus/metrics/TileEntitiesMetrics.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package carpet.prometheus.metrics;

import java.util.ConcurrentModificationException;
import java.util.HashMap;
import java.util.List;

Expand All @@ -9,26 +10,29 @@
import carpet.prometheus.PrometheusExtension;

public class TileEntitiesMetrics extends AbstractMetric {

public TileEntitiesMetrics(String name, String help) {
super(name, help, "world", "type");
}

@Override
public void update(PrometheusExtension extension) {
HashMap<String, HashMap<String, Integer>> worldTileEntities = new HashMap<>();
for (WorldServer world : extension.getServer().worlds) {
List<TileEntity> TileEntityList = world.loadedTileEntityList;
String dimensionName = world.provider.getDimensionType().getName();
for (TileEntity tileEntity : TileEntityList) {
String tileEntityName = TileEntity.getKey(tileEntity.getClass()).getPath();
if (!worldTileEntities.containsKey(dimensionName)) {
worldTileEntities.put(dimensionName, new HashMap<>());
try {
HashMap<String, HashMap<String, Integer>> worldTileEntities = new HashMap<>();
for (WorldServer world : extension.getServer().worlds) {
List<TileEntity> TileEntityList = world.loadedTileEntityList;
String dimensionName = world.provider.getDimensionType().getName();
for (TileEntity tileEntity : TileEntityList) {
String tileEntityName = TileEntity.getKey(tileEntity.getClass()).getPath();
if (!worldTileEntities.containsKey(dimensionName)) {
worldTileEntities.put(dimensionName, new HashMap<>());
}
worldTileEntities.get(dimensionName).put(tileEntityName, worldTileEntities.get(dimensionName).getOrDefault(tileEntityName, 0) + 1);
}
worldTileEntities.get(dimensionName).put(tileEntityName, worldTileEntities.get(dimensionName).getOrDefault(tileEntityName, 0) + 1);
}
}
worldTileEntities.forEach((world, tileEntities) -> tileEntities.forEach((tileEntityName, count) -> this.getGauge().labels(world, tileEntityName).set(count)));
} catch (ConcurrentModificationException concurrentModificationException) {
}
worldTileEntities.forEach((world, tileEntities) -> tileEntities.forEach((tileEntityName, count) -> this.getGauge().labels(world, tileEntityName).set(count)));
}

}

0 comments on commit ad9ff52

Please sign in to comment.