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 4b9d41c..d539201 100644 --- a/bungeecord/src/main/java/com/andre601/oneversionremake/bungeecord/BungeeCore.java +++ b/bungeecord/src/main/java/com/andre601/oneversionremake/bungeecord/BungeeCore.java @@ -24,7 +24,6 @@ import com.andre601.oneversionremake.bungeecord.logging.BungeeLogger; import com.andre601.oneversionremake.core.OneVersionRemake; import com.andre601.oneversionremake.core.commands.CommandHandler; -import com.andre601.oneversionremake.core.enums.ProtocolVersion; import com.andre601.oneversionremake.core.enums.ProxyPlatform; import com.andre601.oneversionremake.core.files.ConfigHandler; import com.andre601.oneversionremake.core.interfaces.PluginCore; @@ -32,12 +31,8 @@ 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; -import java.util.HashMap; -import java.util.List; -import java.util.Map; public class BungeeCore extends Plugin implements PluginCore{ @@ -67,37 +62,7 @@ public void loadEventListeners(){ public void loadMetrics(){ Metrics metrics = new Metrics(this, 10340); - metrics.addCustomChart(new DrilldownPie("allowed_versions", () -> { - Map> map = new HashMap<>(); - - List protocolVersions = getConfigHandler().getIntList("Protocol", "Versions"); - if(protocolVersions.isEmpty()){ - String unknown = ProtocolVersion.getFriendlyName(0); - - Map entry = new HashMap<>(); - - entry.put(unknown, 1); - map.put("other", entry); - - return map; - } - - for(int version : protocolVersions){ - 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; - })); + metrics.addCustomChart(core.getPie()); } @Override diff --git a/core/pom.xml b/core/pom.xml index 1a6d8e5..71a9ad3 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -63,6 +63,12 @@ 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 22e2c4b..c674a91 100644 --- a/core/src/main/java/com/andre601/oneversionremake/core/OneVersionRemake.java +++ b/core/src/main/java/com/andre601/oneversionremake/core/OneVersionRemake.java @@ -23,10 +23,13 @@ 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; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Properties; public class OneVersionRemake{ @@ -65,6 +68,39 @@ public CommandHandler getCommandHandler(){ return commandHandler; } + public DrilldownPie getPie(){ + return new DrilldownPie("allowed_protocols", () -> { + Map> map = new HashMap<>(); + + 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; + } + + 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(){ loadVersion(); printBanner(); diff --git a/pom.xml b/pom.xml index fcc2176..31d197a 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.3.0 + 3.3.1 1.8 1.8 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 21fe99b..93c18ee 100644 --- a/velocity/src/main/java/com/andre601/oneversionremake/velocity/VelocityCore.java +++ b/velocity/src/main/java/com/andre601/oneversionremake/velocity/VelocityCore.java @@ -88,38 +88,8 @@ public void loadEventListeners(){ @Override public void loadMetrics(){ Metrics metrics = factory.make(this, 10341); - - metrics.addCustomChart(new DrilldownPie("allowed_versions", () -> { - Map> map = new HashMap<>(); - - List protocolVersions = getConfigHandler().getIntList("Protocol", "Versions"); - if(protocolVersions.isEmpty()){ - String unknown = ProtocolVersion.getFriendlyName(0); - - Map entry = new HashMap<>(); - - entry.put(unknown, 1); - map.put("other", entry); - - return map; - } - - for(int version : protocolVersions){ - 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; - })); + + metrics.addCustomChart(core.getPie()); } @Override