From 1fbbb876893e2acfacc35b39bd65881138b8aed1 Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Sat, 21 Dec 2019 11:53:19 -0600 Subject: [PATCH] Add PlatformType enum and add bStats platform chart --- .../platform/bukkit/GeyserBukkitPlugin.java | 3 ++- .../platform/bungeecord/GeyserBungeePlugin.java | 3 ++- .../platform/standalone/GeyserBootstrap.java | 3 ++- .../java/org/geysermc/common/PlatformType.java | 17 +++++++++++++++++ .../org/geysermc/connector/GeyserConnector.java | 10 +++++++--- 5 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 common/src/main/java/org/geysermc/common/PlatformType.java diff --git a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java index d3b87e8c..6bb77df1 100644 --- a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java +++ b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java @@ -26,6 +26,7 @@ package org.geysermc.platform.bukkit; import org.bukkit.plugin.java.JavaPlugin; +import org.geysermc.common.PlatformType; import org.geysermc.connector.GeyserConnector; import org.geysermc.common.bootstrap.IGeyserBootstrap; @@ -49,7 +50,7 @@ public class GeyserBukkitPlugin extends JavaPlugin implements IGeyserBootstrap { geyserLogger = new GeyserBukkitLogger(getLogger(), geyserConfig.isDebugMode()); - GeyserConnector.start(this); + GeyserConnector.start(PlatformType.BUKKIT, this); } @Override diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java index 4cbf8832..bf7cfff8 100644 --- a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java +++ b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java @@ -30,6 +30,7 @@ import net.md_5.bungee.config.Configuration; import net.md_5.bungee.config.ConfigurationProvider; import net.md_5.bungee.config.YamlConfiguration; +import org.geysermc.common.PlatformType; import org.geysermc.connector.GeyserConnector; import org.geysermc.common.bootstrap.IGeyserBootstrap; @@ -86,7 +87,7 @@ public class GeyserBungeePlugin extends Plugin implements IGeyserBootstrap { geyserLogger = new GeyserBungeeLogger(getLogger(), geyserConfig.isDebugMode()); - GeyserConnector.start(this); + GeyserConnector.start(PlatformType.BUNGEECORD, this); } @Override diff --git a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserBootstrap.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserBootstrap.java index 45d71bd6..a99b2434 100644 --- a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserBootstrap.java +++ b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserBootstrap.java @@ -26,6 +26,7 @@ package org.geysermc.platform.standalone; import org.fusesource.jansi.AnsiConsole; +import org.geysermc.common.PlatformType; import org.geysermc.common.bootstrap.IGeyserBootstrap; import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.utils.FileUtils; @@ -62,7 +63,7 @@ public class GeyserBootstrap implements IGeyserBootstrap { System.exit(0); } - GeyserConnector connector = GeyserConnector.start(this); + GeyserConnector connector = GeyserConnector.start(PlatformType.STANDALONE, this); ConsoleCommandReader consoleReader = new ConsoleCommandReader(connector); consoleReader.startConsole(); diff --git a/common/src/main/java/org/geysermc/common/PlatformType.java b/common/src/main/java/org/geysermc/common/PlatformType.java new file mode 100644 index 00000000..fa6f57fd --- /dev/null +++ b/common/src/main/java/org/geysermc/common/PlatformType.java @@ -0,0 +1,17 @@ +package org.geysermc.common; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum PlatformType { + + BUKKIT("Bukkit"), + BUNGEECORD("BungeeCord"), + SPONGE("Sponge"), + STANDALONE("Standalone"), + VELOCITY("Velocity"); + + private String platformName; +} diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java index 87337f63..004afe50 100644 --- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java +++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java @@ -31,6 +31,7 @@ import com.nukkitx.protocol.bedrock.v388.Bedrock_v388; import lombok.Getter; +import org.geysermc.common.PlatformType; import org.geysermc.common.bootstrap.IGeyserBootstrap; import org.geysermc.common.logger.IGeyserLogger; import org.geysermc.connector.command.GeyserCommandMap; @@ -77,15 +78,17 @@ public class GeyserConnector { private PingPassthroughThread passthroughThread; private BedrockServer bedrockServer; + private PlatformType platformType; private Metrics metrics; - private GeyserConnector(IGeyserConfiguration config, IGeyserLogger logger) { + private GeyserConnector(PlatformType platformType, IGeyserConfiguration config, IGeyserLogger logger) { long startupTime = System.currentTimeMillis(); instance = this; this.logger = logger; + this.platformType = platformType; logger.info("******************************************"); logger.info(""); @@ -124,6 +127,7 @@ public class GeyserConnector { metrics.addCustomChart(new Metrics.SingleLineChart("servers", () -> 1)); metrics.addCustomChart(new Metrics.SingleLineChart("players", players::size)); metrics.addCustomChart(new Metrics.SimplePie("authMode", config.getRemote()::getAuthType)); + metrics.addCustomChart(new Metrics.SimplePie("platform", platformType::getPlatformName)); } double completeTime = (System.currentTimeMillis() - startupTime) / 1000D; @@ -150,8 +154,8 @@ public class GeyserConnector { players.remove(player.getSocketAddress()); } - public static GeyserConnector start(IGeyserBootstrap bootstrap) { - return new GeyserConnector(bootstrap.getGeyserConfig(), bootstrap.getGeyserLogger()); + public static GeyserConnector start(PlatformType platformType, IGeyserBootstrap bootstrap) { + return new GeyserConnector(platformType, bootstrap.getGeyserConfig(), bootstrap.getGeyserLogger()); } public static void stop() {