mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-25 02:27:38 +01:00
Remove writeAndFlush
This commit is contained in:
parent
b304e1328a
commit
54fd65eded
@ -1305,11 +1305,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
} else {
|
||||
disconnectPacket = new DisconnectPacket(component);
|
||||
}
|
||||
if (playerConnection instanceof PlayerSocketConnection) {
|
||||
((PlayerSocketConnection) playerConnection).writeAndFlush(disconnectPacket);
|
||||
} else {
|
||||
playerConnection.sendPacket(disconnectPacket);
|
||||
}
|
||||
playerConnection.sendPacket(disconnectPacket);
|
||||
playerConnection.disconnect();
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@ import net.minestom.server.network.packet.server.login.LoginSuccessPacket;
|
||||
import net.minestom.server.network.packet.server.play.DisconnectPacket;
|
||||
import net.minestom.server.network.packet.server.play.KeepAlivePacket;
|
||||
import net.minestom.server.network.player.PlayerConnection;
|
||||
import net.minestom.server.network.player.PlayerSocketConnection;
|
||||
import net.minestom.server.utils.StringUtils;
|
||||
import net.minestom.server.utils.async.AsyncUtils;
|
||||
import net.minestom.server.utils.debug.DebugUtils;
|
||||
@ -240,11 +239,7 @@ public final class ConnectionManager {
|
||||
}
|
||||
// Send login success packet
|
||||
LoginSuccessPacket loginSuccessPacket = new LoginSuccessPacket(player.getUuid(), player.getUsername());
|
||||
if (playerConnection instanceof PlayerSocketConnection socketConnection) {
|
||||
socketConnection.writeAndFlush(loginSuccessPacket);
|
||||
} else {
|
||||
playerConnection.sendPacket(loginSuccessPacket);
|
||||
}
|
||||
playerConnection.sendPacket(loginSuccessPacket);
|
||||
playerConnection.setConnectionState(ConnectionState.PLAY);
|
||||
if (register) registerPlayer(player);
|
||||
this.waitingPlayers.relaxedOffer(player);
|
||||
|
@ -153,7 +153,7 @@ public class PlayerSocketConnection extends PlayerConnection {
|
||||
Check.stateCondition(compressed, "Compression is already enabled!");
|
||||
final int threshold = MinecraftServer.getCompressionThreshold();
|
||||
Check.stateCondition(threshold == 0, "Compression cannot be enabled because the threshold is equal to 0");
|
||||
writeAndFlush(new SetCompressionPacket(threshold));
|
||||
sendPacket(new SetCompressionPacket(threshold));
|
||||
this.compressed = true;
|
||||
}
|
||||
|
||||
@ -182,14 +182,6 @@ public class PlayerSocketConnection extends PlayerConnection {
|
||||
write(buffer, buffer.position(), buffer.remaining());
|
||||
}
|
||||
|
||||
public void writeAndFlush(@NotNull ServerPacket packet) {
|
||||
final boolean compressed = this.compressed;
|
||||
this.workerQueue.relaxedOffer(() -> {
|
||||
writeServerPacketSync(packet, compressed);
|
||||
flushSync();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
this.workerQueue.relaxedOffer(this::flushSync);
|
||||
|
@ -83,6 +83,8 @@ public final class Worker extends MinestomThread {
|
||||
|
||||
public void disconnect(PlayerSocketConnection connection, SocketChannel channel) {
|
||||
assert !connection.isOnline();
|
||||
assert Thread.currentThread() == this;
|
||||
connection.flushSync();
|
||||
try {
|
||||
channel.close();
|
||||
this.connectionMap.remove(channel);
|
||||
|
Loading…
Reference in New Issue
Block a user