3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Restore server disconnect messages.

Dieser Commit ist enthalten in:
Andrew Steinborn 2020-06-23 21:56:59 -04:00
Ursprung 24cd1f4da0
Commit fd231c71fd
7 geänderte Dateien mit 24 neuen und 18 gelöschten Zeilen

Datei anzeigen

@ -15,9 +15,6 @@ allprojects {
group 'com.velocitypowered' group 'com.velocitypowered'
version '1.1.0-SNAPSHOT' version '1.1.0-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8
ext { ext {
// dependency versions // dependency versions
textVersion = '3.0.3' textVersion = '3.0.3'
@ -41,6 +38,11 @@ allprojects {
} }
} }
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
repositories { repositories {
mavenLocal() mavenLocal()
mavenCentral() mavenCentral()

Datei anzeigen

@ -92,8 +92,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
sessionHandler.disconnected(); sessionHandler.disconnected();
} }
if (association != null && !knownDisconnect if (association != null && !knownDisconnect) {
&& !(association instanceof InitialInboundConnection)) {
logger.info("{} has disconnected", association); logger.info("{} has disconnected", association);
} }
} }
@ -226,15 +225,20 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
/** /**
* Immediately closes the connection. * Immediately closes the connection.
* @param markKnown whether the disconnection is known
*/ */
public void close() { public void close(boolean markKnown) {
if (channel.isActive()) { if (channel.isActive()) {
if (channel.eventLoop().inEventLoop()) { if (channel.eventLoop().inEventLoop()) {
if (markKnown) {
knownDisconnect = true; knownDisconnect = true;
}
channel.close(); channel.close();
} else { } else {
channel.eventLoop().execute(() -> { channel.eventLoop().execute(() -> {
if (markKnown) {
knownDisconnect = true; knownDisconnect = true;
}
channel.close(); channel.close();
}); });
} }

Datei anzeigen

@ -188,7 +188,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
public void disconnect() { public void disconnect() {
if (connection != null) { if (connection != null) {
gracefulDisconnect = true; gracefulDisconnect = true;
connection.close(); connection.close(false);
connection = null; connection = null;
} }
} }

Datei anzeigen

@ -66,7 +66,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
StateRegistry nextState = getStateForProtocol(handshake.getNextStatus()); StateRegistry nextState = getStateForProtocol(handshake.getNextStatus());
if (nextState == null) { if (nextState == null) {
LOGGER.error("{} provided invalid protocol {}", ic, handshake.getNextStatus()); LOGGER.error("{} provided invalid protocol {}", ic, handshake.getNextStatus());
connection.close(); connection.close(true);
} else { } else {
connection.setState(nextState); connection.setState(nextState);
connection.setProtocolVersion(handshake.getProtocolVersion()); connection.setProtocolVersion(handshake.getProtocolVersion());
@ -171,13 +171,13 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
@Override @Override
public void handleGeneric(MinecraftPacket packet) { public void handleGeneric(MinecraftPacket packet) {
// Unknown packet received. Better to close the connection. // Unknown packet received. Better to close the connection.
connection.close(); connection.close(true);
} }
@Override @Override
public void handleUnknown(ByteBuf buf) { public void handleUnknown(ByteBuf buf) {
// Unknown packet received. Better to close the connection. // Unknown packet received. Better to close the connection.
connection.close(); connection.close(true);
} }
private static class LegacyInboundConnection implements InboundConnection { private static class LegacyInboundConnection implements InboundConnection {

Datei anzeigen

@ -134,11 +134,11 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
logger.error( logger.error(
"Got an unexpected error code {} whilst contacting Mojang to log in {} ({})", "Got an unexpected error code {} whilst contacting Mojang to log in {} ({})",
profileResponse.getStatusCode(), login.getUsername(), playerIp); profileResponse.getStatusCode(), login.getUsername(), playerIp);
mcConnection.close(); mcConnection.close(true);
} }
} catch (ExecutionException e) { } catch (ExecutionException e) {
logger.error("Unable to authenticate with Mojang", e); logger.error("Unable to authenticate with Mojang", e);
mcConnection.close(); mcConnection.close(true);
} catch (InterruptedException e) { } catch (InterruptedException e) {
// not much we can do usefully // not much we can do usefully
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
@ -146,7 +146,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
}, mcConnection.eventLoop()); }, mcConnection.eventLoop());
} catch (GeneralSecurityException e) { } catch (GeneralSecurityException e) {
logger.error("Unable to enable encryption", e); logger.error("Unable to enable encryption", e);
mcConnection.close(); mcConnection.close(true);
} }
return true; return true;
} }
@ -286,7 +286,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
@Override @Override
public void handleUnknown(ByteBuf buf) { public void handleUnknown(ByteBuf buf) {
mcConnection.close(); mcConnection.close(true);
} }
@Override @Override

Datei anzeigen

@ -183,6 +183,6 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
@Override @Override
public void handleUnknown(ByteBuf buf) { public void handleUnknown(ByteBuf buf) {
// what even is going on? // what even is going on?
connection.close(); connection.close(true);
} }
} }

Datei anzeigen

@ -48,7 +48,7 @@ public class PingSessionHandler implements MinecraftSessionHandler {
public boolean handle(StatusResponse packet) { public boolean handle(StatusResponse packet) {
// All good! // All good!
completed = true; completed = true;
connection.close(); connection.close(true);
ServerPing ping = VelocityServer.GSON.fromJson(packet.getStatus(), ServerPing.class); ServerPing ping = VelocityServer.GSON.fromJson(packet.getStatus(), ServerPing.class);
result.complete(ping); result.complete(ping);