From b1dbfb9380cb44fae82e972591c7cecc4f2c90b1 Mon Sep 17 00:00:00 2001 From: rbrick Date: Sun, 3 Apr 2016 02:34:40 -0500 Subject: [PATCH] Temporarily revert changes in 1045 diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java index 474afb52a..b35650ee0 100644 --- a/src/main/java/net/minecraft/server/NetworkManager.java +++ b/src/main/java/net/minecraft/server/NetworkManager.java @@ -28,17 +28,6 @@ import org.spigotmc.SpigotCompressor; import org.spigotmc.SpigotDecompressor; // Spigot end -// Poweruser start -import java.util.Collections; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.TimeUnit; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import net.minecraft.util.io.netty.channel.EventLoop; -// Poweruser end - public class NetworkManager extends SimpleChannelInboundHandler { private static final Logger i = LogManager.getLogger(); @@ -81,35 +70,6 @@ public class NetworkManager extends SimpleChannelInboundHandler { public static final GenericFutureListener[] emptyListenerArray = new GenericFutureListener[0]; // Poweruser - // Poweruser start - private static final Map senderTasks = Collections.synchronizedMap(new HashMap()); - private PacketSender assignedPacketSender; - - public static class PacketSender implements Runnable { - - private Queue commonPacketQueue = new ConcurrentLinkedQueue(); - - private void queuePacket(QueuedPacket queuedPacket) { - this.commonPacketQueue.add(queuedPacket); - } - - private void queuePackets(Collection collection) { - this.commonPacketQueue.addAll(collection); - } - - @Override - public void run() { - QueuedPacket packet = null; - while((packet = this.commonPacketQueue.poll()) != null) { - NetworkManager manager = QueuedPacket.getNetworkManager(packet); - if(manager.isConnected()) { - manager.b(QueuedPacket.a(packet), QueuedPacket.b(packet)); - } - } - } - } - // Poweruser end - public NetworkManager(boolean flag) { this.j = flag; } @@ -122,18 +82,6 @@ public class NetworkManager extends SimpleChannelInboundHandler { this.preparing = false; // Spigot End this.a(EnumProtocol.HANDSHAKING); - // Poweruser start - EventLoop eventLoop = this.m.eventLoop(); - PacketSender sender; - if(senderTasks.containsKey(eventLoop)) { - sender = senderTasks.get(eventLoop); - } else { - sender = new NetworkManager.PacketSender(); - senderTasks.put(eventLoop, sender); - eventLoop.scheduleAtFixedRate(sender, 5L, 5L, TimeUnit.MILLISECONDS); - } - this.assignedPacketSender = sender; - // Poweruser end } public void a(EnumProtocol enumprotocol) { @@ -178,26 +126,12 @@ public class NetworkManager extends SimpleChannelInboundHandler { } public void handle(Packet packet, GenericFutureListener... agenericfuturelistener) { - /* if (this.m != null && this.m.isOpen()) { this.i(); this.b(packet, agenericfuturelistener); } else { this.l.add(new QueuedPacket(packet, agenericfuturelistener)); } - */ - // Poweruser start - QueuedPacket queuedpacket = new QueuedPacket(this, packet, agenericfuturelistener); - if(this.assignedPacketSender != null && this.isConnected()) { - if(!this.l.isEmpty()) { - this.assignedPacketSender.queuePackets(this.l); - this.l.clear(); - } - this.assignedPacketSender.queuePacket(queuedpacket); - } else { - this.l.add(queuedpacket); - } - // Poweruser end } private void b(Packet packet, GenericFutureListener[] agenericfuturelistener) { @@ -234,7 +168,7 @@ public class NetworkManager extends SimpleChannelInboundHandler { } public void a() { - //this.i(); // Poweruser - done through PacketSender + this.i(); EnumProtocol enumprotocol = (EnumProtocol) this.m.attr(d).get(); if (this.p != enumprotocol) { @@ -261,7 +195,8 @@ public class NetworkManager extends SimpleChannelInboundHandler { this.o.a(); } - //this.m.flush(); // Poweruser - done through PacketSender + + this.m.flush(); } public SocketAddress getSocketAddress() { @@ -269,7 +204,6 @@ public class NetworkManager extends SimpleChannelInboundHandler { } public void close(IChatBaseComponent ichatbasecomponent) { - this.assignedPacketSender = null; // Poweruser // Spigot Start this.preparing = false; this.k.clear(); // Spigot Update - 20140921a diff --git a/src/main/java/net/minecraft/server/QueuedPacket.java b/src/main/java/net/minecraft/server/QueuedPacket.java index 06480afef..fdebf9dd3 100644 --- a/src/main/java/net/minecraft/server/QueuedPacket.java +++ b/src/main/java/net/minecraft/server/QueuedPacket.java @@ -8,16 +8,7 @@ class QueuedPacket { private final Packet a; private final GenericFutureListener[] b; - // Poweruser start - private final NetworkManager manager; - - static NetworkManager getNetworkManager(QueuedPacket queuedpacket) { - return queuedpacket.manager; - } - - public QueuedPacket(NetworkManager manager, Packet packet, GenericFutureListener... agenericfuturelistener) { - this.manager = manager; - // Poweruser end + public QueuedPacket(Packet packet, GenericFutureListener... agenericfuturelistener) { this.a = packet; this.b = agenericfuturelistener; } -- 2.13.3