Skip to content

Commit 82180f4

Browse files
authored
Remove patch no longer functional (#384)
1 parent 021ff49 commit 82180f4

File tree

110 files changed

+131
-212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+131
-212
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ Fork of Paper for 1.8.8 focused on improved performance and stability.
1212
- **Updating to Netty 4.1** offers the ability to use newer Java versions with epoll on Linux.
1313
- **Improved flush handling** to massively improve entity tracker performance.
1414
- **Support for Unix domain sockets** to avoid the overhead of TCP when using a proxy on the same machine.
15-
- **Using LazyRunnables** to avoid expensive thread wakeup calls when sending non-flushed packets.
1615

1716
- **More configuration options**, such as:
1817
- Customizable knockback

gradle/wrapper/gradle-wrapper.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionSha256Sum=0d585f69da091fc5b2beced877feab55a3064d43b8a1d46aeb07996b0915e0e0
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.0-bin.zip
3+
distributionSha256Sum=b266d5ff6b90eada6dc3b20cb090e3731302e553a27c5d3e4df1f0d76beaff06
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip
55
networkTimeout=10000
66
validateDistributionUrl=true
77
zipStoreBase=GRADLE_USER_HOME

patches/server/0010-Optimize-Network-Manager-and-add-advanced-packet-sup.patch

Lines changed: 72 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Also avoids spamming closed channel exception by rechecking closed state in disp
2626
and then catch exceptions and close if they fire.
2727

2828
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
29-
index 52a4ddbb898901a41dd171a34f712e7139f6db8f..108464c874585853de4f9cffc90d57f39dfbef8b 100644
29+
index 52a4ddbb898901a41dd171a34f712e7139f6db8f..baf4cb424e801dd8ae72080c089bea44de863981 100644
3030
--- a/src/main/java/net/minecraft/server/NetworkManager.java
3131
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
3232
@@ -62,7 +62,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
@@ -106,7 +106,7 @@ index 52a4ddbb898901a41dd171a34f712e7139f6db8f..108464c874585853de4f9cffc90d57f3
106106
} else {
107107
- this.j.writeLock().lock();
108108
+ java.util.List<NetworkManager.QueuedPacket> packets = new java.util.ArrayList<>(1 + extraPackets.size());
109-
+ packets.add(new NetworkManager.QueuedPacket(packet, (GenericFutureListener<? extends Future<? super Void>>) null)); // delay the future listener until the end of the extra packets
109+
+ packets.add(new NetworkManager.QueuedPacket(packet, (GenericFutureListener<? extends Future<? super Void>>[]) null)); // delay the future listener until the end of the extra packets
110110

111111
- try {
112112
- this.i.add(new NetworkManager.QueuedPacket(packet, (GenericFutureListener[]) ArrayUtils.add(agenericfuturelistener, 0, genericfuturelistener)));
@@ -128,102 +128,86 @@ index 52a4ddbb898901a41dd171a34f712e7139f6db8f..108464c874585853de4f9cffc90d57f3
128128
private void a(final Packet packet, final GenericFutureListener<? extends Future<? super Void>>[] agenericfuturelistener) {
129129
final EnumProtocol enumprotocol = EnumProtocol.a(packet);
130130
final EnumProtocol enumprotocol1 = (EnumProtocol) this.channel.attr(NetworkManager.c).get();
131-
@@ -178,6 +195,8 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
132-
}
133-
134-
if (this.channel.eventLoop().inEventLoop()) {
135-
+ // PandaSpigot start - Simplify
136-
+ /*
137-
if (enumprotocol != enumprotocol1) {
131+
@@ -182,13 +199,34 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
138132
this.a(enumprotocol);
139133
}
140-
@@ -189,42 +208,107 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
134+
135+
+ // PandaSpigot start
136+
+ EntityPlayer player = getPlayer();
137+
+ if (!isConnected()) {
138+
+ packet.onPacketDispatchFinish(player, null);
139+
+ return;
140+
+ }
141+
+ try {
142+
+ // PandaSpigot end
143+
ChannelFuture channelfuture = this.channel.writeAndFlush(packet);
144+
145+
if (agenericfuturelistener != null) {
146+
channelfuture.addListeners(agenericfuturelistener);
141147
}
142148

149+
+ // PandaSpigot start
150+
+ if (packet.hasFinishListener()) {
151+
+ channelfuture.addListener((ChannelFutureListener) channelFuture -> packet.onPacketDispatchFinish(player, channelFuture));
152+
+ }
153+
+ // PandaSpigot end
154+
+
143155
channelfuture.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
144-
+ */
145-
+ doSendPacket(packet, enumprotocol, enumprotocol1, agenericfuturelistener);
156+
+ // PandaSpigot start
157+
+ } catch (Exception e) {
158+
+ g.error("NetworkException: {}", player, e);
159+
+ close(new ChatMessage("disconnect.genericReason", "Internal Exception: " + e.getMessage()));
160+
+ packet.onPacketDispatchFinish(player, null);
161+
+ }
146162
+ // PandaSpigot end
147163
} else {
148-
- this.channel.eventLoop().execute(new Runnable() {
149-
- public void run() {
150-
- if (enumprotocol != enumprotocol1) {
151-
- NetworkManager.this.a(enumprotocol);
152-
- }
153-
-
154-
- ChannelFuture channelfuture = NetworkManager.this.channel.writeAndFlush(packet);
155-
-
156-
- if (agenericfuturelistener != null) {
157-
- channelfuture.addListeners(agenericfuturelistener);
158-
- }
159-
+ // PandaSpigot start - Simplify
160-
+ this.channel.eventLoop().execute(() -> {
161-
+ /*
162-
+ if (enumprotocol != enumprotocol1) {
163-
+ NetworkManager.this.a(enumprotocol);
164-
+ }
165-
+ ChannelFuture channelfuture = NetworkManager.this.channel.writeAndFlush(packet);
164+
this.channel.eventLoop().execute(new Runnable() {
165+
public void run() {
166+
@@ -196,35 +234,80 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
167+
NetworkManager.this.a(enumprotocol);
168+
}
166169

167-
- channelfuture.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
168-
+ if (agenericfuturelistener != null) {
169-
+ channelfuture.addListeners(agenericfuturelistener);
170-
}
170+
+ // PandaSpigot start
171+
+ EntityPlayer player = getPlayer();
172+
+ if (!isConnected()) {
173+
+ packet.onPacketDispatchFinish(player, null);
174+
+ return;
175+
+ }
176+
+ try {
177+
+ // PandaSpigot end
178+
ChannelFuture channelfuture = NetworkManager.this.channel.writeAndFlush(packet);
179+
180+
if (agenericfuturelistener != null) {
181+
channelfuture.addListeners(agenericfuturelistener);
182+
}
183+
184+
+ // PandaSpigot start
185+
+ if (packet.hasFinishListener()) {
186+
+ channelfuture.addListener((ChannelFutureListener) channelFuture -> packet.onPacketDispatchFinish(player, channelFuture));
187+
+ }
188+
+ // PandaSpigot end
171189
+
172-
+ channelfuture.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
173-
+ */
174-
+ doSendPacket(packet, enumprotocol, enumprotocol1, agenericfuturelistener);
190+
channelfuture.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
191+
+ // PandaSpigot start
192+
+ } catch (Exception e) {
193+
+ g.error("NetworkException: {}", player, e);
194+
+ close(new ChatMessage("disconnect.genericReason", "Internal Exception: " + e.getMessage()));
195+
+ packet.onPacketDispatchFinish(player, null);
196+
+ }
197+
+ // PandaSpigot end
198+
}
175199
});
176-
+ // PandaSpigot end
177200
}
178201

179202
}
180203

181204
- private void m() {
182205
- if (this.channel != null && this.channel.isOpen()) {
183206
- this.j.readLock().lock();
184-
+ // PandaSpigot start - Add helper method
185-
+ private void doSendPacket(Packet<?> packet, EnumProtocol enumprotocol, EnumProtocol enumprotocol1, GenericFutureListener<? extends Future<? super Void>>[] agenericfuturelistener) {
186-
+ if (enumprotocol != enumprotocol1) {
187-
+ NetworkManager.this.a(enumprotocol);
188-
+ }
189-
207+
-
190208
- try {
191209
- while (!this.i.isEmpty()) {
192210
- NetworkManager.QueuedPacket networkmanager_queuedpacket = (NetworkManager.QueuedPacket) this.i.poll();
193-
+ // PandaSpigot start
194-
+ EntityPlayer player = getPlayer();
195-
+ if (!isConnected()) {
196-
+ packet.onPacketDispatchFinish(player, null);
197-
+ return;
198-
+ }
199-
+ try {
200-
+ // PandaSpigot end
201-
+ ChannelFuture channelfuture = NetworkManager.this.channel.writeAndFlush(packet);
202-
203-
- this.a(networkmanager_queuedpacket.a, networkmanager_queuedpacket.b);
204-
- }
205-
- } finally {
206-
- this.j.readLock().unlock();
207-
+ if (agenericfuturelistener != null) {
208-
+ channelfuture.addListeners(agenericfuturelistener);
209-
+ }
210-
+
211-
+ // PandaSpigot start
212-
+ if (packet.hasFinishListener()) {
213-
+ channelfuture.addListener((ChannelFutureListener) channelFuture -> packet.onPacketDispatchFinish(player, channelFuture));
214-
+ }
215-
+ // PandaSpigot end
216-
+ channelfuture.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
217-
+ // PandaSpigot start
218-
+ } catch (Exception e) {
219-
+ g.error("NetworkException: {}", player, e);
220-
+ close(new ChatMessage("disconnect.genericReason", "Internal Exception: " + e.getMessage()));
221-
+ packet.onPacketDispatchFinish(player, null);
222-
+ }
223-
+ // PandaSpigot end
224-
+ }
225-
+ // PandaSpigot end
226-
+
227211
+ // PandaSpigot start - rewrite this to be safer if ran off main thread
228212
+ private boolean sendPacketQueue() { return this.m(); } // OBFHELPER // void -> boolean
229213
+ private boolean m() { // void -> boolean
@@ -240,7 +224,11 @@ index 52a4ddbb898901a41dd171a34f712e7139f6db8f..108464c874585853de4f9cffc90d57f3
240224
+ }
241225
+ return false;
242226
+ }
243-
+
227+
228+
- this.a(networkmanager_queuedpacket.a, networkmanager_queuedpacket.b);
229+
- }
230+
- } finally {
231+
- this.j.readLock().unlock();
244232
+ private boolean processQueue() {
245233
+ if (i.isEmpty()) return true;
246234
+ // If we are on main, we are safe here in that nothing else should be processing queue off main anymore
@@ -267,7 +255,7 @@ index 52a4ddbb898901a41dd171a34f712e7139f6db8f..108464c874585853de4f9cffc90d57f3
267255

268256
public void a() {
269257
this.m();
270-
@@ -239,9 +323,23 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
258+
@@ -239,9 +322,23 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
271259
return this.l;
272260
}
273261

@@ -291,15 +279,15 @@ index 52a4ddbb898901a41dd171a34f712e7139f6db8f..108464c874585853de4f9cffc90d57f3
291279
// Spigot End
292280
if (this.channel.isOpen()) {
293281
this.channel.close(); // We can't wait as this may be called from an event loop.
294-
@@ -260,6 +358,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
282+
@@ -260,6 +357,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
295283
this.channel.pipeline().addBefore("prepender", "encrypt", new PacketEncrypter(MinecraftEncryption.a(1, secretkey)));
296284
}
297285

298286
+ public boolean isConnected() { return this.g(); } // PandaSpigot - OBFHELPER
299287
public boolean g() {
300288
return this.channel != null && this.channel.isOpen();
301289
}
302-
@@ -314,9 +413,9 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
290+
@@ -314,9 +412,9 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
303291
} else if (this.getPacketListener() != null) {
304292
this.getPacketListener().a(new ChatComponentText("Disconnected"));
305293
}
@@ -311,7 +299,7 @@ index 52a4ddbb898901a41dd171a34f712e7139f6db8f..108464c874585853de4f9cffc90d57f3
311299
}
312300

313301
}
314-
@@ -328,8 +427,8 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
302+
@@ -328,8 +426,8 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
315303

316304
static class QueuedPacket {
317305

@@ -322,7 +310,7 @@ index 52a4ddbb898901a41dd171a34f712e7139f6db8f..108464c874585853de4f9cffc90d57f3
322310

323311
public QueuedPacket(Packet packet, GenericFutureListener<? extends Future<? super Void>>... agenericfuturelistener) {
324312
this.a = packet;
325-
@@ -348,4 +447,44 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
313+
@@ -348,4 +446,44 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
326314
return this.channel.remoteAddress();
327315
}
328316
// Spigot End

0 commit comments

Comments
 (0)