From 3eb9226b14f5d629299872328b40a19320e3d238 Mon Sep 17 00:00:00 2001 From: Andre601 <11576465+Andre601@users.noreply.github.com> Date: Tue, 16 Mar 2021 11:43:23 +0100 Subject: [PATCH] Change code to instead just return custom HashMap --- .../bungeecord/BungeeCore.java | 3 +- core/pom.xml | 6 --- .../core/OneVersionRemake.java | 54 +++++++++---------- .../velocity/VelocityCore.java | 3 +- 4 files changed, 30 insertions(+), 36 deletions(-) diff --git a/bungeecord/src/main/java/com/andre601/oneversionremake/bungeecord/BungeeCore.java b/bungeecord/src/main/java/com/andre601/oneversionremake/bungeecord/BungeeCore.java index d539201..26e0867 100644 --- a/bungeecord/src/main/java/com/andre601/oneversionremake/bungeecord/BungeeCore.java +++ b/bungeecord/src/main/java/com/andre601/oneversionremake/bungeecord/BungeeCore.java @@ -31,6 +31,7 @@ import net.kyori.adventure.platform.bungeecord.BungeeAudiences; import net.md_5.bungee.api.plugin.Plugin; import org.bstats.bungeecord.Metrics; +import org.bstats.charts.DrilldownPie; import java.nio.file.Path; @@ -62,7 +63,7 @@ public void loadEventListeners(){ public void loadMetrics(){ Metrics metrics = new Metrics(this, 10340); - metrics.addCustomChart(core.getPie()); + metrics.addCustomChart(new DrilldownPie("allowed_protocols", () -> core.getPieMap())); } @Override diff --git a/core/pom.xml b/core/pom.xml index 71a9ad3..1a6d8e5 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -63,12 +63,6 @@ 4.7.0 provided - - org.bstats - bstats-base - 2.2.1 - compile - diff --git a/core/src/main/java/com/andre601/oneversionremake/core/OneVersionRemake.java b/core/src/main/java/com/andre601/oneversionremake/core/OneVersionRemake.java index c674a91..1a9e478 100644 --- a/core/src/main/java/com/andre601/oneversionremake/core/OneVersionRemake.java +++ b/core/src/main/java/com/andre601/oneversionremake/core/OneVersionRemake.java @@ -23,7 +23,6 @@ import com.andre601.oneversionremake.core.files.ConfigHandler; import com.andre601.oneversionremake.core.interfaces.PluginCore; import com.andre601.oneversionremake.core.interfaces.ProxyLogger; -import org.bstats.charts.DrilldownPie; import java.io.IOException; import java.io.InputStream; @@ -68,37 +67,36 @@ public CommandHandler getCommandHandler(){ return commandHandler; } - public DrilldownPie getPie(){ - return new DrilldownPie("allowed_protocols", () -> { - Map> map = new HashMap<>(); + public Map> getPieMap(){ + Map> map = new HashMap<>(); + + List versions = getConfigHandler().getIntList("Protocol", "Versions"); + if(versions.isEmpty()){ + String unknown = ProtocolVersion.getFriendlyName(0); - List versions = getConfigHandler().getIntList("Protocol", "Versions"); - if(versions.isEmpty()){ - String unknown = ProtocolVersion.getFriendlyName(0); - - Map entry = new HashMap<>(); - - entry.put(unknown, 1); - map.put("other", entry); - - return map; - } + Map entry = new HashMap<>(); - for(int version : versions){ - String major = ProtocolVersion.getMajor(version); - String name = ProtocolVersion.getFriendlyName(version); - - Map entry = new HashMap<>(); - entry.put(name, 1); - if(major.equalsIgnoreCase("?")){ - map.put("other", entry); - }else{ - map.put(major, entry); - } - } + entry.put(unknown, 1); + map.put("other", entry); return map; - }); + } + + for(int version : versions){ + String major = ProtocolVersion.getMajor(version); + String name = ProtocolVersion.getFriendlyName(version); + + Map entry = new HashMap<>(); + entry.put(name, 1); + + if(major.equalsIgnoreCase("?")){ + map.put("other", entry); + }else{ + map.put(major, entry); + } + } + + return map; } private void start(){ diff --git a/velocity/src/main/java/com/andre601/oneversionremake/velocity/VelocityCore.java b/velocity/src/main/java/com/andre601/oneversionremake/velocity/VelocityCore.java index df8b325..c3dcbae 100644 --- a/velocity/src/main/java/com/andre601/oneversionremake/velocity/VelocityCore.java +++ b/velocity/src/main/java/com/andre601/oneversionremake/velocity/VelocityCore.java @@ -34,6 +34,7 @@ import com.velocitypowered.api.event.proxy.ProxyInitializeEvent; import com.velocitypowered.api.plugin.annotation.DataDirectory; import com.velocitypowered.api.proxy.ProxyServer; +import org.bstats.charts.DrilldownPie; import org.bstats.velocity.Metrics; import org.slf4j.LoggerFactory; @@ -84,7 +85,7 @@ public void loadEventListeners(){ public void loadMetrics(){ Metrics metrics = factory.make(this, 10341); - metrics.addCustomChart(core.getPie()); + metrics.addCustomChart(new DrilldownPie("allowed_protocols", () -> core.getPieMap())); } @Override