aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVaan1310 <[email protected]>2024-12-08 23:37:39 +0100
committerGitHub <[email protected]>2024-12-08 17:37:39 -0500
commitc17ef64339ab27e5e50f331e53b00f6de45f7444 (patch)
tree86d9438a7a0a476859be50097a1e3711ac4505ff
parent15b2aa1d30a24f07671671cf82fe09fdce1f3b03 (diff)
downloadPaper-c17ef64339ab27e5e50f331e53b00f6de45f7444.tar.gz
Paper-c17ef64339ab27e5e50f331e53b00f6de45f7444.zip
Fix/scoreboard delegate (#11453)
-rw-r--r--patches/server/0009-MC-Utils.patch51
-rw-r--r--patches/server/1075-Expand-scoreboard-tag-count-validation-to-API-set.patch28
2 files changed, 79 insertions, 0 deletions
diff --git a/patches/server/0009-MC-Utils.patch b/patches/server/0009-MC-Utils.patch
index 89b8e3e9c8..c9d3f6c204 100644
--- a/patches/server/0009-MC-Utils.patch
+++ b/patches/server/0009-MC-Utils.patch
@@ -4805,6 +4805,57 @@ index 0000000000000000000000000000000000000000..a4ac34ebb58a404f4fca7e763e61d4ab
+ }
+ }
+}
+diff --git a/src/main/java/io/papermc/paper/util/SizeLimitedSet.java b/src/main/java/io/papermc/paper/util/SizeLimitedSet.java
+new file mode 100644
+index 0000000000000000000000000000000000000000..1eee077b1e2c6d41bdaa4f1a477c715b13981c6d
+--- /dev/null
++++ b/src/main/java/io/papermc/paper/util/SizeLimitedSet.java
+@@ -0,0 +1,45 @@
++package io.papermc.paper.util;
++
++import com.google.common.collect.ForwardingSet;
++import java.util.Collection;
++import java.util.Set;
++import org.jspecify.annotations.NullMarked;
++import org.jspecify.annotations.Nullable;
++
++@NullMarked
++public class SizeLimitedSet<E> extends ForwardingSet<E> {
++
++ private final Set<E> delegate;
++ private final int maxSize;
++
++ public SizeLimitedSet(final Set<E> delegate, final int maxSize) {
++ this.delegate = delegate;
++ this.maxSize = maxSize;
++ }
++
++ @Override
++ public boolean add(final E element) {
++ if (this.size() >= this.maxSize) {
++ return false;
++ }
++ return super.add(element);
++ }
++
++ @Override
++ public boolean addAll(final Collection<? extends @Nullable E> collection) {
++ if ((collection.size() + this.size()) >= this.maxSize) {
++ return false;
++ }
++ boolean edited = false;
++
++ for (final E element : collection) {
++ edited |= super.add(element);
++ }
++ return edited;
++ }
++
++ @Override
++ protected Set<E> delegate() {
++ return this.delegate;
++ }
++}
diff --git a/src/main/java/io/papermc/paper/util/StackWalkerUtil.java b/src/main/java/io/papermc/paper/util/StackWalkerUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..f7114d5b8f2f93f62883e24da29afaf9f74ee1a6
diff --git a/patches/server/1075-Expand-scoreboard-tag-count-validation-to-API-set.patch b/patches/server/1075-Expand-scoreboard-tag-count-validation-to-API-set.patch
new file mode 100644
index 0000000000..e1b3b2a87b
--- /dev/null
+++ b/patches/server/1075-Expand-scoreboard-tag-count-validation-to-API-set.patch
@@ -0,0 +1,28 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Intybyte <[email protected]>
+Date: Mon, 21 Oct 2024 01:41:04 +0200
+Subject: [PATCH] Expand scoreboard tag count validation to API set
+
+
+diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
+index 1b547be0fe97119edf4f29666cfe0037e0c778e0..7ac7d0729705cb02f22277be3c467aed4f69ec0e 100644
+--- a/src/main/java/net/minecraft/world/entity/Entity.java
++++ b/src/main/java/net/minecraft/world/entity/Entity.java
+@@ -586,7 +586,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
+ this.packetPositionCodec = new VecDeltaCodec();
+ this.uuid = Mth.createInsecureUUID(this.random);
+ this.stringUUID = this.uuid.toString();
+- this.tags = Sets.newHashSet();
++ this.tags = new io.papermc.paper.util.SizeLimitedSet<>(new it.unimi.dsi.fastutil.objects.ObjectOpenHashSet<>(), MAX_ENTITY_TAG_COUNT); // Paper - fully limit tag size - replace set impl
+ this.pistonDeltas = new double[]{0.0D, 0.0D, 0.0D};
+ this.mainSupportingBlockPos = Optional.empty();
+ this.onGroundNoBlocks = false;
+@@ -677,7 +677,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
+ }
+
+ public boolean addTag(String tag) {
+- return this.tags.size() >= 1024 ? false : this.tags.add(tag);
++ return this.tags.add(tag); // Paper - fully limit tag size - replace set impl
+ }
+
+ public boolean removeTag(String tag) {