Skip to content

multiple patches + some cleanup around touched patches #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ac10e83
WIP
mechoriet Apr 23, 2023
0e0af19
work
mechoriet Apr 23, 2023
4401aa0
fix some comments and weird lines
mechoriet Apr 23, 2023
3690e28
rebase
mechoriet Apr 23, 2023
b470b39
woops wrong if changed
mechoriet Apr 27, 2023
c7d7d47
resolved some issues + add improved async task scheduler from akarin …
mechoriet Apr 30, 2023
1be1740
comments for api patches
mechoriet Apr 30, 2023
cf34f07
remove continued heavy call to checking if protocolsupport is there w…
mechoriet May 22, 2023
952429f
changes + removed one patch and combined it in worldutil patch touche…
mechoriet May 22, 2023
e38c6cf
fixes
mechoriet May 22, 2023
a160033
add more comments
mechoriet May 22, 2023
8a0b2a0
add comments
mechoriet May 24, 2023
64e8e17
breaks plugins since they don't get fired
mechoriet Jul 1, 2023
a6ee0ee
fixed some requested changes
mechoriet Jul 7, 2023
997aab6
this looks cleaner with same functionality without the redundent chec…
mechoriet Jul 7, 2023
a6421e6
resolved
mechoriet Jul 8, 2023
27e8790
revert this change cause event listener check was removed cause some …
mechoriet Jul 8, 2023
5477125
hmm
mechoriet Jul 8, 2023
532fda5
grrr
mechoriet Jul 8, 2023
fa255ab
grrr x2
mechoriet Jul 8, 2023
3974d49
use the fucking helper
uRyanxD Jul 9, 2023
d47ac79
use the fucking helper 2
uRyanxD Jul 9, 2023
e21b5ea
use helper 3
uRyanxD Jul 9, 2023
bb55352
cleanup
uRyanxD Jul 9, 2023
1f055e5
only call if has listener + use helper
uRyanxD Jul 9, 2023
7ca39c0
use helper 666
uRyanxD Jul 9, 2023
337cc5d
cleanup
uRyanxD Jul 9, 2023
fd1f8c1
ops
uRyanxD Jul 9, 2023
a0a888e
cleanup
uRyanxD Jul 9, 2023
37e8a5b
remove uneless y
uRyanxD Jul 9, 2023
c3a9639
ops
uRyanxD Jul 9, 2023
f687762
cleanup
uRyanxD Jul 10, 2023
a5b369d
ops
uRyanxD Jul 10, 2023
34b52d8
Merge branch 'master' into pr/multipatch
uRyanxD Sep 9, 2023
50f3090
rebuild patches
uRyanxD Sep 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
397 changes: 397 additions & 0 deletions patches/api/0027-Use-ASM-for-event-executors.patch

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: mechoriet <[email protected]>
Date: Sun, 23 Apr 2023 13:07:05 +0200
Subject: [PATCH] Performance & Concurrency Improvements to Permissions no
double lookup


diff --git a/src/main/java/org/bukkit/permissions/PermissibleBase.java b/src/main/java/org/bukkit/permissions/PermissibleBase.java
index 3b95061aad53083219ca653c1ab5c629c2254e05..aa607fe975b7740238082dc5034ad8556171108e 100644
--- a/src/main/java/org/bukkit/permissions/PermissibleBase.java
+++ b/src/main/java/org/bukkit/permissions/PermissibleBase.java
@@ -68,8 +68,11 @@ public class PermissibleBase implements Permissible {

String name = inName.toLowerCase();

- if (isPermissionSet(name)) {
- return permissions.get(name).getValue();
+ // PandaSpigot start
+ PermissionAttachmentInfo info = permissions.get(name);
+ if(info != null) {
+ return info.getValue();
+ // PandaSpigot end
} else {
Permission perm = Bukkit.getServer().getPluginManager().getPermission(name);

@@ -88,13 +91,16 @@ public class PermissibleBase implements Permissible {

String name = perm.getName().toLowerCase();

- if (isPermissionSet(name)) {
- return permissions.get(name).getValue();
+ // PandaSpigot start
+ PermissionAttachmentInfo info = permissions.get(name);
+ if(info != null) {
+ return info.getValue();
+ // PandaSpigot end
}
return perm.getDefault().getValue(isOp());
}

- public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) {
+ public synchronized PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) { // PandaSpigot - synchronized
if (name == null) {
throw new IllegalArgumentException("Permission name cannot be null");
} else if (plugin == null) {
@@ -111,7 +117,7 @@ public class PermissibleBase implements Permissible {
return result;
}

- public PermissionAttachment addAttachment(Plugin plugin) {
+ public synchronized PermissionAttachment addAttachment(Plugin plugin) { // PandaSpigot - synchronized
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null");
} else if (!plugin.isEnabled()) {
@@ -126,7 +132,7 @@ public class PermissibleBase implements Permissible {
return result;
}

- public void removeAttachment(PermissionAttachment attachment) {
+ public synchronized void removeAttachment(PermissionAttachment attachment) { // PandaSpigot - synchronized
if (attachment == null) {
throw new IllegalArgumentException("Attachment cannot be null");
}
@@ -145,7 +151,7 @@ public class PermissibleBase implements Permissible {
}
}

- public void recalculatePermissions() {
+ public synchronized void recalculatePermissions() { // PandaSpigot - synchronized
clearPermissions();
Set<Permission> defaults = Bukkit.getServer().getPluginManager().getDefaultPermissions(isOp());
Bukkit.getServer().getPluginManager().subscribeToDefaultPerms(isOp(), parent);
@@ -192,7 +198,7 @@ public class PermissibleBase implements Permissible {
}
}

- public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) {
+ public synchronized PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) { // PandaSpigot - synchronized
if (name == null) {
throw new IllegalArgumentException("Permission name cannot be null");
} else if (plugin == null) {
@@ -210,7 +216,7 @@ public class PermissibleBase implements Permissible {
return result;
}

- public PermissionAttachment addAttachment(Plugin plugin, int ticks) {
+ public synchronized PermissionAttachment addAttachment(Plugin plugin, int ticks) { // PandaSpigot - synchronized
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null");
} else if (!plugin.isEnabled()) {
@@ -228,7 +234,7 @@ public class PermissibleBase implements Permissible {
}
}

- public Set<PermissionAttachmentInfo> getEffectivePermissions() {
+ public synchronized Set<PermissionAttachmentInfo> getEffectivePermissions() { // PandaSpigot - synchronized
return new HashSet<PermissionAttachmentInfo>(permissions.values());
}

52 changes: 52 additions & 0 deletions patches/server/0001-Fix-Decompilation-errors.patch
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,19 @@ index 4bf790cdffdbc8950450644a813d9c7bb539793d..0446e2be5003e8aa785618de48767d16
}

}
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 0c49a256cc481af1ceb7a873b03763e1d942a362..7a7bb58d8632c34259215b1372140ececf5c825a 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -462,7 +462,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
EntityLiving entityliving = this.bt();

if (entityliving != null) {
- EntityTypes.MonsterEggInfo entitytypes_monsteregginfo = (EntityTypes.MonsterEggInfo) EntityTypes.eggInfo.get(Integer.valueOf(EntityTypes.a(entityliving)));
+ EntityTypes.MonsterEggInfo entitytypes_monsteregginfo = (EntityTypes.MonsterEggInfo) EntityTypes.eggInfo.get(EntityTypes.a(entityliving));

if (entitytypes_monsteregginfo != null) {
this.b(entitytypes_monsteregginfo.e);
diff --git a/src/main/java/net/minecraft/server/EntityTameableAnimal.java b/src/main/java/net/minecraft/server/EntityTameableAnimal.java
index 2b170a15a42b257e92178df8124fd4ce64fa26c9..1cc087d0470c60e26f7c585e1d50156bce6b1f46 100644
--- a/src/main/java/net/minecraft/server/EntityTameableAnimal.java
Expand Down Expand Up @@ -2563,6 +2576,45 @@ index 63fbf9447e1b7250613ee39e72c3d7fae35f3081..906aa3d7e54887a29e241a90abe50e84
}

public void a(IJsonStatistic ijsonstatistic) {
diff --git a/src/main/java/net/minecraft/server/StructureGenerator.java b/src/main/java/net/minecraft/server/StructureGenerator.java
index e76acfc4f39287f8f3078ce1b2516d4ca8fc4c6c..91f2e401f2be2baf3cfc350b0c338f5fae2e9b2d 100644
--- a/src/main/java/net/minecraft/server/StructureGenerator.java
+++ b/src/main/java/net/minecraft/server/StructureGenerator.java
@@ -18,14 +18,14 @@ public abstract class StructureGenerator extends WorldGenBase {

protected final void a(World world, final int i, final int j, int k, int l, ChunkSnapshot chunksnapshot) {
this.a(world);
- if (!this.e.containsKey(Long.valueOf(ChunkCoordIntPair.a(i, j)))) {
+ if (!this.e.containsKey(ChunkCoordIntPair.a(i, j))) {
this.b.nextInt();

try {
if (this.a(i, j)) {
StructureStart structurestart = this.b(i, j);

- this.e.put(Long.valueOf(ChunkCoordIntPair.a(i, j)), structurestart);
+ this.e.put(ChunkCoordIntPair.a(i, j), structurestart);
this.a(i, j, structurestart);
}

@@ -42,7 +42,7 @@ public abstract class StructureGenerator extends WorldGenBase {
return this.a();
}
});
- crashreportsystemdetails.a("Chunk location", (Object) String.format("%d,%d", new Object[] { Integer.valueOf(i), Integer.valueOf(j)}));
+ crashreportsystemdetails.a("Chunk location", (Object) String.format("%d,%d", new Object[] {i, j}));
crashreportsystemdetails.a("Chunk pos hash", new Callable() {
public String a() throws Exception {
return String.valueOf(ChunkCoordIntPair.a(i, j));
@@ -226,7 +226,7 @@ public abstract class StructureGenerator extends WorldGenBase {
StructureStart structurestart = WorldGenFactory.a(nbttagcompound1, world);

if (structurestart != null) {
- this.e.put(Long.valueOf(ChunkCoordIntPair.a(i, j)), structurestart);
+ this.e.put(ChunkCoordIntPair.a(i, j), structurestart);
}
}
}
diff --git a/src/main/java/net/minecraft/server/WeightedRandom.java b/src/main/java/net/minecraft/server/WeightedRandom.java
index 2bbcfa3c7bbb9f304f4817dd1f9a260e7df366b1..58789a31ed2d1fdda2c33a576957c3ed9e30ec78 100644
--- a/src/main/java/net/minecraft/server/WeightedRandom.java
Expand Down
2 changes: 1 addition & 1 deletion patches/server/0023-Player-Chunk-Load-Unload-Events.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Player Chunk Load/Unload Events


diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 0c49a256cc481af1ceb7a873b03763e1d942a362..23524af2dd05a6f14ff3bddbf524c5d4d483290f 100644
index 7a7bb58d8632c34259215b1372140ececf5c825a..f147724e99c3ca8bd72bfaf3da6c92aefb5cd4de 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -241,6 +241,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0052-Add-packet-limiter-config.patch
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ index 0000000000000000000000000000000000000000..d61d44e8e1126ed3bea6e633cc0bdebb
+ }
+}
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
index df8ff41f691626de37f706df187269bee032358f..5c631068db79615bf51ed357bc9bda2b0ebb0c3b 100644
index df8ff41f691626de37f706df187269bee032358f..87ecc1b9a46bfcc146b7b42f142cac46c02faa9c 100644
--- a/src/main/java/net/minecraft/server/NetworkManager.java
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
@@ -113,6 +113,22 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
Expand All @@ -325,7 +325,7 @@ index df8ff41f691626de37f706df187269bee032358f..5c631068db79615bf51ed357bc9bda2b
+ this.close(reason[0]);
+ this.k();
+ this.stopReadingPackets = true;
+ }, null);
+ }, (GenericFutureListener<? extends Future<? super Void>>) null);
+ }
+ // PandaSpigot end - packet limiter
public NetworkManager(EnumProtocolDirection enumprotocoldirection) {
Expand Down
2 changes: 1 addition & 1 deletion patches/server/0059-Optimise-removeQueue.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Optimise removeQueue


diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 77068cd022e677fbf284df3d8aff95325089ce4f..0a4acf1e7b78eaeeca2606dbc46cdc5d703b8fad 100644
index f147724e99c3ca8bd72bfaf3da6c92aefb5cd4de..22eda596ea5b06f3346814e9d8cecb15f828f58d 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -34,7 +34,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
Expand Down
35 changes: 28 additions & 7 deletions patches/server/0066-Fix-issue-with-ProtocolSupport.patch
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,44 @@ The arrays in encryption packets are limited to 256 bytes.

diff --git a/src/main/java/com/hpfxd/pandaspigot/CompatHacks.java b/src/main/java/com/hpfxd/pandaspigot/CompatHacks.java
new file mode 100644
index 0000000000000000000000000000000000000000..c45655f5232934db455aaa5d2d3ff721a5733051
index 0000000000000000000000000000000000000000..1a36e0c9869ff4d196ab2910cf281146bef5985a
--- /dev/null
+++ b/src/main/java/com/hpfxd/pandaspigot/CompatHacks.java
@@ -0,0 +1,11 @@
@@ -0,0 +1,32 @@
+package com.hpfxd.pandaspigot;
+
+import org.bukkit.Bukkit;
+
+public class CompatHacks {
+ private CompatHacks() {}
+ public static boolean hasProtocolSupport() {
+ return Bukkit.getPluginManager().isPluginEnabled("ProtocolSupport");
+
+ private static CompatHacks instance;
+ private boolean isChecked = false, isLoaded = false;
+
+ public CompatHacks() {
+ instance = this;
+ }
+
+ public boolean hasProtocolSupport() {
+ return isChecked ? isLoaded : processCheck();
+ }
+
+
+ private boolean processCheck() {
+ if (!isChecked) {
+ isChecked = true;
+ isLoaded = Bukkit.getPluginManager().isPluginEnabled("ProtocolSupport");
+ }
+ return isLoaded;
+ }
+
+ public static CompatHacks getInstance() {
+ return instance == null ? new CompatHacks() : instance;
+ }
+
+}
+
diff --git a/src/main/java/net/minecraft/server/PacketDataSerializer.java b/src/main/java/net/minecraft/server/PacketDataSerializer.java
index 6c46349fb24856bb2b0f94d84536f64d96daeece..ad33280bb8baab581a4ac17b5fe78022134c676b 100644
index 6c46349fb24856bb2b0f94d84536f64d96daeece..2f1b500d4dd797475363cfc1e15b37aa4120d032 100644
--- a/src/main/java/net/minecraft/server/PacketDataSerializer.java
+++ b/src/main/java/net/minecraft/server/PacketDataSerializer.java
@@ -31,7 +31,21 @@ public class PacketDataSerializer extends ByteBuf {
Expand All @@ -49,7 +70,7 @@ index 6c46349fb24856bb2b0f94d84536f64d96daeece..ad33280bb8baab581a4ac17b5fe78022
+ * it's still much better than the old system of having no limit,
+ * which would leave the server vulnerable to packets up to 2 GIGABYTES in size.
+ */
+ this.allowLargePackets = com.hpfxd.pandaspigot.CompatHacks.hasProtocolSupport();
+ this.allowLargePackets = com.hpfxd.pandaspigot.CompatHacks.getInstance().hasProtocolSupport();
+ // PandaSpigot end
this.a = bytebuf;
}
Expand Down
Loading