Fix Null Error

Signed-off-by: Joseph T. McQuigg <J.T.McQuigg12@gmail.com>
This commit is contained in:
Joseph T. McQuigg 2023-03-23 00:47:41 -04:00
parent 23df0c7123
commit 5e3efeda04
No known key found for this signature in database
GPG Key ID: 1A95882DC8D52B2E

View File

@ -74,6 +74,7 @@ public class Ambassador {
@Subscribe
public void onPlayerChooseInitialServerEvent(PlayerChooseInitialServerEvent event, Continuation continuation) {
//Only handle Forge connections
if (forgeHandshakeHandler == null) return;
if((event.getInitialServer().isPresent()) && (forgeHandshakeHandler.getForgeConnection(event.getPlayer()).isPresent())) {
//Forge client
ForgeConnection forgeConnection = forgeHandshakeHandler.getForgeConnection(event.getPlayer()).get();
@ -86,7 +87,6 @@ public class Ambassador {
}
private void initMetrics() {
Metrics metrics = metricsFactory.make(this, 15655);
metrics.addCustomChart(new SingleLineChart("modern_forge_players", () -> (forgeHandshakeHandler != null) ? forgeHandshakeHandler.getAmountOfForgeConnections() : 0));
metricsFactory.make(this, 15655).addCustomChart(new SingleLineChart("modern_forge_players", () -> (forgeHandshakeHandler != null) ? forgeHandshakeHandler.getAmountOfForgeConnections() : 0));
}
}