From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Chipmunk <65827213+ChipmunkMC@users.noreply.github.com> Date: Mon, 1 May 2023 09:13:50 -0400 Subject: [PATCH] Make excluding players from nbt components configurable diff --git a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java index ec93980fefcab57b7bac78d2fc4a217b376b7eca..44920c46aa75bcdc450e192d8c8ca0bf7ad0b7d5 100644 --- a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java +++ b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java @@ -87,8 +87,8 @@ public class ScissorsConfig config.options().header(HEADER); config.options().copyDefaults(true); - version = getInt("config-version", 3); - set("config-version", 3); + version = getInt("config-version", 4); + set("config-version", 4); readConfig(ScissorsConfig.class, null); } @@ -169,6 +169,12 @@ public class ScissorsConfig chatSignaturesEnabled = getBoolean("chatSignaturesEnabled", true); } + public static boolean excludePlayersFromNbtComponents = false; + private static void excludePlayersFromNbtComponents() + { + excludePlayersFromNbtComponents = getBoolean("excludePlayersFromNbtComponents", false); + } + private static void set(String path, Object val) { config.set(path, val); 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 e5a2bb129100f0f935c8f10682204e7cb6277142..1ebc6107bbbf18dd9ede1196769e43ee7cb9d448 100644 --- a/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java +++ b/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java @@ -1,5 +1,6 @@ package net.minecraft.network.chat.contents; +import me.totalfreedom.scissors.ScissorsConfig; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; import java.util.List; @@ -32,7 +33,11 @@ public record EntityDataSource(String selectorPattern, @Nullable EntitySelector public Stream getData(CommandSourceStack source) throws CommandSyntaxException { if (this.compiledSelector != null) { List list = this.compiledSelector.findEntities(source); - return list.stream().filter((entity) -> !(entity instanceof Player)).map(NbtPredicate::getEntityTagToCompare); // Scissors - Don't query NBT from players + // Scissors start + Stream stream = list.stream(); + if (ScissorsConfig.excludePlayersFromNbtComponents) stream = stream.filter((entity) -> !(entity instanceof Player)); + return stream.map(NbtPredicate::getEntityTagToCompare); + // Scissors end } else { return Stream.empty(); }