From 40b2c9993b524f0882a1efe3b198006a23678ab4 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Fri, 17 May 2019 06:27:19 -0400 Subject: [PATCH] Clean up some connection checks --- .../connection/backend/VelocityServerConnection.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java index 285912c8e..a8b97c028 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java @@ -134,11 +134,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation, } private void startHandshake() { - MinecraftConnection mc = connection; - if (mc == null) { - throw new IllegalStateException("No connection established!"); - } - + final MinecraftConnection mc = ensureConnected(); PlayerInfoForwarding forwardingMode = server.getConfiguration().getPlayerInfoForwardingMode(); // Initiate the handshake. @@ -214,10 +210,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation, Preconditions.checkNotNull(identifier, "identifier"); Preconditions.checkNotNull(data, "data"); - MinecraftConnection mc = connection; - if (mc == null) { - throw new IllegalStateException("Not connected to a server!"); - } + MinecraftConnection mc = ensureConnected(); PluginMessage message = new PluginMessage(); message.setChannel(identifier.getId());