13
0
geforkt von Mirrors/Velocity

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'
version '1.1.0-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8
ext {
// dependency versions
textVersion = '3.0.3'
@ -41,6 +38,11 @@ allprojects {
}
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
repositories {
mavenLocal()
mavenCentral()

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -183,6 +183,6 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
@Override
public void handleUnknown(ByteBuf buf) {
// 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) {
// All good!
completed = true;
connection.close();
connection.close(true);
ServerPing ping = VelocityServer.GSON.fromJson(packet.getStatus(), ServerPing.class);
result.complete(ping);