Update bstats to 2.2.1

This commit is contained in:
Mike Primm 2021-11-12 17:44:33 -06:00
parent 754c10efa6
commit 4610bba449
2 changed files with 39 additions and 20 deletions

View File

@ -22,7 +22,7 @@ dependencies {
implementation group: 'de.bananaco', name: 'bPermissions', version: '2.9.1'
implementation group: 'com.platymuus.bukkit.permissions', name: 'PermissionsBukkit', version: '1.6'
implementation group: 'org.anjocaido', name: 'EssentialsGroupManager', version: '2.10.1'
implementation group: 'org.bstats', name: 'bstats-bukkit', version: '1.5'
implementation group: 'org.bstats', name: 'bstats-bukkit', version: '2.2.1'
implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.2'
implementation project(':bukkit-helper')

View File

@ -18,6 +18,9 @@ import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.CustomChart;
import org.bstats.json.JsonObjectBuilder;
import org.bstats.json.JsonObjectBuilder.JsonObject;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
@ -1671,35 +1674,51 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
return core.testIfPlayerInfoProtected();
}
private void initMetrics() {
metrics = new Metrics(this);
private class FeatureChart extends CustomChart {
public FeatureChart() { super("features_used"); }
metrics.addCustomChart(new Metrics.MultiLineChart("features_used", () -> {
Map<String, Integer> hashMap = new HashMap<>();
hashMap.put("internal_web_server", core.configuration.getBoolean("disable-webserver", false) ? 0 : 1);
hashMap.put("login_security", core.configuration.getBoolean("login-enabled", false) ? 1 : 0);
hashMap.put("player_info_protected", core.player_info_protected ? 1 : 0);
@Override
protected JsonObject getChartData() throws Exception {
JsonObjectBuilder obj = new JsonObjectBuilder();
obj = obj.appendField("internal_web_server", core.configuration.getBoolean("disable-webserver", false) ? 0 : 1);
obj = obj.appendField("login_security", core.configuration.getBoolean("login-enabled", false) ? 1 : 0);
obj = obj.appendField("player_info_protected", core.player_info_protected ? 1 : 0);
for (String mod : modsused)
hashMap.put(mod + "_blocks", 1);
return hashMap;
}));
obj = obj.appendField(mod + "_blocks", 1);
return obj.build();
}
}
private class MapChart extends CustomChart {
public MapChart() { super("map_data"); }
metrics.addCustomChart(new Metrics.MultiLineChart("map_data", () -> {
Map<String, Integer> hashMap = new HashMap<>();
hashMap.put("worlds", core.mapManager != null ? core.mapManager.getWorlds().size() : 0);
@Override
protected JsonObject getChartData() throws Exception {
JsonObjectBuilder obj = new JsonObjectBuilder();
obj = obj.appendField("worlds", core.mapManager != null ? core.mapManager.getWorlds().size() : 0);
int maps = 0, hdmaps = 0;
if (core.mapManager != null)
if (core.mapManager != null) {
for (DynmapWorld w : core.mapManager.getWorlds()) {
for (MapType mt : w.maps)
if (mt instanceof HDMap)
++hdmaps;
maps += w.maps.size();
}
hashMap.put("maps", maps);
hashMap.put("hd_maps", hdmaps);
return hashMap;
}));
obj = obj.appendField("maps", maps);
obj = obj.appendField("hd_maps", hdmaps);
}
return obj.build();
}
}
private void initMetrics() {
metrics = new Metrics(this, 619);
metrics.addCustomChart(new FeatureChart());
metrics.addCustomChart(new MapChart());
}
@Override
public void processSignChange(String material, String world, int x, int y, int z,
String[] lines, String playerid) {