geforkt von Mirrors/Velocity
Correctly handle rapid disconnects. Fixes #31
Dieser Commit ist enthalten in:
Ursprung
8068f72729
Commit
21e72556c9
@ -104,18 +104,21 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void write(Object msg) {
|
public void write(Object msg) {
|
||||||
ensureOpen();
|
if (channel.isActive()) {
|
||||||
channel.writeAndFlush(msg, channel.voidPromise());
|
channel.writeAndFlush(msg, channel.voidPromise());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delayedWrite(Object msg) {
|
public void delayedWrite(Object msg) {
|
||||||
ensureOpen();
|
if (channel.isActive()) {
|
||||||
channel.write(msg, channel.voidPromise());
|
channel.write(msg, channel.voidPromise());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flush() {
|
public void flush() {
|
||||||
ensureOpen();
|
if (channel.isActive()) {
|
||||||
channel.flush();
|
channel.flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeWith(Object msg) {
|
public void closeWith(Object msg) {
|
||||||
|
@ -18,6 +18,13 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(MinecraftPacket packet) {
|
public void handle(MinecraftPacket packet) {
|
||||||
|
if (!connection.getProxyPlayer().isActive()) {
|
||||||
|
// Connection was left open accidentally. Close it so as to avoid "You logged in from another location"
|
||||||
|
// errors.
|
||||||
|
connection.getMinecraftConnection().close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ClientPlaySessionHandler playerHandler =
|
ClientPlaySessionHandler playerHandler =
|
||||||
(ClientPlaySessionHandler) connection.getProxyPlayer().getConnection().getSessionHandler();
|
(ClientPlaySessionHandler) connection.getProxyPlayer().getConnection().getSessionHandler();
|
||||||
if (packet instanceof KeepAlive) {
|
if (packet instanceof KeepAlive) {
|
||||||
@ -69,6 +76,13 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleUnknown(ByteBuf buf) {
|
public void handleUnknown(ByteBuf buf) {
|
||||||
|
if (!connection.getProxyPlayer().isActive()) {
|
||||||
|
// Connection was left open accidentally. Close it so as to avoid "You logged in from another location"
|
||||||
|
// errors.
|
||||||
|
connection.getMinecraftConnection().close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ClientPlaySessionHandler playerHandler =
|
ClientPlaySessionHandler playerHandler =
|
||||||
(ClientPlaySessionHandler) connection.getProxyPlayer().getConnection().getSessionHandler();
|
(ClientPlaySessionHandler) connection.getProxyPlayer().getConnection().getSessionHandler();
|
||||||
ByteBuf remapped = playerHandler.getIdRemapper().remap(buf, ProtocolConstants.Direction.CLIENTBOUND);
|
ByteBuf remapped = playerHandler.getIdRemapper().remap(buf, ProtocolConstants.Direction.CLIENTBOUND);
|
||||||
|
@ -132,7 +132,6 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
String error = ThrowableUtils.briefDescription(throwable);
|
String error = ThrowableUtils.briefDescription(throwable);
|
||||||
String userMessage;
|
String userMessage;
|
||||||
if (connectedServer != null && connectedServer.getServerInfo().equals(info)) {
|
if (connectedServer != null && connectedServer.getServerInfo().equals(info)) {
|
||||||
logger.error("{}: exception occurred in connection to {}", this, info.getName(), throwable);
|
|
||||||
userMessage = "Exception in server " + info.getName();
|
userMessage = "Exception in server " + info.getName();
|
||||||
} else {
|
} else {
|
||||||
logger.error("{}: unable to connect to server {}", this, info.getName(), throwable);
|
logger.error("{}: unable to connect to server {}", this, info.getName(), throwable);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren