mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-01-10 02:07:43 +01:00
update metric implementations
This commit is contained in:
parent
8983a0c024
commit
268c4982c3
@ -103,6 +103,7 @@ import com.onarandombox.MultiverseCore.utils.WorldManager;
|
|||||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||||
import me.main__.util.SerializationConfig.NoSuchPropertyException;
|
import me.main__.util.SerializationConfig.NoSuchPropertyException;
|
||||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Difficulty;
|
import org.bukkit.Difficulty;
|
||||||
@ -359,10 +360,9 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
metrics.addCustomChart(new Metrics.AdvancedPie("custom_generators", () -> {
|
metrics.addCustomChart(new Metrics.AdvancedPie("custom_generators", () -> {
|
||||||
Map<String, Integer> map = new HashMap<>();
|
Map<String, Integer> map = new HashMap<>();
|
||||||
for (MultiverseWorld w : this.getMVWorldManager().getMVWorlds()) {
|
for (MultiverseWorld w : this.getMVWorldManager().getMVWorlds()) {
|
||||||
if (w.getGenerator() != null && !w.getGenerator().equalsIgnoreCase("null")) {
|
String gen = w.getGenerator() != null ? w.getGenerator() : "N/A";
|
||||||
map.putIfAbsent(w.getGenerator(), 0);
|
map.putIfAbsent(gen, 0);
|
||||||
map.put(w.getGenerator(), map.get(w.getGenerator()) + 1);
|
map.put(gen, map.get(gen) + 1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
@ -371,25 +371,16 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
metrics.addCustomChart(new Metrics.AdvancedPie("environments", () -> {
|
metrics.addCustomChart(new Metrics.AdvancedPie("environments", () -> {
|
||||||
Map<String, Integer> map = new HashMap<>();
|
Map<String, Integer> map = new HashMap<>();
|
||||||
for (MultiverseWorld w : this.getMVWorldManager().getMVWorlds()) {
|
for (MultiverseWorld w : this.getMVWorldManager().getMVWorlds()) {
|
||||||
StringBuilder environment = new StringBuilder();
|
String env = w.getEnvironment().name().replace('_', ' ');
|
||||||
String[] environmentArray = w.getEnvironment().name().split("_");
|
env = StringUtils.capitalize(env.toLowerCase());
|
||||||
|
map.putIfAbsent(env, 0);
|
||||||
for (int i = 0; i < environmentArray.length; i++) {
|
map.put(env, map.get(env) + 1);
|
||||||
environment.append(environmentArray[i].substring(0, 1).toUpperCase());
|
|
||||||
environment.append(environmentArray[i].substring(1).toLowerCase());
|
|
||||||
if (i != environmentArray.length - 1) environment.append(" ");
|
|
||||||
}
|
|
||||||
|
|
||||||
String e = environment.toString();
|
|
||||||
map.putIfAbsent(e, 0);
|
|
||||||
map.put(e, map.get(e) + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add Worlds vs Loaded Worlds once bStats adds support for multi-line charts
|
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// TODO: add Worlds vs Loaded Worlds once bStats adds support for multi-line charts
|
||||||
log(Level.FINE, "Metrics were set up!");
|
log(Level.FINE, "Metrics were set up!");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log(Level.WARNING, "There was an issue while enabling metrics:");
|
log(Level.WARNING, "There was an issue while enabling metrics:");
|
||||||
|
Loading…
Reference in New Issue
Block a user