Should avoid handleDisconnection() called twice

This commit is contained in:
Sotr
2019-03-06 19:22:06 +08:00
parent c815d2df75
commit d24f89d7d9
2 changed files with 30 additions and 16 deletions

View File

@@ -19,6 +19,7 @@ import io.netty.util.concurrent.GenericFutureListener;
import java.net.SocketAddress;
import java.util.Queue;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import javax.annotation.Nullable;
import javax.crypto.SecretKey;
@@ -56,7 +57,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
private PacketListener packetListener;
private IChatBaseComponent n;
private boolean o;
private boolean p;
private AtomicBoolean p = new AtomicBoolean(false); // Akarin
private int q;
private int r;
private float s;
@@ -357,10 +358,10 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
public void handleDisconnection() {
if (this.channel != null && !this.channel.isOpen()) {
if (this.p) {
if (!this.p.compareAndSet(false, true)) { // Akarin
NetworkManager.g.warn("handleDisconnection() called twice");
} else {
this.p = true;
// this.p = true; // Akarin
if (this.j() != null) {
this.i().a(this.j());
} else if (this.i() != null) {

View File

@@ -269,11 +269,13 @@ public class PlayerInteractManager {
// Tell client the block is gone immediately then process events
// Don't tell the client if its a creative sword break because its not broken!
if (world.getTileEntity(blockposition) == null && !isSwordNoBreak) {
PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(this.world, blockposition);
packet.block = Blocks.AIR.getBlockData();
((EntityPlayer) this.player).playerConnection.sendPacket(packet);
}
// Akarin start
//if (world.getTileEntity(blockposition) == null && !isSwordNoBreak) {
// PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(this.world, blockposition);
// packet.block = Blocks.AIR.getBlockData();
// ((EntityPlayer) this.player).playerConnection.sendPacket(packet);
//}
// Akarin end
event = new BlockBreakEvent(bblock, this.player.getBukkitEntity());
@@ -303,20 +305,31 @@ public class PlayerInteractManager {
return false;
}
// Let the client know the block still exists
((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
//((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); // Akarin
// Brute force all possible updates
for (EnumDirection dir : EnumDirection.values()) {
((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.shift(dir)));
}
// Akarin start
//for (EnumDirection dir : EnumDirection.values()) {
// ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.shift(dir)));
//}
// Akarin end
// Update any tile entity data for this block
TileEntity tileentity = this.world.getTileEntity(blockposition);
if (tileentity != null) {
this.player.playerConnection.sendPacket(tileentity.getUpdatePacket());
}
// Akarin start
//TileEntity tileentity = this.world.getTileEntity(blockposition);
//if (tileentity != null) {
// this.player.playerConnection.sendPacket(tileentity.getUpdatePacket());
//}
return false;
// Akarin start
} else {
if (world.getTileEntity(blockposition) == null) {
PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(this.world, blockposition);
packet.block = Blocks.AIR.getBlockData();
((EntityPlayer) this.player).playerConnection.sendPacket(packet);
}
}
// Akarin end
}
// CraftBukkit end