Scissors/patches/server/0011-Don-t-query-player-data-in-the-nbt-component.patch
2024-05-08 12:47:03 -05:00

40 lines
2.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Wed, 8 May 2024 12:35:56 -0500
Subject: [PATCH] Don't query player data in the `nbt` component
diff --git a/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java b/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java
index 2750702cff35762bc817ffbe5bf81631e86bc49b..f69261dae717cbb3e7bc9f5e0767adc897f0388d 100644
--- a/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java
+++ b/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java
@@ -8,12 +8,15 @@ import com.mojang.serialization.codecs.RecordCodecBuilder;
import java.util.List;
import java.util.stream.Stream;
import javax.annotation.Nullable;
+
+import me.totalfreedom.scissors.ScissorsConfig;
import net.minecraft.advancements.critereon.NbtPredicate;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.arguments.selector.EntitySelector;
import net.minecraft.commands.arguments.selector.EntitySelectorParser;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.Entity;
+import org.bukkit.entity.Player;
public record EntityDataSource(String selectorPattern, @Nullable EntitySelector compiledSelector) implements DataSource {
public static final MapCodec<EntityDataSource> SUB_CODEC = RecordCodecBuilder.mapCodec(
@@ -39,7 +42,11 @@ public record EntityDataSource(String selectorPattern, @Nullable EntitySelector
public Stream<CompoundTag> getData(CommandSourceStack source) throws CommandSyntaxException {
if (this.compiledSelector != null) {
List<? extends Entity> list = this.compiledSelector.findEntities(source);
- return list.stream().map(NbtPredicate::getEntityTagToCompare);
+ // Scissors start
+ Stream<? extends Entity> stream = list.stream();
+ if (ScissorsConfig.excludePlayersFromNbtComponents) stream = stream.filter((entity) -> !(entity instanceof Player));
+ return stream.map(NbtPredicate::getEntityTagToCompare);
+ // Scissors end
} else {
return Stream.empty();
}