Add PlatformType enum and add bStats platform chart

This commit is contained in:
RednedEpic 2019-12-21 11:53:19 -06:00
parent 0960ab2365
commit 1fbbb87689
5 changed files with 30 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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();

View File

@ -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;
}

View File

@ -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() {