From 65d79936797566bcbb8133908d5aa709744ea782 Mon Sep 17 00:00:00 2001 From: Luna <90072930+LunaWasFlaggedAgain@users.noreply.github.com> Date: Tue, 4 Jul 2023 18:10:53 -0300 Subject: [PATCH] Backport 1.20.1 patches to 1.19.4 (#116) * First pass * Second and final pass * Update Jenkinsfile --- Jenkinsfile | 3 +- patches/server/0001-Build-changes.patch | 40 +-- ...ID-is.patch => 0002-UUID-validation.patch} | 23 +- ...otTables-causing-problems-when-appli.patch | 46 --- .../0003-ResourceLocation-validation.patch | 183 ++++++++++++ ...-Fixes-the-Blank-SkullOwner-exploit.patch} | 16 +- ...used-by-invalid-entities-in-beehive.patch} | 6 +- ...Removes-useless-spammy-error-logging.patch | 2 +- ...rown-when-trying-to-remove-minecart-.patch | 7 +- ...Books-causing-log-spam-when-invalid-.patch | 7 +- ...ate-BlockState-and-SoundEvent-values.patch | 8 +- ...d-items-in-HoverEvent-and-ItemFrame.patch} | 0 ...ceLocation-validation-and-log-spam-f.patch | 86 ------ ... 0012-Change-version-fetcher-to-AMG.patch} | 16 +- ...handling-of-invalid-JSON-components.patch} | 60 ++-- ...en-more-resource-location-validation.patch | 54 ---- ...=> 0014-Block-server-side-chunkbans.patch} | 100 +++---- ...-oversized-components-from-updating.patch} | 21 +- ...Scissors-configuration-file-command.patch} | 267 ++---------------- ...UUIDs-during-the-CompoundTag-GamePro.patch | 25 -- ...s-with-invalid-namespaces-from-bein.patch} | 4 +- ...ry-player-data-in-the-nbt-component.patch} | 21 +- ...0018-Limit-ListTags-to-1024-elements.patch | 18 -- ...string-tag-visitors-to-1024-elements.patch | 142 ++++++++++ ...lling-potion-effects-and-certain-po.patch} | 4 +- ...ch => 0021-Fix-negative-death-times.patch} | 8 +- ...ehicle-collision-checks-to-3-and-di.patch} | 48 ++-- ...ates-before-attempting-to-get-block-.patch | 64 ----- ...Add-custom-classes-used-by-Scissors.patch} | 35 +-- patches/server/0023-Reset-large-tags.patch | 54 ---- ...ners.patch => 0024-Reset-large-tags.patch} | 133 ++++++--- ...-Don-t-log-invalid-teams-to-console.patch} | 8 +- ...-bounds-HangingEntity-crash-exploit.patch} | 4 +- ...ch => 0027-Add-MasterBlockFireEvent.patch} | 66 ++--- ...> 0028-Add-spectator-teleport-event.patch} | 6 +- ...29-Prevent-invalid-container-events.patch} | 17 +- ...running-commands-in-books-by-default.patch | 73 +++++ ...ate-block-entity-tag-query-positions.patch | 31 ++ ...vents-on-Signs-bypassing-permissions.patch | 60 ++++ ...t-legacy-messages-over-1k-characters.patch | 18 ++ ...ate-block-entity-tag-query-positions.patch | 19 -- ...tch => 0034-Prevent-velocity-freeze.patch} | 11 +- ...t-legacy-messages-over-1k-characters.patch | 37 --- ...on-option-to-disable-chat-signatures.patch | 101 +++++++ ...ch-invalid-entity-rotation-log-spam.patch} | 14 +- ...Patch-large-selector-distance-crash.patch} | 4 +- ...mit-sculk-catalyst-cursor-positions.patch} | 12 +- .../server/0039-Limit-map-decorations.patch | 46 +++ ...layer-banning-using-duplicate-UUIDs.patch} | 0 ...on-t-warn-on-duplicate-entity-UUIDs.patch} | 0 ...041-Limit-map-decoration-text-length.patch | 31 -- ...component-extra-empty-array-exploit.patch} | 10 +- .../0042-Limit-map-decoration-count.patch | 23 -- ...pth-limit-to-Component-deserializer.patch} | 74 ++--- ...0044-Implement-command-block-events.patch} | 68 ++--- ...tch => 0045-Add-depth-limit-to-SNBT.patch} | 22 +- ...layers-from-nbt-components-configura.patch | 58 ---- ...ch => 0046-Limit-beacon-effectRange.patch} | 2 +- ...rove-validation-of-ResourceLocations.patch | 18 ++ ...on-t-log-on-too-many-chained-updates.patch | 19 ++ 60 files changed, 1115 insertions(+), 1238 deletions(-) rename patches/server/{0002-Return-null-when-a-show_entity-hover-event-s-UUID-is.patch => 0002-UUID-validation.patch} (71%) delete mode 100644 patches/server/0003-Fixes-invalid-LootTables-causing-problems-when-appli.patch create mode 100644 patches/server/0003-ResourceLocation-validation.patch rename patches/server/{0005-Fixes-the-Blank-SkullOwner-exploit.patch => 0004-Fixes-the-Blank-SkullOwner-exploit.patch} (75%) rename patches/server/{0004-Fixes-log-spam-caused-by-invalid-entities-in-beehive.patch => 0005-Fixes-log-spam-caused-by-invalid-entities-in-beehive.patch} (89%) rename patches/server/{0012-Do-not-log-invalid-items-in-HoverEvent-and-ItemFrame.patch => 0011-Do-not-log-invalid-items-in-HoverEvent-and-ItemFrame.patch} (100%) delete mode 100644 patches/server/0011-Even-more-ResourceLocation-validation-and-log-spam-f.patch rename patches/server/{0014-Change-version-fetcher-to-AMG.patch => 0012-Change-version-fetcher-to-AMG.patch} (91%) rename patches/server/{0027-Better-handling-of-invalid-JSON-components.patch => 0013-Better-handling-of-invalid-JSON-components.patch} (81%) delete mode 100644 patches/server/0013-Even-more-resource-location-validation.patch rename patches/server/{0029-Block-server-side-chunkbans.patch => 0014-Block-server-side-chunkbans.patch} (75%) rename patches/server/{0028-Reject-oversized-components-from-updating.patch => 0015-Reject-oversized-components-from-updating.patch} (69%) rename patches/server/{0037-Add-Scissors-configuration-file-command.patch => 0016-Add-Scissors-configuration-file-command.patch} (60%) delete mode 100644 patches/server/0016-Validate-String-UUIDs-during-the-CompoundTag-GamePro.patch rename patches/server/{0015-Prevent-attributes-with-invalid-namespaces-from-bein.patch => 0017-Prevent-attributes-with-invalid-namespaces-from-bein.patch} (90%) rename patches/server/{0017-Don-t-query-player-data-in-the-nbt-component.patch => 0018-Don-t-query-player-data-in-the-nbt-component.patch} (58%) delete mode 100644 patches/server/0018-Limit-ListTags-to-1024-elements.patch create mode 100644 patches/server/0019-Limit-string-tag-visitors-to-1024-elements.patch rename patches/server/{0019-Fixes-creative-killing-potion-effects-and-certain-po.patch => 0020-Fixes-creative-killing-potion-effects-and-certain-po.patch} (96%) rename patches/server/{0020-Fix-negative-death-times.patch => 0021-Fix-negative-death-times.patch} (77%) rename patches/server/{0025-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch => 0022-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch} (77%) delete mode 100644 patches/server/0022-Validate-coordinates-before-attempting-to-get-block-.patch rename patches/server/{0021-Add-custom-classes-used-by-Scissors.patch => 0023-Add-custom-classes-used-by-Scissors.patch} (80%) delete mode 100644 patches/server/0023-Reset-large-tags.patch rename patches/server/{0024-Account-for-items-inside-containers.patch => 0024-Reset-large-tags.patch} (64%) rename patches/server/{0026-Don-t-log-invalid-teams-to-console.patch => 0025-Don-t-log-invalid-teams-to-console.patch} (64%) rename patches/server/{0035-Fixes-out-of-bounds-HangingEntity-crash-exploit.patch => 0026-Fixes-out-of-bounds-HangingEntity-crash-exploit.patch} (94%) rename patches/server/{0030-Add-MasterBlockFireEvent.patch => 0027-Add-MasterBlockFireEvent.patch} (76%) rename patches/server/{0031-Add-spectator-teleport-event.patch => 0028-Add-spectator-teleport-event.patch} (89%) rename patches/server/{0032-Prevent-invalid-container-events.patch => 0029-Prevent-invalid-container-events.patch} (65%) create mode 100644 patches/server/0030-Disable-running-commands-in-books-by-default.patch create mode 100644 patches/server/0031-Validate-block-entity-tag-query-positions.patch create mode 100644 patches/server/0032-Fix-ClickEvents-on-Signs-bypassing-permissions.patch create mode 100644 patches/server/0033-Refuse-to-convert-legacy-messages-over-1k-characters.patch delete mode 100644 patches/server/0033-Validate-block-entity-tag-query-positions.patch rename patches/server/{0036-Prevent-velocity-freeze.patch => 0034-Prevent-velocity-freeze.patch} (94%) delete mode 100644 patches/server/0034-Refuse-to-convert-legacy-messages-over-1k-characters.patch create mode 100644 patches/server/0035-Add-configuration-option-to-disable-chat-signatures.patch rename patches/server/{0038-Patch-invalid-entity-rotation-log-spam.patch => 0036-Patch-invalid-entity-rotation-log-spam.patch} (61%) rename patches/server/{0039-Patch-large-selector-distance-crash.patch => 0037-Patch-large-selector-distance-crash.patch} (95%) rename patches/server/{0040-Limit-sculk-catalyst-cursor-positions.patch => 0038-Limit-sculk-catalyst-cursor-positions.patch} (74%) create mode 100644 patches/server/0039-Limit-map-decorations.patch rename patches/server/{0043-Prevent-player-banning-using-duplicate-UUIDs.patch => 0040-Prevent-player-banning-using-duplicate-UUIDs.patch} (100%) rename patches/server/{0044-Don-t-warn-on-duplicate-entity-UUIDs.patch => 0041-Don-t-warn-on-duplicate-entity-UUIDs.patch} (100%) delete mode 100644 patches/server/0041-Limit-map-decoration-text-length.patch rename patches/server/{0046-Fix-component-extra-empty-array-exploit.patch => 0042-Fix-component-extra-empty-array-exploit.patch} (62%) delete mode 100644 patches/server/0042-Limit-map-decoration-count.patch rename patches/server/{0047-Add-depth-limit-to-Component-deserializer.patch => 0043-Add-depth-limit-to-Component-deserializer.patch} (72%) rename patches/server/{0049-Implement-command-block-events.patch => 0044-Implement-command-block-events.patch} (53%) rename patches/server/{0048-Add-depth-limit-to-SNBT.patch => 0045-Add-depth-limit-to-SNBT.patch} (85%) delete mode 100644 patches/server/0045-Make-excluding-players-from-nbt-components-configura.patch rename patches/server/{0050-Limit-beacon-effectRange.patch => 0046-Limit-beacon-effectRange.patch} (92%) create mode 100644 patches/server/0047-Improve-validation-of-ResourceLocations.patch create mode 100644 patches/server/0048-Don-t-log-on-too-many-chained-updates.patch diff --git a/Jenkinsfile b/Jenkinsfile index deb5160..3ba2417 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,7 +18,8 @@ pipeline { } sh """ #!/bin/sh - mv \${WORKSPACE}/build/libs/Scissors-paperclip-*.jar \${WORKSPACE}/build/libs/scissors-\${BRANCH_NAME}-\${BUILD_NUMBER}.jar + BRANCH=\$(echo "\${BRANCH_NAME}" | sed 's/\\//_/g') + mv \${WORKSPACE}/build/libs/Scissors-paperclip-*.jar \${WORKSPACE}/build/libs/scissors-\${BRANCH}-\${BUILD_NUMBER}.jar rm \${WORKSPACE}/build/libs/Scissors-bundler-*.jar """ } diff --git a/patches/server/0001-Build-changes.patch b/patches/server/0001-Build-changes.patch index e163a4e..6a0315c 100644 --- a/patches/server/0001-Build-changes.patch +++ b/patches/server/0001-Build-changes.patch @@ -1,31 +1,34 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Telesphoreo -Date: Wed, 27 Jul 2022 22:09:00 -0500 +From: Luna +Date: Sat, 12 Mar 2022 22:22:22 -0300 Subject: [PATCH] Build changes diff --git a/build.gradle.kts b/build.gradle.kts -index 4f2fa65ade89c5703451dad4f80eeef162b277d1..9c1dc30f351b62bf7f527afed9da0021b4234aaf 100644 +index 4f2fa65ade89c5703451dad4f80eeef162b277d1..c3f3cbaf924fc6324cab8d503b92c69f0de5cd42 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -7,8 +7,10 @@ plugins { +@@ -7,8 +7,12 @@ plugins { } dependencies { - implementation(project(":paper-api")) - implementation(project(":paper-mojangapi")) ++ // Scissors start + implementation(project(":Scissors-API")) + implementation("io.papermc.paper:paper-mojangapi:1.19.4-R0.1-SNAPSHOT") { + exclude("io.papermc.paper", "paper-api") + } ++ // Scissors end // Paper start implementation("org.jline:jline-terminal-jansi:3.21.0") implementation("net.minecrell:terminalconsoleappender:1.3.0") -@@ -58,11 +60,17 @@ tasks.jar { +@@ -58,11 +62,19 @@ tasks.jar { val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim() val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\"" val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper - val gitBranch = git("rev-parse", "--abbrev-ref", "HEAD").getText().trim() // Paper ++ // Scissors start + var gitBranch: String; + if (System.getenv("JENKINS_URL") == null) + { @@ -33,25 +36,26 @@ index 4f2fa65ade89c5703451dad4f80eeef162b277d1..9c1dc30f351b62bf7f527afed9da0021 + } else { + gitBranch = System.getenv("GITHUB_BRANCH") + } ++ // Scissors end attributes( "Main-Class" to "org.bukkit.craftbukkit.Main", "Implementation-Title" to "CraftBukkit", - "Implementation-Version" to "git-Paper-$implementationVersion", -+ "Implementation-Version" to "git-Scissors-$implementationVersion", ++ "Implementation-Version" to "git-Scissors-$implementationVersion", // Scissors "Implementation-Vendor" to date, // Paper "Specification-Title" to "Bukkit", "Specification-Version" to project.version, -@@ -134,7 +142,7 @@ fun TaskContainer.registerRunTask( +@@ -134,7 +146,7 @@ fun TaskContainer.registerRunTask( name: String, block: JavaExec.() -> Unit ): TaskProvider = register(name) { - group = "paper" -+ group = "paperweight" ++ group = "paperweight" // Scissors mainClass.set("org.bukkit.craftbukkit.Main") standardInput = System.`in` workingDir = rootProject.layout.projectDirectory diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java -index 4b002e8b75d117b726b0de274a76d3596fce015b..5ff11b9bcef76cb767f0b03ffc326d3f7a361371 100644 +index 4b002e8b75d117b726b0de274a76d3596fce015b..a46d3f40642bbf249c2d24e689f474d07175ca09 100644 --- a/src/main/java/com/destroystokyo/paper/Metrics.java +++ b/src/main/java/com/destroystokyo/paper/Metrics.java @@ -593,7 +593,7 @@ public class Metrics { @@ -59,7 +63,7 @@ index 4b002e8b75d117b726b0de274a76d3596fce015b..5ff11b9bcef76cb767f0b03ffc326d3f // Only start Metrics, if it's enabled in the config if (config.getBoolean("enabled", true)) { - Metrics metrics = new Metrics("Paper", serverUUID, logFailedRequests, Bukkit.getLogger()); -+ Metrics metrics = new Metrics("Scissors", serverUUID, logFailedRequests, Bukkit.getLogger()); ++ Metrics metrics = new Metrics("Scissors", serverUUID, logFailedRequests, Bukkit.getLogger()); // Scissors metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> { String minecraftVersion = Bukkit.getVersion(); @@ -68,17 +72,17 @@ index 4b002e8b75d117b726b0de274a76d3596fce015b..5ff11b9bcef76cb767f0b03ffc326d3f if (implVersion != null) { final String buildOrHash = implVersion.substring(implVersion.lastIndexOf('-') + 1); - paperVersion = "git-Paper-%s-%s".formatted(Bukkit.getServer().getMinecraftVersion(), buildOrHash); -+ paperVersion = "git-Scissors-%s-%s".formatted(Bukkit.getServer().getMinecraftVersion(), buildOrHash); ++ paperVersion = "git-Scissors-%s-%s".formatted(Bukkit.getServer().getMinecraftVersion(), buildOrHash); // Scissors } else { paperVersion = "unknown"; } - metrics.addCustomChart(new Metrics.SimplePie("paper_version", () -> paperVersion)); -+ metrics.addCustomChart(new Metrics.SimplePie("scissors_version", () -> paperVersion)); ++ metrics.addCustomChart(new Metrics.SimplePie("scissors_version", () -> paperVersion)); // Scissors metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> { Map> map = new HashMap<>(); diff --git a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java -index c5d5648f4ca603ef2b1df723b58f9caf4dd3c722..2fbb5fc19e6d7f3767c7c6eedcbc6af2b0877ae5 100644 +index c5d5648f4ca603ef2b1df723b58f9caf4dd3c722..21ded7c14c56a40feaa7741131be5166947f7169 100644 --- a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java +++ b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java @@ -17,7 +17,7 @@ public final class PaperConsole extends SimpleTerminalConsole { @@ -86,7 +90,7 @@ index c5d5648f4ca603ef2b1df723b58f9caf4dd3c722..2fbb5fc19e6d7f3767c7c6eedcbc6af2 protected LineReader buildReader(LineReaderBuilder builder) { builder - .appName("Paper") -+ .appName("Scissors") ++ .appName("Scissors") // Scissors .variable(LineReader.HISTORY_FILE, java.nio.file.Paths.get(".console_history")) .completer(new ConsoleCommandCompleter(this.server)) .option(LineReader.Option.COMPLETE_IN_WORD, true); @@ -104,7 +108,7 @@ index 9f15d9dbdfa74a0640b1a2b4ff695609d4758a4c..c048169628a53462baf2e41813645971 public SystemReport fillSystemReport(SystemReport details) { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 9f2536d9a73bdb15b5b3004d4da79ca32cee205b..c5e22893b1a570e582fc4d0c36a04470639411d9 100644 +index 9f2536d9a73bdb15b5b3004d4da79ca32cee205b..247db707879b53c6ff7259efd76b9e8ff18a9d09 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -262,7 +262,7 @@ import javax.annotation.Nullable; // Paper @@ -112,12 +116,12 @@ index 9f2536d9a73bdb15b5b3004d4da79ca32cee205b..c5e22893b1a570e582fc4d0c36a04470 public final class CraftServer implements Server { - private final String serverName = "Paper"; // Paper -+ private final String serverName = "Scissors"; // Scissors > // Paper ++ private final String serverName = "Scissors"; // Scissors // Paper private final String serverVersion; private final String bukkitVersion = Versioning.getBukkitVersion(); private final Logger logger = Logger.getLogger("Minecraft"); diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java -index 774556a62eb240da42e84db4502e2ed43495be17..5e6cce78e7987b4aa1c0052262ab8c4563905372 100644 +index 774556a62eb240da42e84db4502e2ed43495be17..741c76c4dfa0bb34cc23bd795c194bdea10418cc 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java +++ b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java @@ -11,7 +11,7 @@ public final class Versioning { @@ -125,7 +129,7 @@ index 774556a62eb240da42e84db4502e2ed43495be17..5e6cce78e7987b4aa1c0052262ab8c45 String result = "Unknown-Version"; - InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/io.papermc.paper/paper-api/pom.properties"); -+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/me.totalfreedom.scissors/Scissors-API/pom.properties"); ++ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/me.totalfreedom.scissors/Scissors-API/pom.properties"); // Scissors Properties properties = new Properties(); if (stream != null) { diff --git a/patches/server/0002-Return-null-when-a-show_entity-hover-event-s-UUID-is.patch b/patches/server/0002-UUID-validation.patch similarity index 71% rename from patches/server/0002-Return-null-when-a-show_entity-hover-event-s-UUID-is.patch rename to patches/server/0002-UUID-validation.patch index 305dbf6..56f51a9 100644 --- a/patches/server/0002-Return-null-when-a-show_entity-hover-event-s-UUID-is.patch +++ b/patches/server/0002-UUID-validation.patch @@ -1,9 +1,26 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Telesphoreo -Date: Sat, 10 Dec 2022 22:25:38 -0600 -Subject: [PATCH] Return null when a show_entity hover event's UUID isn't valid +From: Video +Date: Sat, 12 Mar 2022 19:34:59 -0700 +Subject: [PATCH] UUID validation +diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java +index 6dac24354192bea79a4b9eb721543110826790b2..a9c3c55eb622b18c74d8a9bd472e4e871d11b2aa 100644 +--- a/src/main/java/net/minecraft/nbt/NbtUtils.java ++++ b/src/main/java/net/minecraft/nbt/NbtUtils.java +@@ -78,7 +78,11 @@ public final class NbtUtils { + } + // Paper start - support string UUID's + if (nbt.contains("Id", 8)) { +- uUID = UUID.fromString(nbt.getString("Id")); ++ // Scissors start - Validate String UUIDs in game profiles ++ try { ++ uUID = UUID.fromString(nbt.getString("Id")); ++ } catch (Exception ignored) {} ++ // Scissors end + } + // Paper end + diff --git a/src/main/java/net/minecraft/network/chat/HoverEvent.java b/src/main/java/net/minecraft/network/chat/HoverEvent.java index 3ad05bbab726c59e7b67d9614af4b208d4520cb3..c0633f9553fb5aa52e8ffc863159521d09cb3bd5 100644 --- a/src/main/java/net/minecraft/network/chat/HoverEvent.java diff --git a/patches/server/0003-Fixes-invalid-LootTables-causing-problems-when-appli.patch b/patches/server/0003-Fixes-invalid-LootTables-causing-problems-when-appli.patch deleted file mode 100644 index 3161222..0000000 --- a/patches/server/0003-Fixes-invalid-LootTables-causing-problems-when-appli.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Video -Date: Fri, 10 Jun 2022 22:55:01 -0500 -Subject: [PATCH] Fixes invalid LootTables causing problems when applied to - Minecart entities - - -diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java -index d4a8c1bbb8fef27ac42bdf27dde495b4c649e6cb..865c61accf211d28be3c82dcf158fec9778b50c1 100644 ---- a/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java -+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java -@@ -17,7 +17,7 @@ public class PaperContainerEntityLootableInventory implements PaperLootableEntit - - @Override - public org.bukkit.loot.LootTable getLootTable() { -- return entity.getLootTable() != null && !entity.getLootTable().getPath().isEmpty() ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(entity.getLootTable())) : null; -+ return entity.getLootTable() != null && !entity.getLootTable().getPath().isEmpty() && entity.getLootTable().toString().length() < 256 ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(entity.getLootTable())) : null; // Scissors - Validate length of loot tables before even trying - } - - @Override -diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java -index 2ee4ee14ab3345486dad6b24fd9a4fcc6c746b99..c5ac6cda91a81d3075f5c763e30dc009b6be7936 100644 ---- a/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java -+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java -@@ -15,7 +15,7 @@ public class PaperTileEntityLootableInventory implements PaperLootableBlockInven - - @Override - public org.bukkit.loot.LootTable getLootTable() { -- return tileEntityLootable.lootTable != null && !tileEntityLootable.lootTable.getPath().isEmpty() ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(tileEntityLootable.lootTable)) : null; -+ return tileEntityLootable.lootTable != null && !tileEntityLootable.lootTable.getPath().isEmpty() && tileEntityLootable.lootTable.toString().length() < 256 ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(tileEntityLootable.lootTable)) : null; // Scissors - Validate length of loot tables before even trying - } - - @Override -diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -index b9f0dae1ec96194fe78c086b63d8a18b1d0cfcf7..bdc49a9965fd3add3dfca31fb0517c14597fb076 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -@@ -46,7 +46,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc - protected boolean tryLoadLootTable(CompoundTag nbt) { - this.lootableData.loadNbt(nbt); // Paper - if (nbt.contains("LootTable", 8)) { -- this.lootTable = new ResourceLocation(nbt.getString("LootTable")); -+ this.lootTable = ResourceLocation.tryParse(nbt.getString("LootTable")); // Scissors - Validate loot tables - try { org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.lootTable); } catch (IllegalArgumentException ex) { this.lootTable = null; } // Paper - validate - this.lootTableSeed = nbt.getLong("LootTableSeed"); - return false; // Paper - always load the items, table may still remain diff --git a/patches/server/0003-ResourceLocation-validation.patch b/patches/server/0003-ResourceLocation-validation.patch new file mode 100644 index 0000000..ee21257 --- /dev/null +++ b/patches/server/0003-ResourceLocation-validation.patch @@ -0,0 +1,183 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Video +Date: Sun, 13 Mar 2022 07:39:26 -0600 +Subject: [PATCH] ResourceLocation validation + + +diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java +index d4a8c1bbb8fef27ac42bdf27dde495b4c649e6cb..865c61accf211d28be3c82dcf158fec9778b50c1 100644 +--- a/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java ++++ b/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java +@@ -17,7 +17,7 @@ public class PaperContainerEntityLootableInventory implements PaperLootableEntit + + @Override + public org.bukkit.loot.LootTable getLootTable() { +- return entity.getLootTable() != null && !entity.getLootTable().getPath().isEmpty() ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(entity.getLootTable())) : null; ++ return entity.getLootTable() != null && !entity.getLootTable().getPath().isEmpty() && entity.getLootTable().toString().length() < 256 ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(entity.getLootTable())) : null; // Scissors - Validate length of loot tables before even trying + } + + @Override +diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java +index 2ee4ee14ab3345486dad6b24fd9a4fcc6c746b99..c5ac6cda91a81d3075f5c763e30dc009b6be7936 100644 +--- a/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java ++++ b/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java +@@ -15,7 +15,7 @@ public class PaperTileEntityLootableInventory implements PaperLootableBlockInven + + @Override + public org.bukkit.loot.LootTable getLootTable() { +- return tileEntityLootable.lootTable != null && !tileEntityLootable.lootTable.getPath().isEmpty() ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(tileEntityLootable.lootTable)) : null; ++ return tileEntityLootable.lootTable != null && !tileEntityLootable.lootTable.getPath().isEmpty() && tileEntityLootable.lootTable.toString().length() < 256 ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(tileEntityLootable.lootTable)) : null; // Scissors - Validate length of loot tables before even trying + } + + @Override +diff --git a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java +index fa724cd34a7c469ca12068e64295cd00ad215a3c..9f01b0f18bf656a7ab62f07cc98aaded96432665 100644 +--- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java ++++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java +@@ -145,7 +145,7 @@ public class AreaEffectCloud extends Entity implements TraceableEntity { + } + + public void setPotionType(String string) { +- this.setPotion(BuiltInRegistries.POTION.get(new ResourceLocation(string))); ++ this.setPotion(BuiltInRegistries.POTION.get(ResourceLocation.tryParse(string))); // Scissors - Validate resource locations + } + // CraftBukkit end + +@@ -425,7 +425,7 @@ public class AreaEffectCloud extends Entity implements TraceableEntity { + try { + this.setParticle(ParticleArgument.readParticle(new StringReader(nbt.getString("Particle")), (HolderLookup) BuiltInRegistries.PARTICLE_TYPE.asLookup())); + } catch (CommandSyntaxException commandsyntaxexception) { +- AreaEffectCloud.LOGGER.warn("Couldn't load custom particle {}", nbt.getString("Particle"), commandsyntaxexception); ++ // Scissors - Don't log custom particle errors + } + } + +diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java +index ceacc0d383e2ee674783d3c0a7df0a951595faca..edd79cdca33abfc59dbc5dbf072e8b481f4c1156 100644 +--- a/src/main/java/net/minecraft/world/entity/EntityType.java ++++ b/src/main/java/net/minecraft/world/entity/EntityType.java +@@ -588,7 +588,7 @@ public class EntityType implements FeatureElement, EntityTypeT + }), (entity) -> { + entity.load(nbt); + }, () -> { +- EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id")); ++ // Scissors - Don't log invalid entities + }); + } + +@@ -607,7 +607,7 @@ public class EntityType implements FeatureElement, EntityTypeT + } + + public static Optional> by(CompoundTag nbt) { +- return BuiltInRegistries.ENTITY_TYPE.getOptional(new ResourceLocation(nbt.getString("id"))); ++ return BuiltInRegistries.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(nbt.getString("id"))); // Scissors + } + + @Nullable +diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java +index 02cb6b8c1d59855ff4a8aad3024fe12007eca0ee..3f4788b7efec73929e1326f0e54a94f8a09a427f 100644 +--- a/src/main/java/net/minecraft/world/entity/Mob.java ++++ b/src/main/java/net/minecraft/world/entity/Mob.java +@@ -615,7 +615,7 @@ public abstract class Mob extends LivingEntity implements Targeting { + + this.setLeftHanded(nbt.getBoolean("LeftHanded")); + if (nbt.contains("DeathLootTable", 8)) { +- this.lootTable = new ResourceLocation(nbt.getString("DeathLootTable")); ++ this.lootTable = ResourceLocation.tryParse(nbt.getString("DeathLootTable")); // Scissors + this.lootTableSeed = nbt.getLong("DeathLootTableSeed"); + } + +diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +index a3f073066f6e2eea8964461ad2b0409ade202f35..6eecd2e609532bbdde69c0ddc5d6bc2e2e01d1ff 100644 +--- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java ++++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +@@ -289,7 +289,12 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit + while (iterator.hasNext()) { + String s = (String) iterator.next(); + +- this.recipesUsed.put(new ResourceLocation(s), nbttagcompound1.getInt(s)); ++ // Scissors start ++ final ResourceLocation rl = ResourceLocation.tryParse(s); ++ if (rl != null) { ++ this.recipesUsed.put(rl, nbttagcompound1.getInt(s)); ++ } ++ // Scissors end + } + + // Paper start - cook speed API +diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java +index 79b01e32f89defb6b78f4764600d33d4945af592..af6ae368e6871d9db23bd1f13cf7a915005adf6c 100644 +--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java ++++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java +@@ -46,7 +46,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc + protected boolean tryLoadLootTable(CompoundTag nbt) { + this.lootableData.loadNbt(nbt); // Paper + if (nbt.contains("LootTable", 8)) { +- this.lootTable = new ResourceLocation(nbt.getString("LootTable")); ++ this.lootTable = ResourceLocation.tryParse(nbt.getString("LootTable")); // Scissors - Validate loot tables + try { org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.lootTable); } catch (IllegalArgumentException ex) { this.lootTable = null; } // Paper - validate + this.lootTableSeed = nbt.getLong("LootTableSeed"); + return false; // Paper - always load the items, table may still remain +diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java +index e49eece9bff3a53469673d03a7bbf8f9cf8776b8..a49f32e9649155b6af4b1f236e4e8142d730e7e8 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java +@@ -30,8 +30,14 @@ public abstract class CraftLootable + return null; + } + +- ResourceLocation key = getSnapshot().lootTable; +- return Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(key)); ++ // Scissors start - Return a null loot table if the specified loot table is not valid ++ try { ++ ResourceLocation key = getSnapshot().lootTable; ++ return Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(key)); ++ } catch (Exception ex) { ++ return null; ++ } ++ // Scissors end + } + + @Override +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java +index 0dd0ce9a9b3253e87eda12354249ec2fd2a33cf2..b6920f9432ca1736afbe775186fbbcf11cf046fb 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java +@@ -33,8 +33,14 @@ public abstract class CraftMinecartContainer extends CraftMinecart implements Lo + return null; // return empty loot table? + } + +- NamespacedKey key = CraftNamespacedKey.fromMinecraft(nmsTable); +- return Bukkit.getLootTable(key); ++ // Scissors start - Return a null loot table if the specified loot table is not valid ++ try { ++ NamespacedKey key = CraftNamespacedKey.fromMinecraft(nmsTable); ++ return Bukkit.getLootTable(key); ++ } catch (Exception ex) { ++ return null; ++ } ++ // Scissors end + } + + @Override +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java +index 18b9b0dc70f6872a9d71c120bcd2edca531b0ac4..4732fff6d1198e5fc4875b4d4523aa2d152817ea 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java +@@ -80,8 +80,14 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { + + @Override + public LootTable getLootTable() { +- NamespacedKey key = CraftNamespacedKey.fromMinecraft(this.getHandle().getLootTable()); +- return Bukkit.getLootTable(key); ++ // Scissors start - Return a null loot table if the specified loot table is not valid ++ try { ++ NamespacedKey key = CraftNamespacedKey.fromMinecraft(this.getHandle().getLootTable()); ++ return Bukkit.getLootTable(key); ++ } catch (Exception ex) { ++ return null; ++ } ++ // Scissors end + } + + @Override diff --git a/patches/server/0005-Fixes-the-Blank-SkullOwner-exploit.patch b/patches/server/0004-Fixes-the-Blank-SkullOwner-exploit.patch similarity index 75% rename from patches/server/0005-Fixes-the-Blank-SkullOwner-exploit.patch rename to patches/server/0004-Fixes-the-Blank-SkullOwner-exploit.patch index f62c516..6a20862 100644 --- a/patches/server/0005-Fixes-the-Blank-SkullOwner-exploit.patch +++ b/patches/server/0004-Fixes-the-Blank-SkullOwner-exploit.patch @@ -1,31 +1,27 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Video -Date: Fri, 22 Apr 2022 00:59:00 -0500 +Date: Sun, 13 Mar 2022 03:01:29 -0600 Subject: [PATCH] Fixes the Blank SkullOwner exploit diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java -index deed77a3d44bc55681483d7f47f148b5220135f2..053cb78362006a94ee0d82b9b1f665c5f86a4458 100644 +index deed77a3d44bc55681483d7f47f148b5220135f2..f927156d6d7b75ff9a1c437478ae3e200962398c 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java -@@ -11,6 +11,9 @@ import net.minecraft.nbt.CompoundTag; +@@ -11,6 +11,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtUtils; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.entity.SkullBlockEntity; -+// Scissors start -+import org.apache.commons.lang3.StringUtils; -+// Scissors end ++import org.apache.commons.lang3.StringUtils; // Scissors import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.NamespacedKey; -@@ -73,7 +76,9 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { +@@ -73,7 +74,7 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { this.setProfile(NbtUtils.readGameProfile(tag.getCompound(SKULL_OWNER.NBT))); - } else if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_STRING) && !tag.getString(SKULL_OWNER.NBT).isEmpty()) { -+ // Scissors start -+ } else if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_STRING) && !StringUtils.isBlank(tag.getString(SKULL_OWNER.NBT))) { -+ // Scissors end ++ } else if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_STRING) && !StringUtils.isBlank(tag.getString(SKULL_OWNER.NBT))) { // Scissors this.setProfile(new GameProfile(null, tag.getString(SKULL_OWNER.NBT))); } diff --git a/patches/server/0004-Fixes-log-spam-caused-by-invalid-entities-in-beehive.patch b/patches/server/0005-Fixes-log-spam-caused-by-invalid-entities-in-beehive.patch similarity index 89% rename from patches/server/0004-Fixes-log-spam-caused-by-invalid-entities-in-beehive.patch rename to patches/server/0005-Fixes-log-spam-caused-by-invalid-entities-in-beehive.patch index f93c0da..dc1a5a1 100644 --- a/patches/server/0004-Fixes-log-spam-caused-by-invalid-entities-in-beehive.patch +++ b/patches/server/0005-Fixes-log-spam-caused-by-invalid-entities-in-beehive.patch @@ -5,14 +5,14 @@ Subject: [PATCH] Fixes log spam caused by invalid entities in beehives diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java -index 41c9f074203915c31c1ae7a160ce509c13383f84..79a7fff759f062b783a540079cb43f2942799715 100644 +index 41c9f074203915c31c1ae7a160ce509c13383f84..8b4989593da43fc2fd661ac66bfe5ae1eb5e2780 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java @@ -11,6 +11,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.NbtUtils; import net.minecraft.network.protocol.game.DebugPackets; -+import net.minecraft.resources.ResourceLocation; ++import net.minecraft.resources.ResourceLocation; // Scissors import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.tags.BlockTags; @@ -25,7 +25,7 @@ index 41c9f074203915c31c1ae7a160ce509c13383f84..79a7fff759f062b783a540079cb43f29 + if (!nbttagcompound1.contains("id") || !ResourceLocation.isValidResourceLocation(nbttagcompound1.getString("id")) || EntityType.byString(nbttagcompound1.getString("id")).isEmpty()) { + continue; + } -+ // Scissor end ++ // Scissors end + BeehiveBlockEntity.BeeData tileentitybeehive_hivebee = new BeehiveBlockEntity.BeeData(nbttagcompound1.getCompound("EntityData"), nbttagcompound1.getInt("TicksInHive"), nbttagcompound1.getInt("MinOccupationTicks")); diff --git a/patches/server/0006-Removes-useless-spammy-error-logging.patch b/patches/server/0006-Removes-useless-spammy-error-logging.patch index e31fbdc..20f8bd2 100644 --- a/patches/server/0006-Removes-useless-spammy-error-logging.patch +++ b/patches/server/0006-Removes-useless-spammy-error-logging.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Video -Date: Fri, 10 Jun 2022 23:26:03 -0500 +Date: Sun, 13 Mar 2022 07:47:20 -0600 Subject: [PATCH] Removes useless spammy error logging diff --git a/patches/server/0007-Ignore-errors-thrown-when-trying-to-remove-minecart-.patch b/patches/server/0007-Ignore-errors-thrown-when-trying-to-remove-minecart-.patch index 7d66c7e..359cfc8 100644 --- a/patches/server/0007-Ignore-errors-thrown-when-trying-to-remove-minecart-.patch +++ b/patches/server/0007-Ignore-errors-thrown-when-trying-to-remove-minecart-.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Ignore errors thrown when trying to remove minecart entities diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -index b8fb7b5a347298ada16bc8b818edf1863e3f6040..7ec912bfec20d6b5d91f23341c4e9e3188d1236b 100644 +index 08f027cdcaeeca7b545483cb8c5eb8d13e4933b9..d651acb328b52ac252a6a48c1ceccdca8cfb612a 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -@@ -139,7 +139,12 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme +@@ -139,7 +139,11 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme @Override public void remove(Entity.RemovalReason reason) { if (!this.level.isClientSide && reason.shouldDestroy()) { @@ -17,8 +17,7 @@ index b8fb7b5a347298ada16bc8b818edf1863e3f6040..7ec912bfec20d6b5d91f23341c4e9e31 + // Scissors start - Ignore errors thrown when trying to remove minecart entities with content in them + try { + Containers.dropContents(this.level, (Entity) this, (Container) this); -+ } catch (Exception ignored) { -+ } ++ } catch (Exception ignored) {} + // Scissors end } diff --git a/patches/server/0009-Fixes-Knowledge-Books-causing-log-spam-when-invalid-.patch b/patches/server/0009-Fixes-Knowledge-Books-causing-log-spam-when-invalid-.patch index 03da083..d23b1ce 100644 --- a/patches/server/0009-Fixes-Knowledge-Books-causing-log-spam-when-invalid-.patch +++ b/patches/server/0009-Fixes-Knowledge-Books-causing-log-spam-when-invalid-.patch @@ -31,10 +31,10 @@ index b79f4ce38a42e4dba8ebdfc97dadc531b7245c7a..9c49be7c53a1f2a8c203341b8ded9cd2 } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java -index 50fdb086ffec84edc5138737c95f08ed4757a6f3..bb0f673a619810850df0d78bb4abd9d7c49ecbe4 100644 +index 50fdb086ffec84edc5138737c95f08ed4757a6f3..da312b4670fc0ac07e4ab798d4793025e362783e 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java -@@ -41,7 +41,12 @@ public class CraftMetaKnowledgeBook extends CraftMetaItem implements KnowledgeBo +@@ -41,7 +41,11 @@ public class CraftMetaKnowledgeBook extends CraftMetaItem implements KnowledgeBo for (int i = 0; i < pages.size(); i++) { String recipe = pages.getString(i); @@ -42,8 +42,7 @@ index 50fdb086ffec84edc5138737c95f08ed4757a6f3..bb0f673a619810850df0d78bb4abd9d7 + // Scissors start - Don't add recipes with invalid namespaces + try { + this.addRecipe(CraftNamespacedKey.fromString(recipe)); -+ } catch (Exception ignored) { -+ } ++ } catch (Exception ignored) {} + // Scissors end } } diff --git a/patches/server/0010-Validate-BlockState-and-SoundEvent-values.patch b/patches/server/0010-Validate-BlockState-and-SoundEvent-values.patch index 9335373..b7e4d7f 100644 --- a/patches/server/0010-Validate-BlockState-and-SoundEvent-values.patch +++ b/patches/server/0010-Validate-BlockState-and-SoundEvent-values.patch @@ -1,14 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Telesphoreo -Date: Sat, 10 Dec 2022 22:46:24 -0600 +From: Video +Date: Sun, 13 Mar 2022 21:56:29 -0600 Subject: [PATCH] Validate BlockState and SoundEvent values diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java -index 6dac24354192bea79a4b9eb721543110826790b2..b87999106b5068a243c064fa3c30968411996e2b 100644 +index a9c3c55eb622b18c74d8a9bd472e4e871d11b2aa..a78595e91cbb6a815c9ef6b4596cdb0e560f9e42 100644 --- a/src/main/java/net/minecraft/nbt/NbtUtils.java +++ b/src/main/java/net/minecraft/nbt/NbtUtils.java -@@ -231,7 +231,7 @@ public final class NbtUtils { +@@ -235,7 +235,7 @@ public final class NbtUtils { if (!nbt.contains("Name", 8)) { return Blocks.AIR.defaultBlockState(); } else { diff --git a/patches/server/0012-Do-not-log-invalid-items-in-HoverEvent-and-ItemFrame.patch b/patches/server/0011-Do-not-log-invalid-items-in-HoverEvent-and-ItemFrame.patch similarity index 100% rename from patches/server/0012-Do-not-log-invalid-items-in-HoverEvent-and-ItemFrame.patch rename to patches/server/0011-Do-not-log-invalid-items-in-HoverEvent-and-ItemFrame.patch diff --git a/patches/server/0011-Even-more-ResourceLocation-validation-and-log-spam-f.patch b/patches/server/0011-Even-more-ResourceLocation-validation-and-log-spam-f.patch deleted file mode 100644 index 59de4f8..0000000 --- a/patches/server/0011-Even-more-ResourceLocation-validation-and-log-spam-f.patch +++ /dev/null @@ -1,86 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Video -Date: Mon, 9 May 2022 23:40:59 -0500 -Subject: [PATCH] Even more ResourceLocation validation and log spam fixes - - -diff --git a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java -index fa724cd34a7c469ca12068e64295cd00ad215a3c..168b60fda38a7172f4473017ccc42447b36faab2 100644 ---- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java -+++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java -@@ -425,7 +425,7 @@ public class AreaEffectCloud extends Entity implements TraceableEntity { - try { - this.setParticle(ParticleArgument.readParticle(new StringReader(nbt.getString("Particle")), (HolderLookup) BuiltInRegistries.PARTICLE_TYPE.asLookup())); - } catch (CommandSyntaxException commandsyntaxexception) { -- AreaEffectCloud.LOGGER.warn("Couldn't load custom particle {}", nbt.getString("Particle"), commandsyntaxexception); -+ // Scissors - Don't log custom particle errors - } - } - -diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java -index e49eece9bff3a53469673d03a7bbf8f9cf8776b8..a49f32e9649155b6af4b1f236e4e8142d730e7e8 100644 ---- a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java -+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java -@@ -30,8 +30,14 @@ public abstract class CraftLootable - return null; - } - -- ResourceLocation key = getSnapshot().lootTable; -- return Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(key)); -+ // Scissors start - Return a null loot table if the specified loot table is not valid -+ try { -+ ResourceLocation key = getSnapshot().lootTable; -+ return Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(key)); -+ } catch (Exception ex) { -+ return null; -+ } -+ // Scissors end - } - - @Override -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java -index 0dd0ce9a9b3253e87eda12354249ec2fd2a33cf2..b6920f9432ca1736afbe775186fbbcf11cf046fb 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java -@@ -33,8 +33,14 @@ public abstract class CraftMinecartContainer extends CraftMinecart implements Lo - return null; // return empty loot table? - } - -- NamespacedKey key = CraftNamespacedKey.fromMinecraft(nmsTable); -- return Bukkit.getLootTable(key); -+ // Scissors start - Return a null loot table if the specified loot table is not valid -+ try { -+ NamespacedKey key = CraftNamespacedKey.fromMinecraft(nmsTable); -+ return Bukkit.getLootTable(key); -+ } catch (Exception ex) { -+ return null; -+ } -+ // Scissors end - } - - @Override -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java -index 620d918e302a00d5a6640648e3096988d15535a0..ac6831248b7c4f25d48391432afb613f25d7e23a 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java -@@ -80,8 +80,18 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { - - @Override - public LootTable getLootTable() { -- NamespacedKey key = CraftNamespacedKey.fromMinecraft(this.getHandle().getLootTable()); -- return Bukkit.getLootTable(key); -+ if (this.getHandle().lootTable == null) { -+ this.getHandle().lootTable = this.getHandle().getDefaultLootTable(); -+ } -+ -+ // Scissors start - Return a null loot table if the specified loot table is not valid -+ try { -+ NamespacedKey key = CraftNamespacedKey.fromMinecraft(this.getHandle().getLootTable()); -+ return Bukkit.getLootTable(key); -+ } catch (Exception ex) { -+ return null; -+ } -+ // Scissors end - } - - @Override diff --git a/patches/server/0014-Change-version-fetcher-to-AMG.patch b/patches/server/0012-Change-version-fetcher-to-AMG.patch similarity index 91% rename from patches/server/0014-Change-version-fetcher-to-AMG.patch rename to patches/server/0012-Change-version-fetcher-to-AMG.patch index cd9a695..83662fd 100644 --- a/patches/server/0014-Change-version-fetcher-to-AMG.patch +++ b/patches/server/0012-Change-version-fetcher-to-AMG.patch @@ -1,24 +1,24 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Telesphoreo -Date: Fri, 7 Apr 2023 15:35:35 -0500 +Date: Sat, 26 Mar 2022 21:51:07 -0500 Subject: [PATCH] Change version fetcher to AMG diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java -index 9d687da5bdf398bb3f6c84cdf1249a7213d09f2e..0a8fda6939152d393f07e5d2812409ad38855646 100644 +index 9d687da5bdf398bb3f6c84cdf1249a7213d09f2e..bc5ed619e05f24f3ad50a6a81306d120869f57a1 100644 --- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java +++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java @@ -4,11 +4,13 @@ import com.destroystokyo.paper.util.VersionFetcher; import com.google.common.base.Charsets; import com.google.common.io.Resources; import com.google.gson.*; -+import io.papermc.paper.util.JarManifests; ++import io.papermc.paper.util.JarManifests; // Scissors import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; import net.kyori.adventure.text.TextComponent; -+import org.bukkit.Bukkit; ++import org.bukkit.Bukkit; // Scissors import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -28,8 +28,8 @@ index 9d687da5bdf398bb3f6c84cdf1249a7213d09f2e..0a8fda6939152d393f07e5d2812409ad private static final java.util.regex.Pattern VER_PATTERN = java.util.regex.Pattern.compile("^([0-9\\.]*)\\-.*R"); // R is an anchor, will always give '-R' at end - private static final String GITHUB_BRANCH_NAME = "master"; - private static final String DOWNLOAD_PAGE = "https://papermc.io/downloads/paper"; -+ private static final String GITHUB_BRANCH_NAME = getBranch(); -+ private static final String DOWNLOAD_PAGE = "https://ci.scissors.gg/job/Scissors/job/" + GITHUB_BRANCH_NAME; ++ private static final String GITHUB_BRANCH_NAME = getBranch(); // Scissors ++ private static final String DOWNLOAD_PAGE = "https://ci.scissors.gg/job/Scissors/job/" + GITHUB_BRANCH_NAME; // Scissors private static @Nullable String mcVer; @Override @@ -39,8 +39,8 @@ index 9d687da5bdf398bb3f6c84cdf1249a7213d09f2e..0a8fda6939152d393f07e5d2812409ad public Component getVersionMessage(@Nonnull String serverVersion) { - String[] parts = serverVersion.substring("git-Paper-".length()).split("[-\\s]"); - final Component updateMessage = getUpdateStatusMessage("PaperMC/Paper", GITHUB_BRANCH_NAME, parts[0]); -+ String[] parts = serverVersion.substring("git-Scissors-".length()).split("[-\\s]"); -+ final Component updateMessage = getUpdateStatusMessage("AtlasMediaGroup/Scissors", GITHUB_BRANCH_NAME, parts[0]); ++ String[] parts = serverVersion.substring("git-Scissors-".length()).split("[-\\s]"); // Scissors ++ final Component updateMessage = getUpdateStatusMessage("AtlasMediaGroup/Scissors", GITHUB_BRANCH_NAME, parts[0]); // Scissors final Component history = getHistory(); return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage; diff --git a/patches/server/0027-Better-handling-of-invalid-JSON-components.patch b/patches/server/0013-Better-handling-of-invalid-JSON-components.patch similarity index 81% rename from patches/server/0027-Better-handling-of-invalid-JSON-components.patch rename to patches/server/0013-Better-handling-of-invalid-JSON-components.patch index f8e4359..0b5bd3a 100644 --- a/patches/server/0027-Better-handling-of-invalid-JSON-components.patch +++ b/patches/server/0013-Better-handling-of-invalid-JSON-components.patch @@ -1,18 +1,37 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Telesphoreo -Date: Sat, 10 Dec 2022 23:48:28 -0600 +From: Video +Date: Mon, 28 Mar 2022 13:19:43 -0600 Subject: [PATCH] Better handling of invalid JSON components +diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java +index 6efb8b10f17c70b05128039376d254e6beda3841..d280d5b34614442710d64443d03a5bdee86294a9 100644 +--- a/src/main/java/io/papermc/paper/util/MCUtil.java ++++ b/src/main/java/io/papermc/paper/util/MCUtil.java +@@ -542,13 +542,7 @@ public final class MCUtil { + return null; + } + String string = compound.getString(key); +- try { +- return Component.Serializer.fromJson(string); +- } catch (com.google.gson.JsonParseException e) { +- org.bukkit.Bukkit.getLogger().warning("Unable to parse " + key + " from " + compound +": " + e.getMessage()); +- } +- +- return null; ++ return Component.Serializer.fromJsonSafe(string); + } + + public static ChunkStatus getChunkStatus(ChunkHolder chunk) { diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java -index 37fc353c3e59dd5af2fd6c58ac084fb0e6e155d7..3c0ee4e1f42f6056ca86a6f9f129d467e29a2fbc 100644 +index 37fc353c3e59dd5af2fd6c58ac084fb0e6e155d7..2873ed7c443ed8c8c57a8b1d3e444d229f10f07b 100644 --- a/src/main/java/net/minecraft/network/chat/Component.java +++ b/src/main/java/net/minecraft/network/chat/Component.java @@ -26,6 +26,7 @@ import java.util.List; import java.util.Map.Entry; import java.util.Optional; import javax.annotation.Nullable; -+import net.minecraft.ChatFormatting; ++import net.minecraft.ChatFormatting; // Scissors import net.minecraft.Util; import net.minecraft.network.chat.contents.BlockDataSource; import net.minecraft.network.chat.contents.DataSource; @@ -84,18 +103,18 @@ index 7449a024265c42f28a6c9a1ed8d8f4b9e3096aac..487c68abc3eb5c18dc7fee762b216400 // Scissors start UUID uUID; diff --git a/src/main/java/net/minecraft/network/chat/contents/NbtContents.java b/src/main/java/net/minecraft/network/chat/contents/NbtContents.java -index 97a2657bc98d41c3c1e376b266d2c85f685acc88..7b6476455e095eed15c92797ce3a3e1146dbdc3f 100644 +index 97a2657bc98d41c3c1e376b266d2c85f685acc88..9d20f3f1af8e663a8c13714c8928d4a91653daa4 100644 --- a/src/main/java/net/minecraft/network/chat/contents/NbtContents.java +++ b/src/main/java/net/minecraft/network/chat/contents/NbtContents.java @@ -8,6 +8,7 @@ import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.Nullable; -+import net.kyori.adventure.text.TextComponent; ++import net.kyori.adventure.text.TextComponent; // Scissors import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.arguments.NbtPathArgument; import net.minecraft.nbt.Tag; -@@ -107,10 +108,11 @@ public class NbtContents implements ComponentContents { +@@ -107,10 +108,10 @@ public class NbtContents implements ComponentContents { Component component = DataFixUtils.orElse(ComponentUtils.updateForEntity(source, this.separator, sender, depth), ComponentUtils.DEFAULT_NO_STYLE_SEPARATOR); return stream.flatMap((text) -> { try { @@ -105,7 +124,6 @@ index 97a2657bc98d41c3c1e376b266d2c85f685acc88..7b6476455e095eed15c92797ce3a3e11 } catch (Exception var5) { - LOGGER.warn("Failed to parse component: {}", text, var5); + // Scissors - don't log -+ // LOGGER.warn("Failed to parse component: {}", text, var5); return Stream.of(); } }).reduce((accumulator, current) -> { @@ -127,32 +145,6 @@ index 280ee1838106201f5e3ba7753caced6d030f7e55..ade4ed2f219d32050a372283eaebe75f } this.setCustomNameVisible(nbt.getBoolean("CustomNameVisible")); -diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -index ef740d1ad6352ca4af299001a081b720bc472d2e..f2325c0c475bb465f5275f78c71949648a860d0c 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -@@ -410,7 +410,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name - this.levels = nbt.getInt("Levels"); // SPIGOT-5053, use where available - // CraftBukkit end - if (nbt.contains("CustomName", 8)) { -- this.name = io.papermc.paper.util.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException -+ this.name = Component.Serializer.fromJsonSafe(nbt.getString("CustomName")); // Scissors - Use safer method for getting Components from JSON - } - - this.lockKey = LockCode.fromTag(nbt); -diff --git a/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java -index 65e1381bb2d10bd212463feb602c60f8fdb9ade1..3e23451066894ebd88cad7022970cb2c0e9b75db 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java -@@ -42,7 +42,7 @@ public class EnchantmentTableBlockEntity extends BlockEntity implements Nameable - public void load(CompoundTag nbt) { - super.load(nbt); - if (nbt.contains("CustomName", 8)) { -- this.name = io.papermc.paper.util.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException -+ this.name = Component.Serializer.fromJsonSafe(nbt.getString("CustomName")); // Scissors - Use safer method for getting Components from JSON - } - - } diff --git a/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java b/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java index 2be7a697f08045b974579e6942b38571e744efac..84ec21c38bb44db1e9ff26c01d5c8af1a2417616 100644 --- a/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java diff --git a/patches/server/0013-Even-more-resource-location-validation.patch b/patches/server/0013-Even-more-resource-location-validation.patch deleted file mode 100644 index 89b16bd..0000000 --- a/patches/server/0013-Even-more-resource-location-validation.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Telesphoreo -Date: Sat, 10 Dec 2022 23:02:48 -0600 -Subject: [PATCH] Even more resource location validation - - -diff --git a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java -index 168b60fda38a7172f4473017ccc42447b36faab2..9f01b0f18bf656a7ab62f07cc98aaded96432665 100644 ---- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java -+++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java -@@ -145,7 +145,7 @@ public class AreaEffectCloud extends Entity implements TraceableEntity { - } - - public void setPotionType(String string) { -- this.setPotion(BuiltInRegistries.POTION.get(new ResourceLocation(string))); -+ this.setPotion(BuiltInRegistries.POTION.get(ResourceLocation.tryParse(string))); // Scissors - Validate resource locations - } - // CraftBukkit end - -diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java -index ceacc0d383e2ee674783d3c0a7df0a951595faca..32b2558fca4642373f7794449e89bfe275c5cf0d 100644 ---- a/src/main/java/net/minecraft/world/entity/EntityType.java -+++ b/src/main/java/net/minecraft/world/entity/EntityType.java -@@ -588,7 +588,7 @@ public class EntityType implements FeatureElement, EntityTypeT - }), (entity) -> { - entity.load(nbt); - }, () -> { -- EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id")); -+ /*EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id"));*/ // Scissors - Don't log invalid entities - }); - } - -@@ -607,7 +607,7 @@ public class EntityType implements FeatureElement, EntityTypeT - } - - public static Optional> by(CompoundTag nbt) { -- return BuiltInRegistries.ENTITY_TYPE.getOptional(new ResourceLocation(nbt.getString("id"))); -+ return BuiltInRegistries.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(nbt.getString("id"))); - } - - @Nullable -diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 02cb6b8c1d59855ff4a8aad3024fe12007eca0ee..9a64944c6769ced4d82b8edbbc045b870a256cb9 100644 ---- a/src/main/java/net/minecraft/world/entity/Mob.java -+++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -615,7 +615,7 @@ public abstract class Mob extends LivingEntity implements Targeting { - - this.setLeftHanded(nbt.getBoolean("LeftHanded")); - if (nbt.contains("DeathLootTable", 8)) { -- this.lootTable = new ResourceLocation(nbt.getString("DeathLootTable")); -+ this.lootTable = ResourceLocation.tryParse(nbt.getString("DeathLootTable")); - this.lootTableSeed = nbt.getLong("DeathLootTableSeed"); - } - diff --git a/patches/server/0029-Block-server-side-chunkbans.patch b/patches/server/0014-Block-server-side-chunkbans.patch similarity index 75% rename from patches/server/0029-Block-server-side-chunkbans.patch rename to patches/server/0014-Block-server-side-chunkbans.patch index a2fb0d1..185ea59 100644 --- a/patches/server/0029-Block-server-side-chunkbans.patch +++ b/patches/server/0014-Block-server-side-chunkbans.patch @@ -1,41 +1,32 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: ayunami2000 -Date: Fri, 17 Jun 2022 15:28:43 -0500 -Subject: [PATCH] Block server side chunkbans +Date: Mon, 28 Mar 2022 17:02:21 -0400 +Subject: [PATCH] Block server-side chunkbans diff --git a/src/main/java/net/minecraft/network/PacketEncoder.java b/src/main/java/net/minecraft/network/PacketEncoder.java -index fbfadeb83719b81f42724e79c59e92ed88fdece7..d9ed02aa0dcec82bdf9d42c224694773b9307cfe 100644 +index fbfadeb83719b81f42724e79c59e92ed88fdece7..c9c0652a22760716f9dbb5fc73bc6fce5148b800 100644 --- a/src/main/java/net/minecraft/network/PacketEncoder.java +++ b/src/main/java/net/minecraft/network/PacketEncoder.java -@@ -6,9 +6,26 @@ import io.netty.channel.ChannelHandlerContext; +@@ -6,9 +6,17 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToByteEncoder; import io.papermc.paper.adventure.PaperAdventure; // Paper import java.io.IOException; -+import java.util.Collections; -+import net.minecraft.ChatFormatting; -+import net.minecraft.core.NonNullList; -+import net.minecraft.nbt.CompoundTag; -+import net.minecraft.network.chat.Component; -+import net.minecraft.network.chat.SignedMessageBody; ++import java.util.Collections; // Scissors ++import net.minecraft.ChatFormatting; // Scissors ++import net.minecraft.core.NonNullList; // Scissors ++import net.minecraft.nbt.CompoundTag; // Scissors ++import net.minecraft.network.chat.Component; // Scissors ++import net.minecraft.network.chat.SignedMessageBody; // Scissors import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.PacketFlow; -+import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; -+import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; -+import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; -+import net.minecraft.network.protocol.game.ClientboundDisguisedChatPacket; -+import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData; -+import net.minecraft.network.protocol.game.ClientboundMapItemDataPacket; -+import net.minecraft.network.protocol.game.ClientboundPlayerChatPacket; -+import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket; -+import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; -+import net.minecraft.network.protocol.game.ClientboundSystemChatPacket; ++import net.minecraft.network.protocol.game.*; // Scissors import net.minecraft.util.profiling.jfr.JvmProfiler; -+import net.minecraft.world.item.ItemStack; ++import net.minecraft.world.item.ItemStack; // Scissors import org.slf4j.Logger; public class PacketEncoder extends MessageToByteEncoder> { -@@ -19,6 +36,23 @@ public class PacketEncoder extends MessageToByteEncoder> { +@@ -19,6 +27,23 @@ public class PacketEncoder extends MessageToByteEncoder> { this.flow = side; } @@ -59,13 +50,13 @@ index fbfadeb83719b81f42724e79c59e92ed88fdece7..d9ed02aa0dcec82bdf9d42c224694773 protected void encode(ChannelHandlerContext channelHandlerContext, Packet packet, ByteBuf byteBuf) throws Exception { ConnectionProtocol connectionProtocol = channelHandlerContext.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get(); if (connectionProtocol == null) { -@@ -33,38 +67,87 @@ public class PacketEncoder extends MessageToByteEncoder> { +@@ -33,38 +58,66 @@ public class PacketEncoder extends MessageToByteEncoder> { throw new IOException("Can't serialize unregistered packet"); } else { FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(byteBuf); - friendlyByteBuf.writeVarInt(i); - friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper -- + + // Scissors start + int k; try { @@ -107,46 +98,26 @@ index fbfadeb83719b81f42724e79c59e92ed88fdece7..d9ed02aa0dcec82bdf9d42c224694773 } + // Scissors start -+ private static Packet capPacket(Packet packet, int i) -+ { -+ if (packet instanceof ClientboundBlockEntityDataPacket blockEntityDataPacket) -+ { ++ private static Packet capPacket(Packet packet, int i) { ++ if (packet instanceof ClientboundBlockEntityDataPacket blockEntityDataPacket) { + packet = new ClientboundBlockEntityDataPacket(blockEntityDataPacket.getPos(), blockEntityDataPacket.getType(), new CompoundTag()); -+ } -+ else if (packet instanceof ClientboundLevelChunkPacketData chunkPacket) -+ { ++ } else if (packet instanceof ClientboundLevelChunkPacketData chunkPacket) { + chunkPacket.clearNBT(); -+ } -+ else if (packet instanceof ClientboundSetEntityDataPacket) -+ { ++ } else if (packet instanceof ClientboundSetEntityDataPacket) { + return null; // Skip -+ } -+ else if (packet instanceof ClientboundContainerSetContentPacket containerSetContentPacket) -+ { ++ } else if (packet instanceof ClientboundContainerSetContentPacket containerSetContentPacket) { + packet = new ClientboundContainerSetContentPacket(containerSetContentPacket.getContainerId(), containerSetContentPacket.getStateId(), NonNullList.create(), ItemStack.EMPTY); -+ } -+ else if (packet instanceof ClientboundSetEquipmentPacket setEquipmentPacket) -+ { ++ } else if (packet instanceof ClientboundSetEquipmentPacket setEquipmentPacket) { + packet = new ClientboundSetEquipmentPacket(setEquipmentPacket.getEntity(), Collections.emptyList()); -+ } -+ else if (packet instanceof ClientboundContainerSetSlotPacket containerSetSlotPacket) -+ { ++ } else if (packet instanceof ClientboundContainerSetSlotPacket containerSetSlotPacket) { + packet = new ClientboundContainerSetSlotPacket(containerSetSlotPacket.getContainerId(), containerSetSlotPacket.getStateId(), containerSetSlotPacket.getSlot(), ItemStack.EMPTY); -+ } -+ else if (packet instanceof ClientboundMapItemDataPacket mapItemDataPacket) -+ { ++ } else if (packet instanceof ClientboundMapItemDataPacket mapItemDataPacket) { + packet = new ClientboundMapItemDataPacket(mapItemDataPacket.getMapId(), mapItemDataPacket.getScale(), mapItemDataPacket.isLocked(), null, null); -+ } -+ else if (packet instanceof ClientboundSystemChatPacket) -+ { ++ } else if (packet instanceof ClientboundSystemChatPacket) { + return null; -+ } -+ else if (packet instanceof ClientboundDisguisedChatPacket) -+ { ++ } else if (packet instanceof ClientboundDisguisedChatPacket) { + return null; -+ } -+ else if (packet instanceof ClientboundPlayerChatPacket playerChatPacket) -+ { ++ } else if (packet instanceof ClientboundPlayerChatPacket playerChatPacket) { + final SignedMessageBody.Packed body = playerChatPacket.body(); + packet = new ClientboundPlayerChatPacket(playerChatPacket.sender(), // Not sending this packet results in a kick when someone says something. + playerChatPacket.index(), @@ -156,9 +127,7 @@ index fbfadeb83719b81f42724e79c59e92ed88fdece7..d9ed02aa0dcec82bdf9d42c224694773 + playerChatPacket.filterMask(), + playerChatPacket.chatType() + ); -+ } -+ else -+ { ++ } else { + LOGGER.error("Packet with ID {} was too large and was not caught. Please report this to the Scissors developers.", i); + return null; + } @@ -184,16 +153,15 @@ index 3944852921335c78a04a9dc301882ab5b152b1ed..96ee53c7cc862e059328c5cdf5e07f30 this.type = blockEntityType; this.tag = nbt.isEmpty() ? null : nbt; diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -index f3fa2678796c33f3a408a02a1995ad117eac9169..c8dd976240aa4f640bb2d223d472f81fdd8dcf7c 100644 +index f3fa2678796c33f3a408a02a1995ad117eac9169..2d912c6e332706371d0e8431685fe038a567e86e 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -@@ -33,6 +33,14 @@ public class ClientboundLevelChunkPacketData { +@@ -33,6 +33,13 @@ public class ClientboundLevelChunkPacketData { } // Paper end + // Scissors start -+ public void clearNBT() -+ { ++ public void clearNBT() { + this.blockEntitiesData.clear(); + this.extraPackets.clear(); + } @@ -202,3 +170,11 @@ index f3fa2678796c33f3a408a02a1995ad117eac9169..c8dd976240aa4f640bb2d223d472f81f // Paper start - Anti-Xray - Add chunk packet info @Deprecated @io.papermc.paper.annotation.DoNotUse public ClientboundLevelChunkPacketData(LevelChunk chunk) { this(chunk, null); } public ClientboundLevelChunkPacketData(LevelChunk chunk, com.destroystokyo.paper.antixray.ChunkPacketInfo chunkPacketInfo) { +@@ -58,6 +65,7 @@ public class ClientboundLevelChunkPacketData { + int totalTileEntities = 0; // Paper + + for(Map.Entry entry2 : chunk.getBlockEntities().entrySet()) { ++ if (this.extraPackets.size() > 50) break; // Scissors - Limit extraPackets size + // Paper start + if (++totalTileEntities > TE_LIMIT) { + var packet = entry2.getValue().getUpdatePacket(); diff --git a/patches/server/0028-Reject-oversized-components-from-updating.patch b/patches/server/0015-Reject-oversized-components-from-updating.patch similarity index 69% rename from patches/server/0028-Reject-oversized-components-from-updating.patch rename to patches/server/0015-Reject-oversized-components-from-updating.patch index 25959f1..140079f 100644 --- a/patches/server/0028-Reject-oversized-components-from-updating.patch +++ b/patches/server/0015-Reject-oversized-components-from-updating.patch @@ -1,35 +1,32 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Telesphoreo -Date: Fri, 25 Nov 2022 22:25:24 -0600 +From: Video +Date: Mon, 28 Mar 2022 16:49:17 -0600 Subject: [PATCH] Reject oversized components from updating diff --git a/src/main/java/net/minecraft/network/chat/ComponentUtils.java b/src/main/java/net/minecraft/network/chat/ComponentUtils.java -index 9d0d5a44c5948bde037165147d18aaabe21ce50a..c42b8b4daa1ffa6f3ae89b35056edbf61ae47283 100644 +index 584a58659fae6ba3d8b53858890bc6ec509ffb0e..54a7dae26854d320d9e53f63eb411a85a2d78159 100644 --- a/src/main/java/net/minecraft/network/chat/ComponentUtils.java +++ b/src/main/java/net/minecraft/network/chat/ComponentUtils.java -@@ -39,8 +39,10 @@ public class ComponentUtils { +@@ -39,8 +39,9 @@ public class ComponentUtils { } public static MutableComponent updateForEntity(@Nullable CommandSourceStack source, Component text, @Nullable Entity sender, int depth) throws CommandSyntaxException { -+ // Scissors start - Reject oversized components -+ MutableComponent result; ++ MutableComponent result; // Scissors if (depth > 100) { - return text.copy(); -+ result = text.copy(); ++ result = text.copy(); // Scissors } else { // Paper start if (text instanceof io.papermc.paper.adventure.AdventureComponent adventureComponent) { -@@ -53,8 +55,11 @@ public class ComponentUtils { +@@ -53,8 +54,9 @@ public class ComponentUtils { mutableComponent.append(updateForEntity(source, component, sender, depth + 1)); } - return mutableComponent.withStyle(resolveStyle(source, text.getStyle(), sender, depth)); -+ result = mutableComponent.withStyle(resolveStyle(source, text.getStyle(), sender, depth)); ++ result = mutableComponent.withStyle(resolveStyle(source, text.getStyle(), sender, depth)); // Scissors } -+ // Would the resulting component exceed 65535 bytes when encoded as a string? -+ return Component.Serializer.toJson(result).length() > 65535 ? Component.empty() : result; -+ // Scissors end ++ return Component.Serializer.toJson(result).length() > 65535 ? Component.empty() : result; // Scissors } private static Style resolveStyle(@Nullable CommandSourceStack source, Style style, @Nullable Entity sender, int depth) throws CommandSyntaxException { diff --git a/patches/server/0037-Add-Scissors-configuration-file-command.patch b/patches/server/0016-Add-Scissors-configuration-file-command.patch similarity index 60% rename from patches/server/0037-Add-Scissors-configuration-file-command.patch rename to patches/server/0016-Add-Scissors-configuration-file-command.patch index af9323d..7eacdcb 100644 --- a/patches/server/0037-Add-Scissors-configuration-file-command.patch +++ b/patches/server/0016-Add-Scissors-configuration-file-command.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Allink -Date: Wed, 15 Mar 2023 23:13:56 -0500 +Date: Sun, 10 Jul 2022 10:12:04 +0100 Subject: [PATCH] Add Scissors configuration file & command @@ -26,28 +26,6 @@ index c07eb451a576811a39021f6f97103c77488fd001..b91d3ddf586a103770d63cdcf7ec590f )); new TimingsExport(listeners, parent, history).start(); -diff --git a/src/main/java/me/totalfreedom/scissors/PositionUtility.java b/src/main/java/me/totalfreedom/scissors/PositionUtility.java -index 9e33ad84e50c7e2491aa883f905323f3ad2b070c..b085035794c91074205cb6994c73343283d274d5 100644 ---- a/src/main/java/me/totalfreedom/scissors/PositionUtility.java -+++ b/src/main/java/me/totalfreedom/scissors/PositionUtility.java -@@ -8,7 +8,7 @@ import net.minecraft.world.phys.Vec3; - - public class PositionUtility - { -- public static Vec3 getValidVec3(double x, double y, double z, Entity entity) -+ /*public static Vec3 getValidVec3(double x, double y, double z, Entity entity) - { - final Level level = entity.level; - -@@ -37,7 +37,7 @@ public class PositionUtility - { // If we throw some sort of exception due to the position being crazy, catch it - return new Vec3(0, 0, 0); - } -- } -+ }*/ - - public static Vec3 getValidVec3FromBlockPos(BlockPos blockPos, Entity entity) - { diff --git a/src/main/java/me/totalfreedom/scissors/ScissorsCommand.java b/src/main/java/me/totalfreedom/scissors/ScissorsCommand.java new file mode 100644 index 0000000000000000000000000000000000000000..797677d892d83cf54d9a60af1e277b67ed3d6e95 @@ -206,10 +184,10 @@ index 0000000000000000000000000000000000000000..797677d892d83cf54d9a60af1e277b67 +} diff --git a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java new file mode 100644 -index 0000000000000000000000000000000000000000..c973f955879c4d9223d76890b785e21db8d86c97 +index 0000000000000000000000000000000000000000..38179a93c2b04421a14dfcd53d399152e593a4b4 --- /dev/null +++ b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java -@@ -0,0 +1,213 @@ +@@ -0,0 +1,225 @@ +package me.totalfreedom.scissors; + + @@ -299,8 +277,8 @@ index 0000000000000000000000000000000000000000..c973f955879c4d9223d76890b785e21d + config.options().header(HEADER); + config.options().copyDefaults(true); + -+ version = getInt("config-version", 3); -+ set("config-version", 3); ++ version = getInt("config-version", 5); ++ set("config-version", 5); + readConfig(ScissorsConfig.class, null); + } + @@ -381,6 +359,18 @@ index 0000000000000000000000000000000000000000..c973f955879c4d9223d76890b785e21d + chatSignaturesEnabled = getBoolean("chatSignaturesEnabled", true); + } + ++ public static boolean excludePlayersFromNbtComponents = false; ++ private static void excludePlayersFromNbtComponents() ++ { ++ excludePlayersFromNbtComponents = getBoolean("excludePlayersFromNbtComponents", false); ++ } ++ public static int componentDepthLimit = 128; ++ private static void componentDepthLimit() ++ { ++ componentDepthLimit = getInt("componentDepthLimit", 128); ++ } ++ ++ + private static void set(String path, Object val) + { + config.set(path, val); @@ -423,35 +413,6 @@ index 0000000000000000000000000000000000000000..c973f955879c4d9223d76890b785e21d + } +} + -diff --git a/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java b/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java -index 74cf1c043beef03cfd5adf481414a5ee78bef2a6..182f68359a7a8c0b331acd103ed3952ea3c33b93 100644 ---- a/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java -+++ b/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java -@@ -1,5 +1,6 @@ - package net.minecraft.network.chat; - -+import me.totalfreedom.scissors.ScissorsConfig; - import net.minecraft.server.level.ServerPlayer; - - public interface OutgoingChatMessage { -@@ -42,12 +43,16 @@ public interface OutgoingChatMessage { - } - public void sendToPlayer(ServerPlayer sender, boolean filterMaskEnabled, ChatType.Bound params, @javax.annotation.Nullable Component unsigned) { - // Paper end -+ // Scissors start - Add configuration option to disable chat signatures - PlayerChatMessage playerChatMessage = this.message.filter(filterMaskEnabled); - playerChatMessage = unsigned != null ? playerChatMessage.withUnsignedContent(unsigned) : playerChatMessage; // Paper -- if (!playerChatMessage.isFullyFiltered()) { -+ if (!playerChatMessage.isFullyFiltered() && /* Scissors */ ScissorsConfig.chatSignaturesEnabled) { - sender.connection.sendPlayerChatMessage(playerChatMessage, params); -+ return; - } - -+ sender.connection.sendDisguisedChatMessage(playerChatMessage.decoratedContent(), params); -+ // Scissors end - } - } - } diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java index cdbf10339a8e8846a8c364de483a0ccd95cd225a..3863684cdf3d613c39935e9f46fd4e7066f95eab 100644 --- a/src/main/java/net/minecraft/server/Main.java @@ -485,185 +446,8 @@ index a7e133f3495e9132a5fdae2c24f225e7b026295a..16f0daad2456ce23f8d73389f62aac9f this.setPvpAllowed(dedicatedserverproperties.pvp); this.setFlightAllowed(dedicatedserverproperties.allowFlight); this.setMotd(dedicatedserverproperties.motd); -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 5c347c8ff0eb3eb500a7bd49d61fb19925d780ce..2549ff41d1d63ba0dbdaee3e526a44f953945b6d 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1,5 +1,6 @@ - package net.minecraft.server.network; - -+import me.totalfreedom.scissors.ScissorsConfig; - import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; - import com.google.common.collect.Lists; - import com.google.common.primitives.Floats; -@@ -2377,6 +2378,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - Optional optional = this.lastSeenMessages.applyUpdate(acknowledgment); - - if (optional.isEmpty()) { -+ // Scissors start - Add configuration option to disable chat signatures -+ if (!ScissorsConfig.chatSignaturesEnabled) -+ { -+ return optional; -+ } -+ // Scissors end - ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString()); - this.disconnect(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes - } -@@ -2609,11 +2616,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - @Override - public void handleChatAck(ServerboundChatAckPacket packet) { - LastSeenMessagesValidator lastseenmessagesvalidator = this.lastSeenMessages; -- -- synchronized (this.lastSeenMessages) { - if (!this.lastSeenMessages.applyOffset(packet.offset())) { -- ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString()); -- this.disconnect(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes -+ synchronized (this.lastSeenMessages) { -+ // Scissors start - Add configuration option to disable chat signatures -+ if (!ScissorsConfig.chatSignaturesEnabled) -+ { -+ return; -+ } -+ // Scissors end -+ ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString()); -+ this.disconnect(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes - } - - } -diff --git a/src/main/java/net/minecraft/world/item/WrittenBookItem.java b/src/main/java/net/minecraft/world/item/WrittenBookItem.java -index 31911c09fe15753ae32fa39417bdc9e9de552a88..97ce45c6e44b1400b8d60b52397617038f8fe911 100644 ---- a/src/main/java/net/minecraft/world/item/WrittenBookItem.java -+++ b/src/main/java/net/minecraft/world/item/WrittenBookItem.java -@@ -2,6 +2,8 @@ package net.minecraft.world.item; - - import java.util.List; - import javax.annotation.Nullable; -+ -+import me.totalfreedom.scissors.ScissorsConfig; - import net.minecraft.ChatFormatting; - import net.minecraft.commands.CommandSourceStack; - import net.minecraft.core.BlockPos; -@@ -9,8 +11,7 @@ import net.minecraft.nbt.CompoundTag; - import net.minecraft.nbt.ListTag; - import net.minecraft.nbt.StringTag; - import net.minecraft.nbt.Tag; --import net.minecraft.network.chat.Component; --import net.minecraft.network.chat.ComponentUtils; -+import net.minecraft.network.chat.*; - import net.minecraft.stats.Stats; - import net.minecraft.util.StringUtil; - import net.minecraft.world.InteractionHand; -@@ -111,8 +112,7 @@ public class WrittenBookItem extends Item { - - public static boolean resolveBookComponents(ItemStack book, @Nullable CommandSourceStack commandSource, @Nullable Player player) { - CompoundTag compoundTag = book.getTag(); -- if (io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.resolveSelectorsInBooks && compoundTag != null && !compoundTag.getBoolean("resolved")) { // Paper -- compoundTag.putBoolean("resolved", true); -+ if (compoundTag != null) { // Paper - if (!makeSureTagIsValid(compoundTag)) { - return false; - } else { -@@ -161,8 +161,42 @@ public class WrittenBookItem extends Item { - component2 = Component.literal(text); - } - -- return Component.Serializer.toJson(component2); -+ return Component.Serializer.toJson(!ScissorsConfig.runCommandsInBooks ? sanitize(component2, 0) : component2); // Scissors - Allow server owners to disable run command in books -+ } -+ -+ // Scissors start - Allow server owners to disable run command in books -+ public static Component sanitize(Component component, int depth) -+ { -+ if (depth > 128) -+ { -+ return Component.nullToEmpty("Sanitization function depth limit exceeded"); -+ } -+ -+ MutableComponent component2 = component.copy(); -+ -+ final Style style = component2.getStyle(); -+ final ClickEvent clickEvent = style.getClickEvent(); -+ -+ if (clickEvent != null && clickEvent.getAction().equals(ClickEvent.Action.RUN_COMMAND)) -+ { -+ final String clickEventValue = clickEvent.getValue(); -+ -+ component2 = component2.copy().setStyle(style -+ .withClickEvent(null) -+ .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.nullToEmpty("Would've " + (clickEventValue.startsWith("/") ? "ran" : "said") + ": " + clickEvent.getValue()))) -+ ); -+ } -+ -+ final List processedExtra = component2.getSiblings() -+ .stream() -+ .map(comp -> sanitize(comp, depth + 1)) -+ .toList(); -+ component2.getSiblings().clear(); -+ component2.getSiblings().addAll(processedExtra); -+ -+ return component2; - } -+ // Scissors end - - @Override - public boolean isFoil(ItemStack stack) { -diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java -index 4da4edae517a0efec6e03a719ec47b700509dab1..837b20be528bc33f62c0c675d90afebd0a781b6f 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java -@@ -4,8 +4,11 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; - import java.util.UUID; - import java.util.function.Function; - import javax.annotation.Nullable; -+ -+import me.totalfreedom.scissors.ScissorsConfig; - import net.minecraft.commands.CommandSource; - import net.minecraft.commands.CommandSourceStack; -+import net.minecraft.commands.Commands; - import net.minecraft.core.BlockPos; - import net.minecraft.nbt.CompoundTag; - import net.minecraft.network.chat.ClickEvent; -@@ -15,6 +18,7 @@ import net.minecraft.network.chat.ComponentUtils; - import net.minecraft.network.chat.MutableComponent; - import net.minecraft.network.chat.Style; - import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; -+import net.minecraft.server.MinecraftServer; - import net.minecraft.server.level.ServerLevel; - import net.minecraft.server.level.ServerPlayer; - import net.minecraft.util.FormattedCharSequence; -@@ -24,6 +28,8 @@ import net.minecraft.world.item.DyeColor; - import net.minecraft.world.level.block.state.BlockState; - import net.minecraft.world.phys.Vec2; - import net.minecraft.world.phys.Vec3; -+import org.bukkit.craftbukkit.CraftServer; -+import org.bukkit.craftbukkit.entity.CraftPlayer; - - public class SignBlockEntity extends BlockEntity implements CommandSource { // CraftBukkit - implements - private static final boolean CONVERT_LEGACY_SIGNS = Boolean.getBoolean("convertLegacySigns"); // Paper -@@ -272,6 +278,21 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C - } - player.getServer().getCommands().performPrefixedCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle()), event.getMessage()); - // Paper end -+ // Scissors start - Add optional permissions to command signs -+ final MinecraftServer vanillaServer = player.getServer(); -+ final CraftServer craftServer = vanillaServer.server; -+ final CraftPlayer craftPlayer = player.getBukkitEntity(); -+ final Commands commands = vanillaServer.getCommands(); -+ -+ if (ScissorsConfig.commandSignsBypassPermissions) -+ { -+ commands.performPrefixedCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle()), event.getMessage()); -+ } -+ else -+ { -+ craftServer.dispatchCommand(craftPlayer, command.substring(1)); -+ } -+ // Scissors end - } - } - diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index c5e22893b1a570e582fc4d0c36a04470639411d9..bf3f6253aa1f90c39d63119dd3140dae6a85217a 100644 +index 247db707879b53c6ff7259efd76b9e8ff18a9d09..9bddf6e8deb1e74c6076b5190c0b9b72e39fa2a7 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -978,6 +978,7 @@ public final class CraftServer implements Server { @@ -682,24 +466,26 @@ index c5e22893b1a570e582fc4d0c36a04470639411d9..bf3f6253aa1f90c39d63119dd3140dae this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*"); this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions"); -@@ -2763,6 +2765,12 @@ public final class CraftServer implements Server { +@@ -2763,6 +2765,14 @@ public final class CraftServer implements Server { return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console); } ++ // Scissors start + @Override + public YamlConfiguration getScissorsConfig() + { + return me.totalfreedom.scissors.ScissorsConfig.config; + } ++ // Scissors end + @Override public void restart() { org.spigotmc.RestartCommand.restart(); diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index 1fe26cb620e8b550790c3e110e2a1180cf0838fd..6305c9cf0cec52bee5a327ba3dd1531a8198eec4 100644 +index 1fe26cb620e8b550790c3e110e2a1180cf0838fd..c3ecf912ce83810e07e95de1df4a565018429881 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java -@@ -180,9 +180,27 @@ public class Main { +@@ -180,6 +180,20 @@ public class Main { .defaultsTo("Unknown Server") .describedAs("Name"); // Paper end @@ -710,9 +496,7 @@ index 1fe26cb620e8b550790c3e110e2a1180cf0838fd..6305c9cf0cec52bee5a327ba3dd1531a + .ofType(File.class) + .defaultsTo(new File(io.papermc.paper.configuration.PaperConfigurations.CONFIG_DIR)) + .describedAs("Config directory"); -+ // Scissors end + -+ // Scissors start + acceptsAll(asList("scissors", "scissors-settings"), "File for Scissors settings") + .withRequiredArg() + .ofType(File.class) @@ -722,8 +506,3 @@ index 1fe26cb620e8b550790c3e110e2a1180cf0838fd..6305c9cf0cec52bee5a327ba3dd1531a } }; -+ -+ - OptionSet options = null; - - // Paper start - preload logger classes to avoid plugins mixing versions diff --git a/patches/server/0016-Validate-String-UUIDs-during-the-CompoundTag-GamePro.patch b/patches/server/0016-Validate-String-UUIDs-during-the-CompoundTag-GamePro.patch deleted file mode 100644 index 37338a1..0000000 --- a/patches/server/0016-Validate-String-UUIDs-during-the-CompoundTag-GamePro.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Video -Date: Wed, 30 Mar 2022 02:01:55 -0600 -Subject: [PATCH] Validate String UUIDs during the CompoundTag -> GameProfile - conversion process - - -diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java -index b87999106b5068a243c064fa3c30968411996e2b..596baf1bc372875b8b82904d9d5bd53f4bedc0fb 100644 ---- a/src/main/java/net/minecraft/nbt/NbtUtils.java -+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java -@@ -78,7 +78,12 @@ public final class NbtUtils { - } - // Paper start - support string UUID's - if (nbt.contains("Id", 8)) { -- uUID = UUID.fromString(nbt.getString("Id")); -+ // Scissors start - Validate String UUIDs in game profiles -+ try { -+ uUID = UUID.fromString(nbt.getString("Id")); -+ } catch (Exception ignored) { -+ } -+ // Scissors end - } - // Paper end - diff --git a/patches/server/0015-Prevent-attributes-with-invalid-namespaces-from-bein.patch b/patches/server/0017-Prevent-attributes-with-invalid-namespaces-from-bein.patch similarity index 90% rename from patches/server/0015-Prevent-attributes-with-invalid-namespaces-from-bein.patch rename to patches/server/0017-Prevent-attributes-with-invalid-namespaces-from-bein.patch index 9eb8cb2..d7be624 100644 --- a/patches/server/0015-Prevent-attributes-with-invalid-namespaces-from-bein.patch +++ b/patches/server/0017-Prevent-attributes-with-invalid-namespaces-from-bein.patch @@ -6,14 +6,14 @@ Subject: [PATCH] Prevent attributes with invalid namespaces from being applied diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -index e3d5ded703be73343d821f329175710609dc388f..7c04bab95a49c527831949c9618ab96320b1b7ad 100644 +index e3d5ded703be73343d821f329175710609dc388f..d1279c60cafa2ad888227996f45011f54d711e38 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -46,6 +46,7 @@ import net.minecraft.nbt.NbtIo; import net.minecraft.nbt.StringTag; import net.minecraft.nbt.Tag; import net.minecraft.network.chat.Component; -+import net.minecraft.resources.ResourceLocation; ++import net.minecraft.resources.ResourceLocation; // Scissors import net.minecraft.world.item.BlockItem; import org.apache.commons.lang.Validate; import org.apache.commons.lang3.EnumUtils; diff --git a/patches/server/0017-Don-t-query-player-data-in-the-nbt-component.patch b/patches/server/0018-Don-t-query-player-data-in-the-nbt-component.patch similarity index 58% rename from patches/server/0017-Don-t-query-player-data-in-the-nbt-component.patch rename to patches/server/0018-Don-t-query-player-data-in-the-nbt-component.patch index b96ac8b..3860b8c 100644 --- a/patches/server/0017-Don-t-query-player-data-in-the-nbt-component.patch +++ b/patches/server/0018-Don-t-query-player-data-in-the-nbt-component.patch @@ -5,23 +5,34 @@ 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 8a6799b50062c1b7b141ee1568dc523f9ee7ecfd..e5a2bb129100f0f935c8f10682204e7cb6277142 100644 +index 8a6799b50062c1b7b141ee1568dc523f9ee7ecfd..80e7b0889235288b60d813a569daecb7e08e108e 100644 --- a/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java +++ b/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java -@@ -11,6 +11,7 @@ import net.minecraft.commands.arguments.selector.EntitySelector; +@@ -1,5 +1,6 @@ + package net.minecraft.network.chat.contents; + ++import me.totalfreedom.scissors.ScissorsConfig; // Scissors + import com.mojang.brigadier.StringReader; + import com.mojang.brigadier.exceptions.CommandSyntaxException; + import java.util.List; +@@ -11,6 +12,7 @@ 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 net.minecraft.world.entity.player.Player; ++import net.minecraft.world.entity.player.Player; // Scissors public record EntityDataSource(String selectorPattern, @Nullable EntitySelector compiledSelector) implements DataSource { public EntityDataSource(String rawPath) { -@@ -31,7 +32,7 @@ public record EntityDataSource(String selectorPattern, @Nullable EntitySelector +@@ -31,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().map(NbtPredicate::getEntityTagToCompare); -+ 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(); } diff --git a/patches/server/0018-Limit-ListTags-to-1024-elements.patch b/patches/server/0018-Limit-ListTags-to-1024-elements.patch deleted file mode 100644 index 72bb3e3..0000000 --- a/patches/server/0018-Limit-ListTags-to-1024-elements.patch +++ /dev/null @@ -1,18 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Luna -Date: Fri, 8 Apr 2022 23:38:12 -0300 -Subject: [PATCH] Limit ListTags to 1024 elements - - -diff --git a/src/main/java/net/minecraft/nbt/ListTag.java b/src/main/java/net/minecraft/nbt/ListTag.java -index 749d3e67a877d7d1ed47b5fef511a604ee6589b6..fe7a7fd77c7dd1750144fb57e181c51ccda26329 100644 ---- a/src/main/java/net/minecraft/nbt/ListTag.java -+++ b/src/main/java/net/minecraft/nbt/ListTag.java -@@ -31,6 +31,7 @@ public class ListTag extends CollectionTag { - list.add(tagType.load(dataInput, i + 1, nbtAccounter)); - } - -+ if(j > 1024) return new ListTag(Lists.newArrayListWithCapacity(0), b); - return new ListTag(list, b); - } - } diff --git a/patches/server/0019-Limit-string-tag-visitors-to-1024-elements.patch b/patches/server/0019-Limit-string-tag-visitors-to-1024-elements.patch new file mode 100644 index 0000000..255a727 --- /dev/null +++ b/patches/server/0019-Limit-string-tag-visitors-to-1024-elements.patch @@ -0,0 +1,142 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Luna +Date: Fri, 8 Apr 2022 23:38:12 -0300 +Subject: [PATCH] Limit string tag visitors to 1024 elements + + +diff --git a/src/main/java/net/minecraft/nbt/SnbtPrinterTagVisitor.java b/src/main/java/net/minecraft/nbt/SnbtPrinterTagVisitor.java +index e07cc7970955ce240754cfe424d768c2bba0241a..a4f41bb4ec6cb20f782668c714229b61415cfdfb 100644 +--- a/src/main/java/net/minecraft/nbt/SnbtPrinterTagVisitor.java ++++ b/src/main/java/net/minecraft/nbt/SnbtPrinterTagVisitor.java +@@ -89,6 +89,7 @@ public class SnbtPrinterTagVisitor implements TagVisitor { + public void visitByteArray(ByteArrayTag element) { + StringBuilder stringBuilder = (new StringBuilder("[")).append("B").append(";"); + byte[] bs = element.getAsByteArray(); ++ if (bs.length > 1024) { this.result = stringBuilder.append("]").toString(); return; } // Scissors + + for(int i = 0; i < bs.length; ++i) { + stringBuilder.append(" ").append((int)bs[i]).append("B"); +@@ -105,6 +106,7 @@ public class SnbtPrinterTagVisitor implements TagVisitor { + public void visitIntArray(IntArrayTag element) { + StringBuilder stringBuilder = (new StringBuilder("[")).append("I").append(";"); + int[] is = element.getAsIntArray(); ++ if (is.length > 1024) { this.result = stringBuilder.append("]").toString(); return; } // Scissors + + for(int i = 0; i < is.length; ++i) { + stringBuilder.append(" ").append(is[i]); +@@ -122,6 +124,7 @@ public class SnbtPrinterTagVisitor implements TagVisitor { + String string = "L"; + StringBuilder stringBuilder = (new StringBuilder("[")).append("L").append(";"); + long[] ls = element.getAsLongArray(); ++ if (ls.length > 1024) { this.result = stringBuilder.append("]").toString(); return; } // Scissors + + for(int i = 0; i < ls.length; ++i) { + stringBuilder.append(" ").append(ls[i]).append("L"); +@@ -136,7 +139,7 @@ public class SnbtPrinterTagVisitor implements TagVisitor { + + @Override + public void visitList(ListTag element) { +- if (element.isEmpty()) { ++ if (element.isEmpty() || element.size() > 1024) { // Scissors + this.result = "[]"; + } else { + StringBuilder stringBuilder = new StringBuilder("["); +@@ -166,7 +169,7 @@ public class SnbtPrinterTagVisitor implements TagVisitor { + + @Override + public void visitCompound(CompoundTag compound) { +- if (compound.isEmpty()) { ++ if (compound.isEmpty() || compound.size() > 1024) { // Scissors + this.result = "{}"; + } else { + StringBuilder stringBuilder = new StringBuilder("{"); +diff --git a/src/main/java/net/minecraft/nbt/StringTagVisitor.java b/src/main/java/net/minecraft/nbt/StringTagVisitor.java +index a687a0f17df30126d53a1e3a669dc6d157c23ed5..2c50f41dd8034af16fcceca75eeb6c7a9940e327 100644 +--- a/src/main/java/net/minecraft/nbt/StringTagVisitor.java ++++ b/src/main/java/net/minecraft/nbt/StringTagVisitor.java +@@ -53,6 +53,7 @@ public class StringTagVisitor implements TagVisitor { + public void visitByteArray(ByteArrayTag element) { + this.builder.append("[B;"); + byte[] bs = element.getAsByteArray(); ++ if (bs.length > 1024) { this.builder.append(']'); return; } // Scissors + + for(int i = 0; i < bs.length; ++i) { + if (i != 0) { +@@ -69,6 +70,7 @@ public class StringTagVisitor implements TagVisitor { + public void visitIntArray(IntArrayTag element) { + this.builder.append("[I;"); + int[] is = element.getAsIntArray(); ++ if (is.length > 1024) { this.builder.append(']'); return; } // Scissors + + for(int i = 0; i < is.length; ++i) { + if (i != 0) { +@@ -85,6 +87,7 @@ public class StringTagVisitor implements TagVisitor { + public void visitLongArray(LongArrayTag element) { + this.builder.append("[L;"); + long[] ls = element.getAsLongArray(); ++ if (ls.length > 1024) { this.builder.append(']'); return; } // Scissors + + for(int i = 0; i < ls.length; ++i) { + if (i != 0) { +@@ -100,6 +103,7 @@ public class StringTagVisitor implements TagVisitor { + @Override + public void visitList(ListTag element) { + this.builder.append('['); ++ if (element.size() > 1024) { this.builder.append(']'); return; } // Scissors + + for(int i = 0; i < element.size(); ++i) { + if (i != 0) { +@@ -116,6 +120,7 @@ public class StringTagVisitor implements TagVisitor { + public void visitCompound(CompoundTag compound) { + this.builder.append('{'); + List list = Lists.newArrayList(compound.getAllKeys()); ++ if (list.size() > 1024) { this.builder.append('}'); return; } // Scissors + Collections.sort(list); + + for(String string : list) { +diff --git a/src/main/java/net/minecraft/nbt/TextComponentTagVisitor.java b/src/main/java/net/minecraft/nbt/TextComponentTagVisitor.java +index 149def3da0b92f64e4fc04630965dce44884f938..c9d753f37bd65e35f8a4e2eb5c6fe8f74d5d1606 100644 +--- a/src/main/java/net/minecraft/nbt/TextComponentTagVisitor.java ++++ b/src/main/java/net/minecraft/nbt/TextComponentTagVisitor.java +@@ -97,6 +97,7 @@ public class TextComponentTagVisitor implements TagVisitor { + Component component = Component.literal("B").withStyle(SYNTAX_HIGHLIGHTING_NUMBER_TYPE); + MutableComponent mutableComponent = Component.literal("[").append(component).append(";"); + byte[] bs = element.getAsByteArray(); ++ if (bs.length > 1024) { this.result = mutableComponent.append("]"); return; } // Scissors + + for(int i = 0; i < bs.length; ++i) { + MutableComponent mutableComponent2 = Component.literal(String.valueOf((int)bs[i])).withStyle(SYNTAX_HIGHLIGHTING_NUMBER); +@@ -115,6 +116,7 @@ public class TextComponentTagVisitor implements TagVisitor { + Component component = Component.literal("I").withStyle(SYNTAX_HIGHLIGHTING_NUMBER_TYPE); + MutableComponent mutableComponent = Component.literal("[").append(component).append(";"); + int[] is = element.getAsIntArray(); ++ if (is.length > 1024) { this.result = mutableComponent.append("]"); return; } // Scissors + + for(int i = 0; i < is.length; ++i) { + mutableComponent.append(" ").append(Component.literal(String.valueOf(is[i])).withStyle(SYNTAX_HIGHLIGHTING_NUMBER)); +@@ -132,6 +134,7 @@ public class TextComponentTagVisitor implements TagVisitor { + Component component = Component.literal("L").withStyle(SYNTAX_HIGHLIGHTING_NUMBER_TYPE); + MutableComponent mutableComponent = Component.literal("[").append(component).append(";"); + long[] ls = element.getAsLongArray(); ++ if (ls.length > 1024) { this.result = mutableComponent.append("]"); return; } // Scissors + + for(int i = 0; i < ls.length; ++i) { + Component component2 = Component.literal(String.valueOf(ls[i])).withStyle(SYNTAX_HIGHLIGHTING_NUMBER); +@@ -147,7 +150,7 @@ public class TextComponentTagVisitor implements TagVisitor { + + @Override + public void visitList(ListTag element) { +- if (element.isEmpty()) { ++ if (element.isEmpty() || element.size() > 1024) { // Scissors + this.result = Component.literal("[]"); + } else if (INLINE_ELEMENT_TYPES.contains(element.getElementType()) && element.size() <= 8) { + String string = ELEMENT_SEPARATOR + " "; +@@ -190,7 +193,7 @@ public class TextComponentTagVisitor implements TagVisitor { + + @Override + public void visitCompound(CompoundTag compound) { +- if (compound.isEmpty()) { ++ if (compound.isEmpty() || compound.size() > 1024) { // Scissors + this.result = Component.literal("{}"); + } else { + MutableComponent mutableComponent = Component.literal("{"); diff --git a/patches/server/0019-Fixes-creative-killing-potion-effects-and-certain-po.patch b/patches/server/0020-Fixes-creative-killing-potion-effects-and-certain-po.patch similarity index 96% rename from patches/server/0019-Fixes-creative-killing-potion-effects-and-certain-po.patch rename to patches/server/0020-Fixes-creative-killing-potion-effects-and-certain-po.patch index 4ee2dbe..2a57100 100644 --- a/patches/server/0019-Fixes-creative-killing-potion-effects-and-certain-po.patch +++ b/patches/server/0020-Fixes-creative-killing-potion-effects-and-certain-po.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Fixes creative-killing potion effects and certain potion diff --git a/src/main/java/net/minecraft/world/effect/MobEffect.java b/src/main/java/net/minecraft/world/effect/MobEffect.java -index 2cc714585fc3790b70a7ad1ab8034543462e2b3b..2d3706d8d0dbed3b3588066eaa6b9ce1b266294f 100644 +index 2cc714585fc3790b70a7ad1ab8034543462e2b3b..a791b9dc3e29d87bf3aa309e772aea43386da89d 100644 --- a/src/main/java/net/minecraft/world/effect/MobEffect.java +++ b/src/main/java/net/minecraft/world/effect/MobEffect.java @@ -58,6 +58,7 @@ public class MobEffect { @@ -25,9 +25,9 @@ index 2cc714585fc3790b70a7ad1ab8034543462e2b3b..2d3706d8d0dbed3b3588066eaa6b9ce1 + // Scissors start + amplifier = Math.min(Math.abs(amplifier), 124); + if (!god && (this == MobEffects.HARM && !entity.isInvertedHealAndHarm() || this == MobEffects.HEAL && entity.isInvertedHealAndHarm())) { ++ // Scissors end entity.hurt(entity.damageSources().magic(), (float) (6 << amplifier)); } -+ // Scissors end } else { - entity.heal((float) Math.max(4 << amplifier, 0), RegainReason.MAGIC); // CraftBukkit + // Scissors start diff --git a/patches/server/0020-Fix-negative-death-times.patch b/patches/server/0021-Fix-negative-death-times.patch similarity index 77% rename from patches/server/0020-Fix-negative-death-times.patch rename to patches/server/0021-Fix-negative-death-times.patch index 44a3a2a..775fcaa 100644 --- a/patches/server/0020-Fix-negative-death-times.patch +++ b/patches/server/0021-Fix-negative-death-times.patch @@ -1,11 +1,11 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Telesphoreo -Date: Sat, 10 Dec 2022 23:23:52 -0600 +From: Allink +Date: Mon, 18 Apr 2022 16:55:19 +0100 Subject: [PATCH] Fix negative death times diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index e9d3e34520b706627205e0d5b17b25e09f198e7e..36b1fcc106909aa7305d63bb4710b4330cb9bc6a 100644 +index 95a27d28f73039693ca64601954af62028413634..c62552b37d9dd8f0a50ab454af6090d876e0879f 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -612,7 +612,7 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -13,7 +13,7 @@ index e9d3e34520b706627205e0d5b17b25e09f198e7e..36b1fcc106909aa7305d63bb4710b433 protected void tickDeath() { ++this.deathTime; - if (this.deathTime >= 20 && !this.level.isClientSide() && !this.isRemoved()) { -+ if ((this.deathTime >= 20 || this.deathTime <= 0) && !this.level.isClientSide() && !this.isRemoved()) { ++ if ((this.deathTime >= 20 || this.deathTime <= 0) && !this.level.isClientSide() && !this.isRemoved()) { // Scissors this.level.broadcastEntityEvent(this, (byte) 60); this.remove(Entity.RemovalReason.KILLED); } diff --git a/patches/server/0025-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch b/patches/server/0022-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch similarity index 77% rename from patches/server/0025-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch rename to patches/server/0022-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch index 648f54b..0332e0d 100644 --- a/patches/server/0025-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch +++ b/patches/server/0022-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch @@ -1,19 +1,19 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Telesphoreo -Date: Sat, 10 Dec 2022 23:44:05 -0600 +From: Allink +Date: Thu, 21 Apr 2022 13:52:32 +0100 Subject: [PATCH] Limit amount of vehicle collision checks to 3 and discard vehicles if they collide with more than 15 other entities diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java -index ee4f924afe15c9a4d96af7a55b357076c7b28501..939e4ef5a2fcedce6dfc08f1ee618bb9f21226ef 100644 +index ee4f924afe15c9a4d96af7a55b357076c7b28501..602337661d96a21d13c4da66622b7d845613c5de 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java @@ -8,6 +8,7 @@ import com.mojang.datafixers.util.Pair; import java.util.Iterator; import java.util.List; import java.util.Map; -+import java.util.concurrent.TimeUnit; ++import java.util.concurrent.TimeUnit; // Scissors import javax.annotation.Nullable; import net.minecraft.BlockUtil; import net.minecraft.Util; @@ -31,39 +31,37 @@ index ee4f924afe15c9a4d96af7a55b357076c7b28501..939e4ef5a2fcedce6dfc08f1ee618bb9 - if (!list.isEmpty()) { - for (int l = 0; l < list.size(); ++l) { -+ // Scissors - Add a collision debounce ++ // Scissors start + if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Using TimeUnit for better code readability -+ // Scissors - Limit amount of vehicle collision checks to 3 maximum + for (int l = 0; l < Math.min(3, list.size()); ++l) { ++ // Scissors end Entity entity = (Entity) list.get(l); if (!(entity instanceof Player) && !(entity instanceof IronGolem) && !(entity instanceof AbstractMinecart) && !this.isVehicle() && !entity.isPassenger()) { -@@ -460,6 +464,16 @@ public abstract class AbstractMinecart extends Entity { +@@ -460,6 +464,14 @@ public abstract class AbstractMinecart extends Entity { entity.push(this); } } + -+ // Scissors - Add a collision debounce -+ if (list.size() > 3) { -+ lastLargeCollision = System.currentTimeMillis(); -+ } -+ -+ // Scissors - Delete entity if the collision amount is over 15 ++ // Scissors start - Add a collision debounce + if (list.size() > 15) { + this.discard(); ++ } else if (list.size() > 3) { ++ lastLargeCollision = System.currentTimeMillis(); + } ++ // Scissors end } } else { Iterator iterator = this.level.getEntities(this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D)).iterator(); diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java -index 12e3209c5246ede89daaf8455fe70b4a517e12f6..a1480258f3713ea32dc0a2f6c651fd95924214da 100644 +index 12e3209c5246ede89daaf8455fe70b4a517e12f6..c5bc5e38ea6b856b1cc3e9c3907f697235b32c50 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java @@ -5,6 +5,7 @@ import com.google.common.collect.UnmodifiableIterator; import java.util.Iterator; import java.util.List; import java.util.function.IntFunction; -+import java.util.concurrent.TimeUnit; ++import java.util.concurrent.TimeUnit; // Scissors import javax.annotation.Nullable; import net.minecraft.BlockUtil; import net.minecraft.core.BlockPos; @@ -75,35 +73,31 @@ index 12e3209c5246ede89daaf8455fe70b4a517e12f6..a1480258f3713ea32dc0a2f6c651fd95 public Boat(EntityType type, Level world) { super(type, world); -@@ -421,10 +423,12 @@ public class Boat extends Entity implements VariantHolder { +@@ -421,10 +423,10 @@ public class Boat extends Entity implements VariantHolder { this.checkInsideBlocks(); List list = this.level.getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, -0.009999999776482582D, 0.20000000298023224D), EntitySelector.pushableBy(this)); - if (!list.isEmpty()) { -+ // Scissors - Add collision debounce -+ if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Using TimeUnit for better code readability ++ if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Scissors - add collision debounce, using TimeUnit for better code readability boolean flag = !this.level.isClientSide && !(this.getControllingPassenger() instanceof Player); - for (int j = 0; j < list.size(); ++j) { -+ // Scissors - Limit amount of vehicle collision checks to 3 maximum -+ for (int j = 0; j < Math.min(3, list.size()); ++j) { ++ for (int j = 0; j < Math.min(3, list.size()); ++j) { // Scissors - Limit amount of vehicle collision checks to 3 maximum Entity entity = (Entity) list.get(j); if (!entity.hasPassenger((Entity) this)) { -@@ -435,6 +439,16 @@ public class Boat extends Entity implements VariantHolder { +@@ -435,6 +437,14 @@ public class Boat extends Entity implements VariantHolder { } } } + -+ // Scissors - Add collision debounce -+ if (list.size() > 3) { -+ lastLargeCollision = System.currentTimeMillis(); -+ } -+ -+ // Scissors - Delete entity if the collision amount is over 15 ++ // Scissors start - Add collision debounce + if (list.size() > 15) { + this.discard(); ++ } else if (list.size() > 3) { ++ lastLargeCollision = System.currentTimeMillis(); + } ++ // Scissors end } } diff --git a/patches/server/0022-Validate-coordinates-before-attempting-to-get-block-.patch b/patches/server/0022-Validate-coordinates-before-attempting-to-get-block-.patch deleted file mode 100644 index dc35266..0000000 --- a/patches/server/0022-Validate-coordinates-before-attempting-to-get-block-.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Video -Date: Wed, 27 Jul 2022 22:30:39 -0500 -Subject: [PATCH] Validate coordinates before attempting to get block entities - when handling Creative Inventory packets - - -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index aa287d7f37f38d938d195114408cb6dbda59063d..80384bf470da2da2d6214a9d3429c8556aa18320 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1922,6 +1922,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - } - // Spigot end - -+ // Scissors start - Readd the following Paper code -+ // Paper start -+ private static final int SURVIVAL_PLACE_DISTANCE_SQUARED = 6 * 6; -+ private static final int CREATIVE_PLACE_DISTANCE_SQUARED = 7 * 7; -+ private boolean isOutsideOfReach(double x, double y, double z) { -+ Location eyeLoc = this.getCraftPlayer().getEyeLocation(); -+ double reachDistance = org.bukkit.util.NumberConversions.square(eyeLoc.getX() - x) + org.bukkit.util.NumberConversions.square(eyeLoc.getY() - y) + org.bukkit.util.NumberConversions.square(eyeLoc.getZ() - z); -+ return reachDistance > (this.getCraftPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED); -+ } -+ // Paper end -+ // Scissors end -+ - @Override - public void handleUseItemOn(ServerboundUseItemOnPacket packet) { - PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); -@@ -3345,17 +3357,24 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - if (!itemstack.isEmpty() && nbttagcompound != null && nbttagcompound.contains("x") && nbttagcompound.contains("y") && nbttagcompound.contains("z") && this.player.getBukkitEntity().hasPermission("minecraft.nbt.copy")) { // Spigot - BlockPos blockposition = BlockEntity.getPosFromTag(nbttagcompound); - -- if (this.player.level.isLoaded(blockposition)) { -- // Paper start -- BlockEntity tileentity = null; -- if (this.player.distanceToSqr(blockposition.getX(), blockposition.getY(), blockposition.getZ()) < 32 * 32 && this.player.getLevel().isLoadedAndInBounds(blockposition)) { -- tileentity = this.player.level.getBlockEntity(blockposition); -- } -- // Paper end -+ if (this.player.level.isLoaded(blockposition)) -+ { -+ // Scissors start - Validate coordinates and whether the player can reach them -+ if (Level.isInSpawnableBounds(blockposition) && !isOutsideOfReach(blockposition.getX(), blockposition.getY(), blockposition.getZ())) -+ { -+ BlockEntity tileentity = null; -+ if (this.player.distanceToSqr(blockposition.getX(), blockposition.getY(), blockposition.getZ()) < 32 * 32 && this.player.getLevel().isLoadedAndInBounds(blockposition)) -+ { -+ tileentity = this.player.level.getBlockEntity(blockposition); -+ } -+ // Paper end - -- if (tileentity != null) { -- tileentity.saveToItem(itemstack); -+ if (tileentity != null) -+ { -+ tileentity.saveToItem(itemstack); -+ } - } -+ // Scissors end - } - } - diff --git a/patches/server/0021-Add-custom-classes-used-by-Scissors.patch b/patches/server/0023-Add-custom-classes-used-by-Scissors.patch similarity index 80% rename from patches/server/0021-Add-custom-classes-used-by-Scissors.patch rename to patches/server/0023-Add-custom-classes-used-by-Scissors.patch index 7f8af6c..be95b46 100644 --- a/patches/server/0021-Add-custom-classes-used-by-Scissors.patch +++ b/patches/server/0023-Add-custom-classes-used-by-Scissors.patch @@ -121,10 +121,10 @@ index 0000000000000000000000000000000000000000..b724baaef8d565e41db1af6393d0890e +} diff --git a/src/main/java/me/totalfreedom/scissors/PositionUtility.java b/src/main/java/me/totalfreedom/scissors/PositionUtility.java new file mode 100644 -index 0000000000000000000000000000000000000000..9e33ad84e50c7e2491aa883f905323f3ad2b070c +index 0000000000000000000000000000000000000000..7c7e39ea96449f8eb5472cd9eca0f45f690b1861 --- /dev/null +++ b/src/main/java/me/totalfreedom/scissors/PositionUtility.java -@@ -0,0 +1,83 @@ +@@ -0,0 +1,52 @@ +package me.totalfreedom.scissors; + +import net.minecraft.core.BlockPos; @@ -135,37 +135,6 @@ index 0000000000000000000000000000000000000000..9e33ad84e50c7e2491aa883f905323f3 + +public class PositionUtility +{ -+ public static Vec3 getValidVec3(double x, double y, double z, Entity entity) -+ { -+ final Level level = entity.level; -+ -+ try -+ { -+ if (level.isInWorldBounds(new BlockPos(Math.floor(MathUtility.safeDoubleToInt(x)), Math.floor(MathUtility.safeDoubleToInt(y)), Math.floor(MathUtility.safeDoubleToInt(z))))) -+ { -+ return new Vec3(x, y, z); -+ } -+ else -+ { -+ final WorldBorder worldBorder = level.getWorldBorder(); -+ -+ final double maxX = worldBorder.getMaxX(); -+ final double maxY = level.getMaxBuildHeight(); -+ final double maxZ = worldBorder.getMaxZ(); -+ -+ final double minX = worldBorder.getMinX(); -+ final double minY = level.getMinBuildHeight(); -+ final double minZ = worldBorder.getMinZ(); -+ -+ return new Vec3(MathUtility.clampDouble(x, minX, maxX), MathUtility.clampDouble(y, minY, maxY), MathUtility.clampDouble(z, minZ, maxZ)); -+ } -+ } -+ catch (Exception e) -+ { // If we throw some sort of exception due to the position being crazy, catch it -+ return new Vec3(0, 0, 0); -+ } -+ } -+ + public static Vec3 getValidVec3FromBlockPos(BlockPos blockPos, Entity entity) + { + final BlockPos validBlockPos = getValidBlockPos(blockPos, entity); diff --git a/patches/server/0023-Reset-large-tags.patch b/patches/server/0023-Reset-large-tags.patch deleted file mode 100644 index e34986c..0000000 --- a/patches/server/0023-Reset-large-tags.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Telesphoreo -Date: Sat, 10 Dec 2022 23:38:53 -0600 -Subject: [PATCH] Reset large tags - - -diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index a7533d18fe6148d7bfd3106b9cdcb6fa3347cf7c..135c1c3013bd75673a8352b9386679195eb681d3 100644 ---- a/src/main/java/net/minecraft/world/item/ItemStack.java -+++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -20,6 +20,7 @@ import java.util.function.Predicate; - import java.util.stream.Collectors; - import java.util.stream.Stream; - import javax.annotation.Nullable; -+import me.totalfreedom.scissors.NbtUtility; - import net.minecraft.ChatFormatting; - import net.minecraft.Util; - import net.minecraft.advancements.CriteriaTriggers; -@@ -258,6 +259,12 @@ public final class ItemStack { - - // CraftBukkit - break into own method - private void load(CompoundTag nbttagcompound) { -+ // Scissors start - Reset large tags -+ if (NbtUtility.isTooLarge(nbttagcompound)) { -+ // Reset tag without destroying item -+ nbttagcompound = NbtUtility.Item.removeItemData(nbttagcompound); -+ } -+ // Scissors end - this.item = (Item) BuiltInRegistries.ITEM.get(new ResourceLocation(nbttagcompound.getString("id"))); - this.count = nbttagcompound.getByte("Count"); - if (nbttagcompound.contains("tag", 10)) { -@@ -538,7 +545,11 @@ public final class ItemStack { - nbt.putString("id", minecraftkey == null ? "minecraft:air" : minecraftkey.toString()); - nbt.putByte("Count", (byte) this.count); - if (this.tag != null) { -- nbt.put("tag", this.tag.copy()); -+ // Scissors start - Don't save large tags -+ if (!NbtUtility.isTooLarge(this.tag)) { -+ nbt.put("tag", this.tag.copy()); -+ } -+ // Scissors end - } - - return nbt; -@@ -874,6 +885,9 @@ public final class ItemStack { - // Paper end - - public void setTag(@Nullable CompoundTag nbt) { -+ // Scissors start - Ignore large tags -+ if (NbtUtility.isTooLarge(nbt)) return; -+ // Scissors end - this.tag = nbt; - this.processEnchantOrder(this.tag); // Paper - if (this.getItem().canBeDepleted()) { diff --git a/patches/server/0024-Account-for-items-inside-containers.patch b/patches/server/0024-Reset-large-tags.patch similarity index 64% rename from patches/server/0024-Account-for-items-inside-containers.patch rename to patches/server/0024-Reset-large-tags.patch index fcd5ed0..507e809 100644 --- a/patches/server/0024-Account-for-items-inside-containers.patch +++ b/patches/server/0024-Reset-large-tags.patch @@ -1,27 +1,26 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Business Goose -Date: Sat, 11 Jun 2022 23:33:13 -0500 -Subject: [PATCH] Account for items inside containers +From: Allink +Date: Mon, 18 Apr 2022 03:56:09 +0100 +Subject: [PATCH] Reset large tags diff --git a/src/main/java/net/minecraft/world/ContainerHelper.java b/src/main/java/net/minecraft/world/ContainerHelper.java -index 4092c7a8c2b0d9d26e6f4d97386735236300d132..9e0ab51dd7a4f9fed8f9edde962d42d4bbf604c1 100644 +index 4092c7a8c2b0d9d26e6f4d97386735236300d132..04c47cf1a920ae6c356449df801227ee14f6dfb7 100644 --- a/src/main/java/net/minecraft/world/ContainerHelper.java +++ b/src/main/java/net/minecraft/world/ContainerHelper.java @@ -2,6 +2,7 @@ package net.minecraft.world; import java.util.List; import java.util.function.Predicate; -+import me.totalfreedom.scissors.NbtUtility; ++import me.totalfreedom.scissors.NbtUtility; // Scissors import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; -@@ -22,10 +23,13 @@ public class ContainerHelper { +@@ -22,10 +23,12 @@ public class ContainerHelper { public static CompoundTag saveAllItems(CompoundTag nbt, NonNullList stacks, boolean setIfEmpty) { ListTag listTag = new ListTag(); -+ // Scissors - Account for items inside containers -+ long total = 0; ++ long total = 0; // Scissors for(int i = 0; i < stacks.size(); ++i) { ItemStack itemStack = stacks.get(i); @@ -30,7 +29,7 @@ index 4092c7a8c2b0d9d26e6f4d97386735236300d132..9e0ab51dd7a4f9fed8f9edde962d42d4 CompoundTag compoundTag = new CompoundTag(); compoundTag.putByte("Slot", (byte)i); itemStack.save(compoundTag); -@@ -33,7 +37,7 @@ public class ContainerHelper { +@@ -33,7 +36,7 @@ public class ContainerHelper { } } @@ -39,42 +38,89 @@ index 4092c7a8c2b0d9d26e6f4d97386735236300d132..9e0ab51dd7a4f9fed8f9edde962d42d4 nbt.put("Items", listTag); } -@@ -42,11 +46,18 @@ public class ContainerHelper { +@@ -42,11 +45,19 @@ public class ContainerHelper { public static void loadAllItems(CompoundTag nbt, NonNullList stacks) { ListTag listTag = nbt.getList("Items", 10); -+ // Scissors - Account for items inside containers -+ long total = 0; ++ long total = 0; // Scissors - Account for items inside containers for(int i = 0; i < listTag.size(); ++i) { CompoundTag compoundTag = listTag.getCompound(i); int j = compoundTag.getByte("Slot") & 255; if (j >= 0 && j < stacks.size()) { ++ // Scissors start + total += NbtUtility.getTagSize(compoundTag); + if (total >= NbtUtility.MAXIMUM_SIZE) { + stacks.clear(); + break; + } ++ // Scissors end stacks.set(j, ItemStack.of(compoundTag)); } } +diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java +index d81fcbadc5c0b3d4b54dde5d47a0f847d8ec6918..4c2f3f932654dec5dcbf2d8b0a61122905315e56 100644 +--- a/src/main/java/net/minecraft/world/item/ItemStack.java ++++ b/src/main/java/net/minecraft/world/item/ItemStack.java +@@ -20,6 +20,7 @@ import java.util.function.Predicate; + import java.util.stream.Collectors; + import java.util.stream.Stream; + import javax.annotation.Nullable; ++import me.totalfreedom.scissors.NbtUtility; // Scissors + import net.minecraft.ChatFormatting; + import net.minecraft.Util; + import net.minecraft.advancements.CriteriaTriggers; +@@ -258,6 +259,12 @@ public final class ItemStack { + + // CraftBukkit - break into own method + private void load(CompoundTag nbttagcompound) { ++ // Scissors start - Reset large tags ++ if (NbtUtility.isTooLarge(nbttagcompound)) { ++ // Reset tag without destroying item ++ nbttagcompound = NbtUtility.Item.removeItemData(nbttagcompound); ++ } ++ // Scissors end + this.item = (Item) BuiltInRegistries.ITEM.get(new ResourceLocation(nbttagcompound.getString("id"))); + this.count = nbttagcompound.getByte("Count"); + if (nbttagcompound.contains("tag", 10)) { +@@ -538,7 +545,11 @@ public final class ItemStack { + nbt.putString("id", minecraftkey == null ? "minecraft:air" : minecraftkey.toString()); + nbt.putByte("Count", (byte) this.count); + if (this.tag != null) { +- nbt.put("tag", this.tag.copy()); ++ // Scissors start - Don't save large tags ++ if (!NbtUtility.isTooLarge(this.tag)) { ++ nbt.put("tag", this.tag.copy()); ++ } ++ // Scissors end + } + + return nbt; +@@ -874,6 +885,7 @@ public final class ItemStack { + // Paper end + + public void setTag(@Nullable CompoundTag nbt) { ++ if (NbtUtility.isTooLarge(nbt)) return; // Scissors - Ignore large tags + this.tag = nbt; + this.processEnchantOrder(this.tag); // Paper + if (this.getItem().canBeDepleted()) { diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -index 2a786c9fd29dc2139cf487fa645cd43345d60167..dbdc66620ae4284cfe96f633b1f4db46866b597b 100644 +index 6eecd2e609532bbdde69c0ddc5d6bc2e2e01d1ff..907e163e5377335aac828c137deed42af9d2ce38 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java @@ -9,6 +9,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import javax.annotation.Nullable; -+import me.totalfreedom.scissors.NbtUtility; ++import me.totalfreedom.scissors.NbtUtility; // Scissors import net.minecraft.SharedConstants; import net.minecraft.Util; import net.minecraft.core.BlockPos; -@@ -212,6 +213,16 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit +@@ -212,6 +213,17 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit public List transaction = new java.util.ArrayList(); public List getContents() { -+ // Scissors - Account for items inside containers ++ // Scissors start - Account for items inside containers + long total = 0; + + for (ItemStack item : this.items) { @@ -84,25 +130,26 @@ index 2a786c9fd29dc2139cf487fa645cd43345d60167..dbdc66620ae4284cfe96f633b1f4db46 + if (total > NbtUtility.MAXIMUM_SIZE) { + this.items.clear(); + } ++ // Scissors end return this.items; } diff --git a/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java -index 416aa989ebb18a8741cc9d605a1180ab830f6643..893cf89dd2b022e2b785318e7e86eb5d75be8ed8 100644 +index 416aa989ebb18a8741cc9d605a1180ab830f6643..a9a8c9e68e5b767dec2c26495685da88e0caa627 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java @@ -1,5 +1,6 @@ package net.minecraft.world.level.block.entity; -+import me.totalfreedom.scissors.NbtUtility; ++import me.totalfreedom.scissors.NbtUtility; // Scissors import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.NonNullList; -@@ -34,6 +35,16 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity { +@@ -34,6 +35,17 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity { @Override public List getContents() { -+ // Scissors - Account for items inside containers ++ // Scissors start - Account for items inside containers + long total = 0; + + for (ItemStack item : this.items) { @@ -112,26 +159,27 @@ index 416aa989ebb18a8741cc9d605a1180ab830f6643..893cf89dd2b022e2b785318e7e86eb5d + if (total > NbtUtility.MAXIMUM_SIZE) { + this.items.clear(); + } ++ // Scissors end return this.items; } diff --git a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java -index c57efcb9a79337ec791e4e8f6671612f0a82b441..2963b72061a9ede734842d6fb46a67a1c41d4740 100644 +index c57efcb9a79337ec791e4e8f6671612f0a82b441..2cbb8170953cb555411db8c171a3d1d91eb799bb 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java @@ -3,6 +3,7 @@ package net.minecraft.world.level.block.entity; import java.util.Arrays; import java.util.Iterator; import javax.annotation.Nullable; -+import me.totalfreedom.scissors.NbtUtility; ++import me.totalfreedom.scissors.NbtUtility; // Scissors import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.NonNullList; -@@ -73,6 +74,16 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements +@@ -73,6 +74,17 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements } public List getContents() { -+ // Scissors - Account for items inside containers ++ // Scissors start - Account for items inside containers + long total = 0; + + for (ItemStack item : this.items) { @@ -141,25 +189,26 @@ index c57efcb9a79337ec791e4e8f6671612f0a82b441..2963b72061a9ede734842d6fb46a67a1 + if (total > NbtUtility.MAXIMUM_SIZE) { + this.items.clear(); + } ++ // Scissors end return this.items; } diff --git a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java -index a71414397bd45ee7bcacfeef0041d80dfa25f114..1b6f91055eb01627761e83e5e99e1731029b32ab 100644 +index a71414397bd45ee7bcacfeef0041d80dfa25f114..f51abf1722e98d7ce9e616d84472d847e597eafb 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java @@ -1,5 +1,6 @@ package net.minecraft.world.level.block.entity; -+import me.totalfreedom.scissors.NbtUtility; ++import me.totalfreedom.scissors.NbtUtility; // Scissors import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.NonNullList; -@@ -40,6 +41,16 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement +@@ -40,6 +41,17 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement private int maxStack = MAX_STACK; public List getContents() { -+ // Scissors - Account for items inside containers ++ // Scissors start - Account for items inside containers + long total = 0; + + for (ItemStack item : this.items) { @@ -169,25 +218,26 @@ index a71414397bd45ee7bcacfeef0041d80dfa25f114..1b6f91055eb01627761e83e5e99e1731 + if (total > NbtUtility.MAXIMUM_SIZE) { + this.items.clear(); + } ++ // Scissors end return this.items; } diff --git a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java -index 881379681c39230a00b3a1f11cd87498984396c7..1be5d600573f7632e6630224530dd76522e1b191 100644 +index 881379681c39230a00b3a1f11cd87498984396c7..d0513b72cdaec3b67b9341d251367b193bafa40c 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java @@ -1,5 +1,6 @@ package net.minecraft.world.level.block.entity; -+import me.totalfreedom.scissors.NbtUtility; ++import me.totalfreedom.scissors.NbtUtility; // Scissors import net.minecraft.core.BlockPos; import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; -@@ -28,6 +29,16 @@ public class DispenserBlockEntity extends RandomizableContainerBlockEntity { +@@ -28,6 +29,17 @@ public class DispenserBlockEntity extends RandomizableContainerBlockEntity { private int maxStack = MAX_STACK; public List getContents() { -+ // Scissors - Account for items inside containers ++ // Scissors start - Account for items inside containers + long total = 0; + + for (ItemStack item : this.items) { @@ -197,26 +247,27 @@ index 881379681c39230a00b3a1f11cd87498984396c7..1be5d600573f7632e6630224530dd765 + if (total > NbtUtility.MAXIMUM_SIZE) { + this.items.clear(); + } ++ // Scissors end return this.items; } diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index 789e5458f4a137694563a22612455506807de51b..84c721da46b7786857677b56f439c2b9448ba4b8 100644 +index aac5572c1d40a10cd1d17f89c9eb836718837577..e31ce92c8381ff2b1e5777f6f5351adcd137cdc5 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java @@ -6,6 +6,7 @@ import java.util.function.BooleanSupplier; import java.util.stream.Collectors; import java.util.stream.IntStream; import javax.annotation.Nullable; -+import me.totalfreedom.scissors.NbtUtility; ++import me.totalfreedom.scissors.NbtUtility; // Scissors import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.NonNullList; -@@ -56,6 +57,16 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -56,6 +57,17 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen private int maxStack = MAX_STACK; public List getContents() { -+ // Scissors - Account for items inside containers ++ // Scissors start - Account for items inside containers + long total = 0; + + for (ItemStack item : this.items) { @@ -226,26 +277,27 @@ index 789e5458f4a137694563a22612455506807de51b..84c721da46b7786857677b56f439c2b9 + if (total > NbtUtility.MAXIMUM_SIZE) { + this.items.clear(); + } ++ // Scissors end return this.items; } diff --git a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java -index b7686fd63b7c5d88c3a12ec4ee9bc01a17f997e0..c2904048625bb4439c7f0ba8a2605d3194b66070 100644 +index b7686fd63b7c5d88c3a12ec4ee9bc01a17f997e0..db3a4a8cd19da9775bb0884c33494f1e8591b1fa 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java @@ -3,6 +3,7 @@ package net.minecraft.world.level.block.entity; import java.util.List; import java.util.stream.IntStream; import javax.annotation.Nullable; -+import me.totalfreedom.scissors.NbtUtility; ++import me.totalfreedom.scissors.NbtUtility; // Scissors import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.NonNullList; -@@ -60,6 +61,16 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl +@@ -60,6 +61,17 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl public boolean opened; public List getContents() { -+ // Scissors - Account for items inside containers ++ // Scissors start - Account for items inside containers + long total = 0; + + for (ItemStack item : this.itemStacks) { @@ -255,6 +307,7 @@ index b7686fd63b7c5d88c3a12ec4ee9bc01a17f997e0..c2904048625bb4439c7f0ba8a2605d31 + if (total > NbtUtility.MAXIMUM_SIZE) { + this.itemStacks.clear(); + } ++ // Scissors end return this.itemStacks; } diff --git a/patches/server/0026-Don-t-log-invalid-teams-to-console.patch b/patches/server/0025-Don-t-log-invalid-teams-to-console.patch similarity index 64% rename from patches/server/0026-Don-t-log-invalid-teams-to-console.patch rename to patches/server/0025-Don-t-log-invalid-teams-to-console.patch index 235ca71..3455723 100644 --- a/patches/server/0026-Don-t-log-invalid-teams-to-console.patch +++ b/patches/server/0025-Don-t-log-invalid-teams-to-console.patch @@ -5,17 +5,15 @@ Subject: [PATCH] Don't log invalid teams to console diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 36b1fcc106909aa7305d63bb4710b4330cb9bc6a..795ebbea0c0100cd05661caad74ed2ae1a32e045 100644 +index c62552b37d9dd8f0a50ab454af6090d876e0879f..2f4c606562c08189c817280a601a32632959614e 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -844,7 +844,9 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -844,7 +844,7 @@ public abstract class LivingEntity extends Entity implements Attackable { boolean flag = scoreboardteam != null && this.level.getScoreboard().addPlayerToTeam(this.getStringUUID(), scoreboardteam); if (!flag) { - LivingEntity.LOGGER.warn("Unable to add mob to team \"{}\" (that team probably doesn't exist)", s); -+ // Scissors start - Prevent log spam possible with this error message, easily provokable by players in creative. -+ // LivingEntity.LOGGER.warn("Unable to add mob to team \"{}\" (that team probably doesn't exist)", s); -+ // Scissors end ++ // Scissors - Prevent log spam possible with this error message, easily provokable by players in creative. } } diff --git a/patches/server/0035-Fixes-out-of-bounds-HangingEntity-crash-exploit.patch b/patches/server/0026-Fixes-out-of-bounds-HangingEntity-crash-exploit.patch similarity index 94% rename from patches/server/0035-Fixes-out-of-bounds-HangingEntity-crash-exploit.patch rename to patches/server/0026-Fixes-out-of-bounds-HangingEntity-crash-exploit.patch index 6a1df72..b566fb3 100644 --- a/patches/server/0035-Fixes-out-of-bounds-HangingEntity-crash-exploit.patch +++ b/patches/server/0026-Fixes-out-of-bounds-HangingEntity-crash-exploit.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Telesphoreo -Date: Mon, 22 Aug 2022 21:33:37 -0500 +From: Video +Date: Fri, 19 Aug 2022 00:49:38 -0600 Subject: [PATCH] Fixes out of bounds HangingEntity crash exploit diff --git a/patches/server/0030-Add-MasterBlockFireEvent.patch b/patches/server/0027-Add-MasterBlockFireEvent.patch similarity index 76% rename from patches/server/0030-Add-MasterBlockFireEvent.patch rename to patches/server/0027-Add-MasterBlockFireEvent.patch index 12f2c42..02eb901 100644 --- a/patches/server/0030-Add-MasterBlockFireEvent.patch +++ b/patches/server/0027-Add-MasterBlockFireEvent.patch @@ -5,34 +5,29 @@ Subject: [PATCH] Add MasterBlockFireEvent diff --git a/src/main/java/net/minecraft/world/level/block/CommandBlock.java b/src/main/java/net/minecraft/world/level/block/CommandBlock.java -index 2e7c03b00bc941b86df6a7f1b2b188c9f0aede22..333f9bcccbe9ecd88c1fd13e2956f69414d6e295 100644 +index 2e7c03b00bc941b86df6a7f1b2b188c9f0aede22..0ae03d3934ad7b2b38afa45a65c7753dcbe796d2 100644 --- a/src/main/java/net/minecraft/world/level/block/CommandBlock.java +++ b/src/main/java/net/minecraft/world/level/block/CommandBlock.java @@ -1,5 +1,6 @@ package net.minecraft.world.level.block; -+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent; ++import me.totalfreedom.scissors.event.block.MasterBlockFireEvent; // Scissors import com.mojang.logging.LogUtils; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -@@ -25,10 +26,10 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties; +@@ -25,6 +26,7 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.level.block.state.properties.DirectionProperty; import net.minecraft.world.phys.BlockHitResult; -+import org.bukkit.event.block.BlockRedstoneEvent; -+import org.bukkit.Location; ++import org.bukkit.Location; // Scissors import org.slf4j.Logger; --import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit -- - public class CommandBlock extends BaseEntityBlock implements GameMasterBlock { - - private static final Logger LOGGER = LogUtils.getLogger(); -@@ -117,6 +118,15 @@ public class CommandBlock extends BaseEntityBlock implements GameMasterBlock { + import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit +@@ -117,6 +119,15 @@ public class CommandBlock extends BaseEntityBlock implements GameMasterBlock { } private void execute(BlockState state, Level world, BlockPos pos, BaseCommandBlock executor, boolean hasCommand) { -+ // Scissors - Add master block fire event ++ // Scissors start - Add master block fire event + final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ())); + + if (!event.callEvent()) @@ -44,44 +39,31 @@ index 2e7c03b00bc941b86df6a7f1b2b188c9f0aede22..333f9bcccbe9ecd88c1fd13e2956f694 if (hasCommand) { executor.performCommand(world); } else { -diff --git a/src/main/java/net/minecraft/world/level/block/StructureBlock.java b/src/main/java/net/minecraft/world/level/block/StructureBlock.java -index a3dac53b07618819b322b48339d850d80a1c55ba..4dd21b7ea247b3ced3d3ee6c67746cc6811d5bb8 100644 ---- a/src/main/java/net/minecraft/world/level/block/StructureBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/StructureBlock.java -@@ -1,6 +1,7 @@ - package net.minecraft.world.level.block; - - import javax.annotation.Nullable; -+ - import net.minecraft.core.BlockPos; - import net.minecraft.server.level.ServerLevel; - import net.minecraft.world.InteractionHand; diff --git a/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java -index 182e16c1d968707a11329150d71b7d01df6c6e52..fa5cade3f5f2fecc37cc065b96403d0a1c1a2553 100644 +index 182e16c1d968707a11329150d71b7d01df6c6e52..8582a9369cffe0eebeb82a81fc413d0bf4ad28ed 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java -@@ -2,6 +2,8 @@ package net.minecraft.world.level.block.entity; +@@ -2,6 +2,7 @@ package net.minecraft.world.level.block.entity; import java.util.Arrays; import java.util.Optional; -+ -+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent; ++import me.totalfreedom.scissors.event.block.MasterBlockFireEvent; // Scissors import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.core.Registry; -@@ -17,6 +19,7 @@ import net.minecraft.world.level.block.JigsawBlock; +@@ -17,6 +18,7 @@ import net.minecraft.world.level.block.JigsawBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.structure.pools.JigsawPlacement; import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool; -+import org.bukkit.Location; ++import org.bukkit.Location; // Scissors public class JigsawBlockEntity extends BlockEntity { public static final String TARGET = "target"; -@@ -107,6 +110,16 @@ public class JigsawBlockEntity extends BlockEntity { +@@ -107,6 +109,16 @@ public class JigsawBlockEntity extends BlockEntity { } public void generate(ServerLevel world, int maxDepth, boolean keepJigsaws) { -+ // Scissors - Add master block fire event ++ // Scissors start - Add master block fire event + final BlockPos pos = this.getBlockPos(); + final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), pos.getX(), pos.getY(), pos.getZ())); + @@ -95,31 +77,31 @@ index 182e16c1d968707a11329150d71b7d01df6c6e52..fa5cade3f5f2fecc37cc065b96403d0a Registry registry = world.registryAccess().registryOrThrow(Registries.TEMPLATE_POOL); // Paper start - Replace getHolderOrThrow with a null check diff --git a/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java -index 9792bf3ee083f571f1f4089d30beb586839f5f6b..e9d584b0ca984f9b7c70f99e1665cdedecb710e1 100644 +index 9792bf3ee083f571f1f4089d30beb586839f5f6b..fa6592cdc916d3578fccc6c0075eb616fd3f73eb 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java -@@ -5,6 +5,8 @@ import java.util.Objects; +@@ -5,6 +5,7 @@ import java.util.Objects; import java.util.Optional; import java.util.stream.Stream; import javax.annotation.Nullable; -+ -+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent; ++import me.totalfreedom.scissors.event.block.MasterBlockFireEvent; // Scissors import net.minecraft.ResourceLocationException; import net.minecraft.Util; import net.minecraft.core.BlockPos; -@@ -29,6 +31,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.BlockRotProce +@@ -29,6 +30,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.BlockRotProce import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager; -+import org.bukkit.Location; ++import org.bukkit.Location; // Scissors public class StructureBlockEntity extends BlockEntity { private static final int SCAN_CORNER_BLOCKS_RANGE = 5; -@@ -264,7 +267,6 @@ public class StructureBlockEntity extends BlockEntity { +@@ -264,7 +266,7 @@ public class StructureBlockEntity extends BlockEntity { return false; } else { BlockPos blockPos = this.getBlockPos(); - int i = 80; ++ // Scissors - Obfuscation fixes BlockPos blockPos2 = new BlockPos(blockPos.getX() - 80, this.level.getMinBuildHeight(), blockPos.getZ() - 80); BlockPos blockPos3 = new BlockPos(blockPos.getX() + 80, this.level.getMaxBuildHeight() - 1, blockPos.getZ() + 80); Stream stream = this.getRelatedCorners(blockPos2, blockPos3); @@ -127,7 +109,7 @@ index 9792bf3ee083f571f1f4089d30beb586839f5f6b..e9d584b0ca984f9b7c70f99e1665cded public boolean saveStructure(boolean bl) { if (this.mode == StructureMode.SAVE && !this.level.isClientSide && this.structureName != null) { -+ // Scissors - Add master block fire event ++ // Scissors start - Add master block fire event + final BlockPos pos = this.getBlockPos(); + final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), pos.getX(), pos.getY(), pos.getZ())); + @@ -144,7 +126,7 @@ index 9792bf3ee083f571f1f4089d30beb586839f5f6b..e9d584b0ca984f9b7c70f99e1665cded public boolean loadStructure(ServerLevel world, boolean bl) { if (this.mode == StructureMode.LOAD && this.structureName != null) { -+ // Scissors - Add master block fire event ++ // Scissors start - Add master block fire event + final BlockPos blockPos = this.getBlockPos(); + final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), blockPos.getX(), blockPos.getY(), blockPos.getZ())); + @@ -161,7 +143,7 @@ index 9792bf3ee083f571f1f4089d30beb586839f5f6b..e9d584b0ca984f9b7c70f99e1665cded } public void unloadStructure() { -+ // Scissors - Add master block fire event ++ // Scissors start - Add master block fire event + final BlockPos blockPos = this.getBlockPos(); + final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), blockPos.getX(), blockPos.getY(), blockPos.getZ())); + diff --git a/patches/server/0031-Add-spectator-teleport-event.patch b/patches/server/0028-Add-spectator-teleport-event.patch similarity index 89% rename from patches/server/0031-Add-spectator-teleport-event.patch rename to patches/server/0028-Add-spectator-teleport-event.patch index c141749..f5caed5 100644 --- a/patches/server/0031-Add-spectator-teleport-event.patch +++ b/patches/server/0028-Add-spectator-teleport-event.patch @@ -5,17 +5,17 @@ Subject: [PATCH] Add spectator teleport event diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 80384bf470da2da2d6214a9d3429c8556aa18320..cf0bd9aba6de16e8061d5f8b4268969fe812fa37 100644 +index aa287d7f37f38d938d195114408cb6dbda59063d..e46febba49530c4c71a15bfc75d731c45fcb48f2 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -1,5 +1,6 @@ package net.minecraft.server.network; -+import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; ++import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors import com.google.common.collect.Lists; import com.google.common.primitives.Floats; import com.mojang.brigadier.ParseResults; -@@ -2068,6 +2069,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2056,6 +2057,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic Entity entity = packet.getEntity(worldserver); if (entity != null) { diff --git a/patches/server/0032-Prevent-invalid-container-events.patch b/patches/server/0029-Prevent-invalid-container-events.patch similarity index 65% rename from patches/server/0032-Prevent-invalid-container-events.patch rename to patches/server/0029-Prevent-invalid-container-events.patch index 8ab9bf8..50a08d2 100644 --- a/patches/server/0032-Prevent-invalid-container-events.patch +++ b/patches/server/0029-Prevent-invalid-container-events.patch @@ -5,27 +5,18 @@ Subject: [PATCH] Prevent invalid container events diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index cf0bd9aba6de16e8061d5f8b4268969fe812fa37..f5f94b7a7f7055dd9dfeb0da161de3553b8e7d38 100644 +index e46febba49530c4c71a15bfc75d731c45fcb48f2..798ffda66ccbc98a073b276208e04d643b04e1b2 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -30,6 +30,8 @@ import java.util.function.UnaryOperator; +@@ -30,6 +30,7 @@ import java.util.function.UnaryOperator; import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.Nullable; -+ -+import net.kyori.adventure.text.format.NamedTextColor; ++import net.kyori.adventure.text.format.NamedTextColor; // Scissors import net.minecraft.ChatFormatting; import net.minecraft.CrashReport; import net.minecraft.CrashReportCategory; -@@ -2987,6 +2989,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - public void handleContainerClick(ServerboundContainerClickPacket packet) { - PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); - if (this.player.isImmobile()) return; // CraftBukkit -+ - this.player.resetLastActionTime(); - if (this.player.containerMenu.containerId == packet.getContainerId() && this.player.containerMenu.stillValid(this.player)) { // CraftBukkit - boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if -@@ -3008,6 +3011,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2996,6 +2997,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic return; } diff --git a/patches/server/0030-Disable-running-commands-in-books-by-default.patch b/patches/server/0030-Disable-running-commands-in-books-by-default.patch new file mode 100644 index 0000000..18bb269 --- /dev/null +++ b/patches/server/0030-Disable-running-commands-in-books-by-default.patch @@ -0,0 +1,73 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Allink +Date: Sun, 10 Jul 2022 10:29:03 +0100 +Subject: [PATCH] Disable running commands in books by default + + +diff --git a/src/main/java/net/minecraft/world/item/WrittenBookItem.java b/src/main/java/net/minecraft/world/item/WrittenBookItem.java +index 31911c09fe15753ae32fa39417bdc9e9de552a88..b810a5afcb2343174e37efb7dd8a36b968b07c3a 100644 +--- a/src/main/java/net/minecraft/world/item/WrittenBookItem.java ++++ b/src/main/java/net/minecraft/world/item/WrittenBookItem.java +@@ -2,6 +2,7 @@ package net.minecraft.world.item; + + import java.util.List; + import javax.annotation.Nullable; ++import me.totalfreedom.scissors.ScissorsConfig; // Scissors + import net.minecraft.ChatFormatting; + import net.minecraft.commands.CommandSourceStack; + import net.minecraft.core.BlockPos; +@@ -9,8 +10,7 @@ import net.minecraft.nbt.CompoundTag; + import net.minecraft.nbt.ListTag; + import net.minecraft.nbt.StringTag; + import net.minecraft.nbt.Tag; +-import net.minecraft.network.chat.Component; +-import net.minecraft.network.chat.ComponentUtils; ++import net.minecraft.network.chat.*; // Scissors + import net.minecraft.stats.Stats; + import net.minecraft.util.StringUtil; + import net.minecraft.world.InteractionHand; +@@ -161,9 +161,43 @@ public class WrittenBookItem extends Item { + component2 = Component.literal(text); + } + +- return Component.Serializer.toJson(component2); ++ return Component.Serializer.toJson(!ScissorsConfig.runCommandsInBooks ? sanitize(component2, 0) : component2); // Scissors - Allow server owners to disable run command in books + } + ++ // Scissors start - Allow server owners to disable run command in books ++ public static Component sanitize(Component component, int depth) ++ { ++ if (depth > 128) ++ { ++ return Component.nullToEmpty("Sanitization function depth limit exceeded"); ++ } ++ ++ MutableComponent component2 = component.copy(); ++ ++ final Style style = component2.getStyle(); ++ final ClickEvent clickEvent = style.getClickEvent(); ++ ++ if (clickEvent != null && clickEvent.getAction().equals(ClickEvent.Action.RUN_COMMAND)) ++ { ++ final String clickEventValue = clickEvent.getValue(); ++ ++ component2 = component2.copy().setStyle(style ++ .withClickEvent(null) ++ .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.nullToEmpty("Would've " + (clickEventValue.startsWith("/") ? "ran" : "said") + ": " + clickEvent.getValue()))) ++ ); ++ } ++ ++ final List processedExtra = component2.getSiblings() ++ .stream() ++ .map(comp -> sanitize(comp, depth + 1)) ++ .toList(); ++ component2.getSiblings().clear(); ++ component2.getSiblings().addAll(processedExtra); ++ ++ return component2; ++ } ++ // Scissors end ++ + @Override + public boolean isFoil(ItemStack stack) { + return true; diff --git a/patches/server/0031-Validate-block-entity-tag-query-positions.patch b/patches/server/0031-Validate-block-entity-tag-query-positions.patch new file mode 100644 index 0000000..95ea034 --- /dev/null +++ b/patches/server/0031-Validate-block-entity-tag-query-positions.patch @@ -0,0 +1,31 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Luna +Date: Mon, 11 Jul 2022 17:29:12 -0300 +Subject: [PATCH] Validate block entity tag query positions + + +diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +index 798ffda66ccbc98a073b276208e04d643b04e1b2..d428490171bb1c0209ca9a279c2b1e1e1dfcf914 100644 +--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java ++++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +@@ -1359,7 +1359,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic + if (this.player.hasPermissions(2)) { + Entity entity = this.player.getLevel().getEntity(packet.getEntityId()); + +- if (entity != null) { ++ if (entity != null && this.player.distanceToSqr(entity.position().x, entity.position().y, entity.position().z) < 32 * 32) { // Scissors - Validate entity tag query positions + CompoundTag nbttagcompound = entity.saveWithoutId(new CompoundTag()); + + this.player.connection.send(new ClientboundTagQueryPacket(packet.getTransactionId(), nbttagcompound)); +@@ -1371,7 +1371,10 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic + @Override + public void handleBlockEntityTagQuery(ServerboundBlockEntityTagQuery packet) { + PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); +- if (this.player.hasPermissions(2)) { ++ // Scissors start - Validate block entity tag query positions ++ if (this.player.hasPermissions(2) && this.player.getLevel().isLoadedAndInBounds(packet.getPos()) ++ && this.player.distanceToSqr(packet.getPos().getX(), packet.getPos().getY(), packet.getPos().getZ()) < 32 * 32) { ++ // Scissors end + BlockEntity tileentity = this.player.getLevel().getBlockEntity(packet.getPos()); + CompoundTag nbttagcompound = tileentity != null ? tileentity.saveWithoutMetadata() : null; + diff --git a/patches/server/0032-Fix-ClickEvents-on-Signs-bypassing-permissions.patch b/patches/server/0032-Fix-ClickEvents-on-Signs-bypassing-permissions.patch new file mode 100644 index 0000000..7b3d17d --- /dev/null +++ b/patches/server/0032-Fix-ClickEvents-on-Signs-bypassing-permissions.patch @@ -0,0 +1,60 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Allink +Date: Wed, 13 Jul 2022 12:13:22 +0100 +Subject: [PATCH] Fix ClickEvents on Signs bypassing permissions + + +diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java +index 4da4edae517a0efec6e03a719ec47b700509dab1..96e330e024384503496f834a9767122f6b4d86d6 100644 +--- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java ++++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java +@@ -4,8 +4,10 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; + import java.util.UUID; + import java.util.function.Function; + import javax.annotation.Nullable; ++import me.totalfreedom.scissors.ScissorsConfig; // Scissors + import net.minecraft.commands.CommandSource; + import net.minecraft.commands.CommandSourceStack; ++import net.minecraft.commands.Commands; // Scissors + import net.minecraft.core.BlockPos; + import net.minecraft.nbt.CompoundTag; + import net.minecraft.network.chat.ClickEvent; +@@ -15,6 +17,7 @@ import net.minecraft.network.chat.ComponentUtils; + import net.minecraft.network.chat.MutableComponent; + import net.minecraft.network.chat.Style; + import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; ++import net.minecraft.server.MinecraftServer; // Scissors + import net.minecraft.server.level.ServerLevel; + import net.minecraft.server.level.ServerPlayer; + import net.minecraft.util.FormattedCharSequence; +@@ -24,6 +27,8 @@ import net.minecraft.world.item.DyeColor; + import net.minecraft.world.level.block.state.BlockState; + import net.minecraft.world.phys.Vec2; + import net.minecraft.world.phys.Vec3; ++import org.bukkit.craftbukkit.CraftServer; // Scissors ++import org.bukkit.craftbukkit.entity.CraftPlayer; // Scissors + + public class SignBlockEntity extends BlockEntity implements CommandSource { // CraftBukkit - implements + private static final boolean CONVERT_LEGACY_SIGNS = Boolean.getBoolean("convertLegacySigns"); // Paper +@@ -272,6 +277,21 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C + } + player.getServer().getCommands().performPrefixedCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle()), event.getMessage()); + // Paper end ++ // Scissors start - Add optional permissions to command signs ++ final MinecraftServer vanillaServer = player.getServer(); ++ final CraftServer craftServer = vanillaServer.server; ++ final CraftPlayer craftPlayer = player.getBukkitEntity(); ++ final Commands commands = vanillaServer.getCommands(); ++ ++ if (ScissorsConfig.commandSignsBypassPermissions) ++ { ++ commands.performPrefixedCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle()), event.getMessage()); ++ } ++ else ++ { ++ craftServer.dispatchCommand(craftPlayer, command.substring(1)); ++ } ++ // Scissors end + } + } + diff --git a/patches/server/0033-Refuse-to-convert-legacy-messages-over-1k-characters.patch b/patches/server/0033-Refuse-to-convert-legacy-messages-over-1k-characters.patch new file mode 100644 index 0000000..7eac5d1 --- /dev/null +++ b/patches/server/0033-Refuse-to-convert-legacy-messages-over-1k-characters.patch @@ -0,0 +1,18 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Allink +Date: Tue, 16 Aug 2022 17:13:02 +0100 +Subject: [PATCH] Refuse to convert legacy messages over 1k characters + + +diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java +index 0f70be614f8f5350ad558d0ae645cdf0027e1e76..c006ac8531cf2c029fd2fac449f96736a4afed0d 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java +@@ -199,6 +199,7 @@ public final class CraftChatMessage { + } + + public static Component[] fromString(String message, boolean keepNewlines, boolean plain) { ++ if (message.length() > 1_000) return new Component[]{Component.empty()}; // Scissors - Refuse to convert legacy messages over 1k characters + return new StringMessage(message, keepNewlines, plain).getOutput(); + } + diff --git a/patches/server/0033-Validate-block-entity-tag-query-positions.patch b/patches/server/0033-Validate-block-entity-tag-query-positions.patch deleted file mode 100644 index 74a868c..0000000 --- a/patches/server/0033-Validate-block-entity-tag-query-positions.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Luna -Date: Mon, 11 Jul 2022 17:29:12 -0300 -Subject: [PATCH] Validate block entity tag query positions - - -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index f5f94b7a7f7055dd9dfeb0da161de3553b8e7d38..5c347c8ff0eb3eb500a7bd49d61fb19925d780ce 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1372,7 +1372,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - @Override - public void handleBlockEntityTagQuery(ServerboundBlockEntityTagQuery packet) { - PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); -- if (this.player.hasPermissions(2)) { -+ if (this.player.hasPermissions(2) && Level.isInSpawnableBounds(packet.getPos())) { // Scissors - Validate block entity tag query positions - BlockEntity tileentity = this.player.getLevel().getBlockEntity(packet.getPos()); - CompoundTag nbttagcompound = tileentity != null ? tileentity.saveWithoutMetadata() : null; - diff --git a/patches/server/0036-Prevent-velocity-freeze.patch b/patches/server/0034-Prevent-velocity-freeze.patch similarity index 94% rename from patches/server/0036-Prevent-velocity-freeze.patch rename to patches/server/0034-Prevent-velocity-freeze.patch index 5c807b4..c44e923 100644 --- a/patches/server/0036-Prevent-velocity-freeze.patch +++ b/patches/server/0034-Prevent-velocity-freeze.patch @@ -5,13 +5,13 @@ Subject: [PATCH] Prevent velocity freeze diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java -index 2096e8a0bdbcfc865f175f3a01ab688542481531..15d375221c253dc4ca1b598eb80b4638eba6f8d0 100644 +index 2096e8a0bdbcfc865f175f3a01ab688542481531..2ad58d4e4fd361d17803f57c3496a92bd233c857 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java @@ -1,5 +1,6 @@ package net.minecraft.world.entity.projectile; -+import me.totalfreedom.scissors.MathUtility; ++import me.totalfreedom.scissors.MathUtility; // Scissors import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; @@ -26,9 +26,9 @@ index 2096e8a0bdbcfc865f175f3a01ab688542481531..15d375221c253dc4ca1b598eb80b4638 + //this.xPower = d3 / d6 * 0.1D; + //this.yPower = d4 / d6 * 0.1D; + //this.zPower = d5 / d6 * 0.1D; -+ // Scissors end + + setPower(d3 / d6 * .1d, d4 / d6 * .1d, d5 / d6 * .1d); ++ // Scissors end } } @@ -69,13 +69,13 @@ index 2096e8a0bdbcfc865f175f3a01ab688542481531..15d375221c253dc4ca1b598eb80b4638 + //this.xPower = nbttaglist.getDouble(0); + //this.yPower = nbttaglist.getDouble(1); + //this.zPower = nbttaglist.getDouble(2); -+ // Scissors end + + setPower(nbttaglist.getDouble(0), nbttaglist.getDouble(1), nbttaglist.getDouble(2)); ++ // Scissors end } } -@@ -184,9 +212,12 @@ public abstract class AbstractHurtingProjectile extends Projectile { +@@ -184,9 +212,13 @@ public abstract class AbstractHurtingProjectile extends Projectile { Vec3 vec3d = entity.getLookAngle(); this.setDeltaMovement(vec3d); @@ -86,6 +86,7 @@ index 2096e8a0bdbcfc865f175f3a01ab688542481531..15d375221c253dc4ca1b598eb80b4638 + //this.xPower = vec3d.x * 0.1D; + //this.yPower = vec3d.y * 0.1D; + //this.zPower = vec3d.z * 0.1D; ++ + setPower(vec3d.x * 0.1D, vec3d.y * 0.1D, vec3d.z * 0.1D); + // Scissors end this.setOwner(entity); diff --git a/patches/server/0034-Refuse-to-convert-legacy-messages-over-1k-characters.patch b/patches/server/0034-Refuse-to-convert-legacy-messages-over-1k-characters.patch deleted file mode 100644 index 79cef2a..0000000 --- a/patches/server/0034-Refuse-to-convert-legacy-messages-over-1k-characters.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Allink -Date: Tue, 16 Aug 2022 17:13:02 +0100 -Subject: [PATCH] Refuse to convert legacy messages over 1k characters - - -diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java -index 0f70be614f8f5350ad558d0ae645cdf0027e1e76..6f036df37609daf33db3884174406e1ccd339735 100644 ---- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java -+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java -@@ -3,12 +3,14 @@ package org.bukkit.craftbukkit.util; - import com.google.common.collect.ImmutableMap; - import com.google.common.collect.ImmutableMap.Builder; - import com.google.gson.JsonParseException; -+ - import java.util.ArrayList; - import java.util.List; - import java.util.Map; - import java.util.Optional; - import java.util.regex.Matcher; - import java.util.regex.Pattern; -+ - import net.minecraft.ChatFormatting; - import net.minecraft.network.chat.ClickEvent; - import net.minecraft.network.chat.ClickEvent.Action; -@@ -199,6 +201,11 @@ public final class CraftChatMessage { - } - - public static Component[] fromString(String message, boolean keepNewlines, boolean plain) { -+ // Scissors start - Refuse to convert legacy messages over 1k characters -+ if (message.length() > 1_000) { -+ return new Component[]{Component.empty()}; -+ } -+ // Scissors end - return new StringMessage(message, keepNewlines, plain).getOutput(); - } - diff --git a/patches/server/0035-Add-configuration-option-to-disable-chat-signatures.patch b/patches/server/0035-Add-configuration-option-to-disable-chat-signatures.patch new file mode 100644 index 0000000..3ba70b9 --- /dev/null +++ b/patches/server/0035-Add-configuration-option-to-disable-chat-signatures.patch @@ -0,0 +1,101 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Allink +Date: Tue, 31 Jan 2023 23:16:52 +0000 +Subject: [PATCH] Add configuration option to disable chat signatures + + +diff --git a/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java b/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java +index 74cf1c043beef03cfd5adf481414a5ee78bef2a6..1a44bad14ce764d6c09f38065ee8e5f0da4975aa 100644 +--- a/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java ++++ b/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java +@@ -1,5 +1,6 @@ + package net.minecraft.network.chat; + ++import me.totalfreedom.scissors.ScissorsConfig; // Scissors + import net.minecraft.server.level.ServerPlayer; + + public interface OutgoingChatMessage { +@@ -44,10 +45,25 @@ public interface OutgoingChatMessage { + // Paper end + PlayerChatMessage playerChatMessage = this.message.filter(filterMaskEnabled); + playerChatMessage = unsigned != null ? playerChatMessage.withUnsignedContent(unsigned) : playerChatMessage; // Paper +- if (!playerChatMessage.isFullyFiltered()) { ++ // Scissors start ++ if (!playerChatMessage.isFullyFiltered() && ScissorsConfig.chatSignaturesEnabled) { + sender.connection.sendPlayerChatMessage(playerChatMessage, params); ++ return; + } + ++ if (sender.getServer().server.getOnlineMode()) { ++ sender.connection.sendDisguisedChatMessage(playerChatMessage.decoratedContent(), params); ++ } else { ++ sender.connection.sendPlayerChatMessage(new PlayerChatMessage( ++ SignedMessageLink.unsigned(playerChatMessage.sender()), ++ null, ++ SignedMessageBody.unsigned(playerChatMessage.signedContent()), ++ unsigned, ++ playerChatMessage.filterMask(), ++ playerChatMessage.result() ++ ), params); ++ } ++ // Scissors end + } + } + } +diff --git a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java +index c0a80824a0307ea673805015119cc834b268f0dc..9f28f86b1b56ea55ab39f6ac988c1f47c5312c6c 100644 +--- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java ++++ b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java +@@ -4,6 +4,7 @@ import com.mojang.logging.LogUtils; + import java.time.Instant; + import java.util.UUID; + import javax.annotation.Nullable; ++import me.totalfreedom.scissors.ScissorsConfig; // Scissors + import net.minecraft.util.SignatureUpdater; + import net.minecraft.util.SignatureValidator; + import net.minecraft.util.Signer; +@@ -41,7 +42,7 @@ public class SignedMessageChain { + if (!playerChatMessage.verify(signatureValidator)) { + throw new SignedMessageChain.DecodeException(Component.translatable("multiplayer.disconnect.unsigned_chat"), true, org.bukkit.event.player.PlayerKickEvent.Cause.UNSIGNED_CHAT); // Paper - kick event causes + } else { +- if (playerChatMessage.hasExpiredServer(Instant.now())) { ++ if (playerChatMessage.hasExpiredServer(Instant.now()) && ScissorsConfig.chatSignaturesEnabled) { // Scissors + LOGGER.warn("Received expired chat: '{}'. Is the client/server system time unsynchronized?", (Object)body.content()); + } + +diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +index d428490171bb1c0209ca9a279c2b1e1e1dfcf914..8274514733caf0fb3c3db5836a3ab9bd204c4378 100644 +--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java ++++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +@@ -1,5 +1,6 @@ + package net.minecraft.server.network; + ++import me.totalfreedom.scissors.ScissorsConfig; // Scissors + import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors + import com.google.common.collect.Lists; + import com.google.common.primitives.Floats; +@@ -2311,7 +2312,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic + } + + private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) { +- if (exception.shouldDisconnect()) { ++ if (exception.shouldDisconnect() && ScissorsConfig.chatSignaturesEnabled) { // Scissors - Do not kick when chat signatures are disabled + this.disconnect(exception.getComponent(), exception.kickCause); // Paper - kick event causes + } else { + this.player.sendSystemMessage(exception.getComponent().copy().withStyle(ChatFormatting.RED)); +@@ -2367,6 +2368,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic + Optional optional = this.lastSeenMessages.applyUpdate(acknowledgment); + + if (optional.isEmpty()) { ++ if (!ScissorsConfig.chatSignaturesEnabled) return optional; // Scissors + ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString()); + this.disconnect(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes + } +@@ -2602,6 +2604,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic + + synchronized (this.lastSeenMessages) { + if (!this.lastSeenMessages.applyOffset(packet.offset())) { ++ if (!ScissorsConfig.chatSignaturesEnabled) return; // Scissors + ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString()); + this.disconnect(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes + } diff --git a/patches/server/0038-Patch-invalid-entity-rotation-log-spam.patch b/patches/server/0036-Patch-invalid-entity-rotation-log-spam.patch similarity index 61% rename from patches/server/0038-Patch-invalid-entity-rotation-log-spam.patch rename to patches/server/0036-Patch-invalid-entity-rotation-log-spam.patch index 22ebe5c..1249f22 100644 --- a/patches/server/0038-Patch-invalid-entity-rotation-log-spam.patch +++ b/patches/server/0036-Patch-invalid-entity-rotation-log-spam.patch @@ -5,28 +5,24 @@ Subject: [PATCH] Patch invalid entity rotation log spam diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index ade4ed2f219d32050a372283eaebe75f9014ec78..deb54926662b2872f40d688db2756faadbf6aa6e 100644 +index ade4ed2f219d32050a372283eaebe75f9014ec78..88d119605eba1b59fad431d94882f054f0074b80 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -4482,7 +4482,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4482,7 +4482,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { public void setYRot(float yaw) { if (!Float.isFinite(yaw)) { - Util.logAndPauseIfInIde("Invalid entity rotation: " + yaw + ", discarding."); -+ // Scissors start - Patch invalid entity rotation log spam -+ //Util.logAndPauseIfInIde("Invalid entity rotation: " + yaw + ", discarding."); -+ // Scissors end ++ // Scissors - Patch invalid entity rotation log spam } else { this.yRot = yaw; } -@@ -4494,7 +4496,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4494,7 +4494,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { public void setXRot(float pitch) { if (!Float.isFinite(pitch)) { - Util.logAndPauseIfInIde("Invalid entity rotation: " + pitch + ", discarding."); -+ // Scissors start - Patch invalid entity rotation log spam -+ //Util.logAndPauseIfInIde("Invalid entity rotation: " + pitch + ", discarding."); -+ // Scissors end ++ // Scissors - Patch invalid entity rotation log spam } else { this.xRot = pitch; } diff --git a/patches/server/0039-Patch-large-selector-distance-crash.patch b/patches/server/0037-Patch-large-selector-distance-crash.patch similarity index 95% rename from patches/server/0039-Patch-large-selector-distance-crash.patch rename to patches/server/0037-Patch-large-selector-distance-crash.patch index f9c17ac..034c00b 100644 --- a/patches/server/0039-Patch-large-selector-distance-crash.patch +++ b/patches/server/0037-Patch-large-selector-distance-crash.patch @@ -18,14 +18,14 @@ index 60d32afe2eecdfebdc91531ca3672f8f130ac30e..73b0f516f80ef810379860ea74697a34 this.minSq = squareOpt(min); this.maxSq = squareOpt(max); diff --git a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java -index f25b9330e068c7d9e12cb57a7761cfef9ebaf7bc..ba549e6e5da75413ae3b4083f8b7a5527672de4e 100644 +index f25b9330e068c7d9e12cb57a7761cfef9ebaf7bc..e8cf963f0190438bbf65f827d144775ab0b02b63 100644 --- a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java @@ -10,6 +10,7 @@ import java.util.function.BiConsumer; import java.util.function.Function; import java.util.function.Predicate; import javax.annotation.Nullable; -+import me.totalfreedom.scissors.MathUtility; ++import me.totalfreedom.scissors.MathUtility; // Scissors import net.minecraft.advancements.critereon.MinMaxBounds; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.arguments.EntityArgument; diff --git a/patches/server/0040-Limit-sculk-catalyst-cursor-positions.patch b/patches/server/0038-Limit-sculk-catalyst-cursor-positions.patch similarity index 74% rename from patches/server/0040-Limit-sculk-catalyst-cursor-positions.patch rename to patches/server/0038-Limit-sculk-catalyst-cursor-positions.patch index c4c51c5..90e4672 100644 --- a/patches/server/0040-Limit-sculk-catalyst-cursor-positions.patch +++ b/patches/server/0038-Limit-sculk-catalyst-cursor-positions.patch @@ -5,20 +5,14 @@ Subject: [PATCH] Limit sculk catalyst cursor positions diff --git a/src/main/java/net/minecraft/world/level/block/SculkSpreader.java b/src/main/java/net/minecraft/world/level/block/SculkSpreader.java -index ab732f0e52ef3c3d3be6ddc827d693fe294e4167..761c8cfb98e05a3c500599520e26e4323725fc85 100644 +index ab732f0e52ef3c3d3be6ddc827d693fe294e4167..9785f2d8c94552b4a1139fa6d936fdaa61e5827c 100644 --- a/src/main/java/net/minecraft/world/level/block/SculkSpreader.java +++ b/src/main/java/net/minecraft/world/level/block/SculkSpreader.java -@@ -141,6 +141,13 @@ public class SculkSpreader { +@@ -141,6 +141,7 @@ public class SculkSpreader { Object2IntMap object2IntMap = new Object2IntOpenHashMap<>(); for(SculkSpreader.ChargeCursor chargeCursor : this.cursors) { -+ // Scissors start -+ if (!world.getMinecraftWorld().isLoadedAndInBounds(chargeCursor.getPos())) -+ { -+ continue; -+ } -+ // Scissors end -+ ++ if (!world.getMinecraftWorld().isLoadedAndInBounds(chargeCursor.getPos())) continue; // Scissors chargeCursor.update(world, pos, random, this, shouldConvertToBlock); if (chargeCursor.charge <= 0) { world.levelEvent(3006, chargeCursor.getPos(), 0); diff --git a/patches/server/0039-Limit-map-decorations.patch b/patches/server/0039-Limit-map-decorations.patch new file mode 100644 index 0000000..239f491 --- /dev/null +++ b/patches/server/0039-Limit-map-decorations.patch @@ -0,0 +1,46 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Luna +Date: Fri, 28 Apr 2023 16:29:23 -0300 +Subject: [PATCH] Limit map decorations + + +diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java +index 347d2914f9560a3ee8cea59444bc0dfbb7cf3456..b6a38b1458957bd444fea439fa81d2976ffb86e0 100644 +--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java ++++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java +@@ -2,6 +2,7 @@ package net.minecraft.world.level.saveddata.maps; + + import java.util.Objects; + import javax.annotation.Nullable; ++import net.minecraft.ChatFormatting; // Scissors + import net.minecraft.network.chat.Component; + import net.minecraft.util.Mth; + +@@ -14,6 +15,11 @@ public class MapDecoration { + private final Component name; + + public MapDecoration(MapDecoration.Type type, byte x, byte z, byte rotation, @Nullable Component text) { ++ // Scissors start - Limit decoration text length ++ if (text != null && text.getString().length() > 32) { ++ text = null; ++ } ++ // Scissors end + this.type = type; + this.x = x; + this.y = z; +diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java +index 25a64250ce57fe4cd90f8b95d1e003d961662152..65c2b553711e9f9ded87a422c4a0aacd7de8d8c1 100644 +--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java ++++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java +@@ -356,6 +356,11 @@ public class MapItemSavedData extends SavedData { + } + + private void addDecoration(MapDecoration.Type type, @Nullable LevelAccessor world, String key, double x, double z, double rotation, @Nullable Component text) { ++ // Scissors start - Limit decoration count ++ if (this.decorations.size() > 32) { ++ return; ++ } ++ // Scissors end + int i = 1 << this.scale; + float f = (float) (x - (double) this.centerX) / (float) i; + float f1 = (float) (z - (double) this.centerZ) / (float) i; diff --git a/patches/server/0043-Prevent-player-banning-using-duplicate-UUIDs.patch b/patches/server/0040-Prevent-player-banning-using-duplicate-UUIDs.patch similarity index 100% rename from patches/server/0043-Prevent-player-banning-using-duplicate-UUIDs.patch rename to patches/server/0040-Prevent-player-banning-using-duplicate-UUIDs.patch diff --git a/patches/server/0044-Don-t-warn-on-duplicate-entity-UUIDs.patch b/patches/server/0041-Don-t-warn-on-duplicate-entity-UUIDs.patch similarity index 100% rename from patches/server/0044-Don-t-warn-on-duplicate-entity-UUIDs.patch rename to patches/server/0041-Don-t-warn-on-duplicate-entity-UUIDs.patch diff --git a/patches/server/0041-Limit-map-decoration-text-length.patch b/patches/server/0041-Limit-map-decoration-text-length.patch deleted file mode 100644 index b979d3f..0000000 --- a/patches/server/0041-Limit-map-decoration-text-length.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Luna -Date: Fri, 28 Apr 2023 16:29:23 -0300 -Subject: [PATCH] Limit map decoration text length - - -diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java -index 347d2914f9560a3ee8cea59444bc0dfbb7cf3456..b225f770869832775c9a8a79ffaf89e98245cc2e 100644 ---- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java -+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java -@@ -2,6 +2,7 @@ package net.minecraft.world.level.saveddata.maps; - - import java.util.Objects; - import javax.annotation.Nullable; -+import net.minecraft.ChatFormatting; - import net.minecraft.network.chat.Component; - import net.minecraft.util.Mth; - -@@ -14,6 +15,12 @@ public class MapDecoration { - private final Component name; - - public MapDecoration(MapDecoration.Type type, byte x, byte z, byte rotation, @Nullable Component text) { -+ // Scissors start - Limit decoration text length -+ if (text != null && text.getString().length() > 32) { -+ text = null; -+ } -+ // Scissors end -+ - this.type = type; - this.x = x; - this.y = z; diff --git a/patches/server/0046-Fix-component-extra-empty-array-exploit.patch b/patches/server/0042-Fix-component-extra-empty-array-exploit.patch similarity index 62% rename from patches/server/0046-Fix-component-extra-empty-array-exploit.patch rename to patches/server/0042-Fix-component-extra-empty-array-exploit.patch index e4acc93..b506470 100644 --- a/patches/server/0046-Fix-component-extra-empty-array-exploit.patch +++ b/patches/server/0042-Fix-component-extra-empty-array-exploit.patch @@ -5,18 +5,14 @@ Subject: [PATCH] Fix component extra empty array exploit diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java -index 3c0ee4e1f42f6056ca86a6f9f129d467e29a2fbc..9c2c22ee548ad77f0912698f33de5f467f32fb7f 100644 +index 2873ed7c443ed8c8c57a8b1d3e444d229f10f07b..a2149452ee461002ea74189c5aa49cddd943d0cf 100644 --- a/src/main/java/net/minecraft/network/chat/Component.java +++ b/src/main/java/net/minecraft/network/chat/Component.java -@@ -266,6 +266,11 @@ public interface Component extends Message, FormattedText, Iterable { +@@ -266,6 +266,7 @@ public interface Component extends Message, FormattedText, Iterable { if (!jsonelement.isJsonObject()) { if (jsonelement.isJsonArray()) { JsonArray jsonarray = jsonelement.getAsJsonArray(); -+ // Scissors start -+ if (jsonarray.size() <= 0) { -+ throw new JsonParseException("Unexpected empty array of components"); -+ } -+ // Scissors end ++ if (jsonarray.size() <= 0) throw new JsonParseException("Unexpected empty array of components"); // Scissors ichatmutablecomponent = null; Iterator iterator = jsonarray.iterator(); diff --git a/patches/server/0042-Limit-map-decoration-count.patch b/patches/server/0042-Limit-map-decoration-count.patch deleted file mode 100644 index 830b1d3..0000000 --- a/patches/server/0042-Limit-map-decoration-count.patch +++ /dev/null @@ -1,23 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Luna -Date: Fri, 28 Apr 2023 16:34:15 -0300 -Subject: [PATCH] Limit map decoration count - - -diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -index 25a64250ce57fe4cd90f8b95d1e003d961662152..60e013d418b1aa8c154ca9474186191aa5c9041d 100644 ---- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -@@ -356,6 +356,12 @@ public class MapItemSavedData extends SavedData { - } - - private void addDecoration(MapDecoration.Type type, @Nullable LevelAccessor world, String key, double x, double z, double rotation, @Nullable Component text) { -+ // Scissors start - Limit decoration count -+ if (this.decorations.size() > 32) { -+ return; -+ } -+ // Scissors end -+ - int i = 1 << this.scale; - float f = (float) (x - (double) this.centerX) / (float) i; - float f1 = (float) (z - (double) this.centerZ) / (float) i; diff --git a/patches/server/0047-Add-depth-limit-to-Component-deserializer.patch b/patches/server/0043-Add-depth-limit-to-Component-deserializer.patch similarity index 72% rename from patches/server/0047-Add-depth-limit-to-Component-deserializer.patch rename to patches/server/0043-Add-depth-limit-to-Component-deserializer.patch index c017ffd..c05b2a1 100644 --- a/patches/server/0047-Add-depth-limit-to-Component-deserializer.patch +++ b/patches/server/0043-Add-depth-limit-to-Component-deserializer.patch @@ -4,36 +4,8 @@ Date: Wed, 31 May 2023 18:14:00 -0300 Subject: [PATCH] Add depth limit to Component deserializer -diff --git a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java -index 39b56ca496ed7369ead21805d476c2b813fcdd1d..9659cff6412584190ff0c32e01f602de4ff7d3b3 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", 4); -- set("config-version", 4); -+ version = getInt("config-version", 5); -+ set("config-version", 5); - readConfig(ScissorsConfig.class, null); - } - -@@ -175,6 +175,12 @@ public class ScissorsConfig - excludePlayersFromNbtComponents = getBoolean("excludePlayersFromNbtComponents", false); - } - -+ public static int componentDepthLimit = 128; -+ private static void componentDepthLimit() -+ { -+ componentDepthLimit = getInt("componentDepthLimit", 128); -+ } -+ - private static void set(String path, Object val) - { - config.set(path, val); diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java -index 9c2c22ee548ad77f0912698f33de5f467f32fb7f..ba2879b25e59290ab81501458414a417c121ed03 100644 +index a2149452ee461002ea74189c5aa49cddd943d0cf..f1d1501211a923c0ccab6b5982887c3a9262889b 100644 --- a/src/main/java/net/minecraft/network/chat/Component.java +++ b/src/main/java/net/minecraft/network/chat/Component.java @@ -26,6 +26,7 @@ import java.util.List; @@ -41,7 +13,7 @@ index 9c2c22ee548ad77f0912698f33de5f467f32fb7f..ba2879b25e59290ab81501458414a417 import java.util.Optional; import javax.annotation.Nullable; +import me.totalfreedom.scissors.ScissorsConfig; // Scissors - import net.minecraft.ChatFormatting; + import net.minecraft.ChatFormatting; // Scissors import net.minecraft.Util; import net.minecraft.network.chat.contents.BlockDataSource; @@ -44,6 +45,7 @@ import net.minecraft.util.GsonHelper; @@ -66,80 +38,70 @@ index 9c2c22ee548ad77f0912698f33de5f467f32fb7f..ba2879b25e59290ab81501458414a417 + if (depth > ScissorsConfig.componentDepthLimit) { + throw new JsonParseException("Depth limit exceeded"); + } -+ ++ // Scissors end if (jsonelement.isJsonPrimitive()) { return Component.literal(jsonelement.getAsString()); } else { -@@ -266,18 +274,16 @@ public interface Component extends Message, FormattedText, Iterable { - if (!jsonelement.isJsonObject()) { - if (jsonelement.isJsonArray()) { - JsonArray jsonarray = jsonelement.getAsJsonArray(); -- // Scissors start - if (jsonarray.size() <= 0) { - throw new JsonParseException("Unexpected empty array of components"); - } -- // Scissors end - - ichatmutablecomponent = null; - Iterator iterator = jsonarray.iterator(); +@@ -273,7 +281,7 @@ public interface Component extends Message, FormattedText, Iterable { while (iterator.hasNext()) { JsonElement jsonelement1 = (JsonElement) iterator.next(); - MutableComponent ichatmutablecomponent1 = this.deserialize(jsonelement1, jsonelement1.getClass(), jsondeserializationcontext); -+ MutableComponent ichatmutablecomponent1 = this.deserialize(jsonelement1, jsondeserializationcontext, depth + 1); ++ MutableComponent ichatmutablecomponent1 = this.deserialize(jsonelement1, jsondeserializationcontext, depth + 1); // Scissors if (ichatmutablecomponent == null) { ichatmutablecomponent = ichatmutablecomponent1; -@@ -301,12 +307,17 @@ public interface Component extends Message, FormattedText, Iterable { +@@ -297,12 +305,17 @@ public interface Component extends Message, FormattedText, Iterable { s = GsonHelper.getAsString(jsonobject, "translate"); String s1 = GsonHelper.getAsString(jsonobject, "fallback", (String) null); -+ // Penalize depth for placeholders in translate & fallback ++ // Scissors start - Penalize depth for placeholders in translate & fallback + long translate_placeholders = PLACEHOLDER_PATTERN.matcher(s).results().count(); + long fallback_placeholders = s1 != null ? PLACEHOLDER_PATTERN.matcher(s1).results().count() : 0; + int penalty = (int)Math.max(translate_placeholders, fallback_placeholders) * 12; -+ ++ // Scissors end if (jsonobject.has("with")) { JsonArray jsonarray1 = GsonHelper.getAsJsonArray(jsonobject, "with"); Object[] aobject = new Object[jsonarray1.size()]; for (int i = 0; i < aobject.length; ++i) { - aobject[i] = Serializer.unwrapTextArgument(this.deserialize(jsonarray1.get(i), type, jsondeserializationcontext)); -+ aobject[i] = Serializer.unwrapTextArgument(this.deserialize(jsonarray1.get(i), jsondeserializationcontext, depth + 1 + penalty)); ++ aobject[i] = Serializer.unwrapTextArgument(this.deserialize(jsonarray1.get(i), jsondeserializationcontext, depth + 1 + penalty)); // Scissors } ichatmutablecomponent = Component.translatableWithFallback(s, s1, aobject); -@@ -322,7 +333,7 @@ public interface Component extends Message, FormattedText, Iterable { +@@ -318,7 +331,7 @@ public interface Component extends Message, FormattedText, Iterable { ichatmutablecomponent = Component.score(GsonHelper.getAsString(jsonobject1, "name"), GsonHelper.getAsString(jsonobject1, "objective")); } else if (jsonobject.has("selector")) { - Optional optional = this.parseSeparator(type, jsondeserializationcontext, jsonobject); -+ Optional optional = this.parseSeparator(jsondeserializationcontext, jsonobject, depth + 1); ++ Optional optional = this.parseSeparator(jsondeserializationcontext, jsonobject, depth + 1); // Scissors ichatmutablecomponent = Component.selector(GsonHelper.getAsString(jsonobject, "selector"), optional); } else if (jsonobject.has("keybind")) { -@@ -333,7 +344,7 @@ public interface Component extends Message, FormattedText, Iterable { +@@ -329,7 +342,7 @@ public interface Component extends Message, FormattedText, Iterable { } s = GsonHelper.getAsString(jsonobject, "nbt"); - Optional optional1 = this.parseSeparator(type, jsondeserializationcontext, jsonobject); -+ Optional optional1 = this.parseSeparator(jsondeserializationcontext, jsonobject, depth + 1); ++ Optional optional1 = this.parseSeparator(jsondeserializationcontext, jsonobject, depth + 1); // Scissors boolean flag = GsonHelper.getAsBoolean(jsonobject, "interpret", false); Object object; -@@ -360,7 +371,7 @@ public interface Component extends Message, FormattedText, Iterable { +@@ -356,7 +369,7 @@ public interface Component extends Message, FormattedText, Iterable { } for (int j = 0; j < jsonarray2.size(); ++j) { - ichatmutablecomponent.append((Component) this.deserialize(jsonarray2.get(j), type, jsondeserializationcontext)); -+ ichatmutablecomponent.append((Component) this.deserialize(jsonarray2.get(j), jsondeserializationcontext, depth + 1)); ++ ichatmutablecomponent.append((Component) this.deserialize(jsonarray2.get(j), jsondeserializationcontext, depth + 1)); // Scissors } } -@@ -370,6 +381,11 @@ public interface Component extends Message, FormattedText, Iterable { +@@ -366,6 +379,12 @@ public interface Component extends Message, FormattedText, Iterable { } } ++ // Scissors start + public MutableComponent deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException { + return this.deserialize(jsonelement, jsondeserializationcontext, 1); + } @@ -148,7 +110,7 @@ index 9c2c22ee548ad77f0912698f33de5f467f32fb7f..ba2879b25e59290ab81501458414a417 private static Object unwrapTextArgument(Object text) { if (text instanceof Component) { Component ichatbasecomponent = (Component) text; -@@ -388,8 +404,10 @@ public interface Component extends Message, FormattedText, Iterable { +@@ -384,8 +403,10 @@ public interface Component extends Message, FormattedText, Iterable { return text; } diff --git a/patches/server/0049-Implement-command-block-events.patch b/patches/server/0044-Implement-command-block-events.patch similarity index 53% rename from patches/server/0049-Implement-command-block-events.patch rename to patches/server/0044-Implement-command-block-events.patch index fd6708e..4e6fbfd 100644 --- a/patches/server/0049-Implement-command-block-events.patch +++ b/patches/server/0044-Implement-command-block-events.patch @@ -4,83 +4,83 @@ Date: Fri, 2 Jun 2023 20:55:18 +0100 Subject: [PATCH] Implement command block events +diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCommandMinecartPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCommandMinecartPacket.java +index c99fc118013cb3d4043638e2001a8297e79ddf9c..cdaa81e1f2167b29ec01cc25e51a8400deb533d2 100644 +--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCommandMinecartPacket.java ++++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCommandMinecartPacket.java +@@ -9,7 +9,7 @@ import net.minecraft.world.level.BaseCommandBlock; + import net.minecraft.world.level.Level; + + public class ServerboundSetCommandMinecartPacket implements Packet { +- private final int entity; ++ public final int entity; // Scissors - private -> public + private final String command; + private final boolean trackOutput; + diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 2549ff41d1d63ba0dbdaee3e526a44f953945b6d..2748949301ce9b2c3b098dd2a7d2caee331980a7 100644 +index 8274514733caf0fb3c3db5836a3ab9bd204c4378..ca6b809f56cf4d28d5a6514c18322419c8184f30 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -1,6 +1,8 @@ package net.minecraft.server.network; - import me.totalfreedom.scissors.ScissorsConfig; -+import me.totalfreedom.scissors.event.block.CommandBlockPlayerEditEvent; -+import me.totalfreedom.scissors.event.block.CommandMinecartPlayerEditEvent; - import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; + import me.totalfreedom.scissors.ScissorsConfig; // Scissors ++import me.totalfreedom.scissors.event.block.CommandBlockPlayerEditEvent; // Scissors ++import me.totalfreedom.scissors.event.block.CommandMinecartPlayerEditEvent; // Scissors + import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors import com.google.common.collect.Lists; import com.google.common.primitives.Floats; -@@ -160,6 +162,7 @@ import net.minecraft.world.entity.player.Inventory; +@@ -159,6 +161,7 @@ import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.ProfilePublicKey; import net.minecraft.world.entity.projectile.AbstractArrow; import net.minecraft.world.entity.vehicle.Boat; -+import net.minecraft.world.entity.vehicle.MinecartCommandBlock; ++import net.minecraft.world.entity.vehicle.MinecartCommandBlock; // Scissors import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.BucketItem; import net.minecraft.world.item.Item; -@@ -188,6 +191,7 @@ import net.minecraft.world.phys.Vec3; +@@ -187,6 +190,8 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.BooleanOp; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; -+import org.bukkit.entity.minecart.CommandMinecart; ++import org.bukkit.craftbukkit.block.CraftCommandBlock; // Scissors ++import org.bukkit.craftbukkit.entity.CraftMinecartCommand; // Scissors import org.slf4j.Logger; // CraftBukkit start -@@ -994,6 +998,21 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -993,6 +998,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic this.player.level.getChunkAt(blockposition).setBlockEntity(tileentity); } -+ // Scissors start - Implement command block events -+ if (commandblocklistenerabstract instanceof org.bukkit.block.CommandBlock commandBlock) -+ { -+ CommandBlockPlayerEditEvent event = new CommandBlockPlayerEditEvent(this.getCraftPlayer(), Objects.requireNonNullElse(commandblocklistenerabstract.getCommand(), ""), s, commandBlock); -+ event.callEvent(); ++ // Scissors start ++ CommandBlockPlayerEditEvent event = new CommandBlockPlayerEditEvent(this.getCraftPlayer(), commandblocklistenerabstract.getCommand(), s, new CraftCommandBlock(this.player.level.getWorld(), tileentitycommand)); + -+ if (event.isCancelled()) { -+ return; -+ } -+ -+ s = event.getNewCommand(); ++ if (!event.callEvent()) { ++ return; + } + ++ s = event.getNewCommand(); + // Scissors end + commandblocklistenerabstract.setCommand(s); commandblocklistenerabstract.setTrackOutput(flag); if (!flag) { -@@ -1025,7 +1044,27 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1024,7 +1039,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic BaseCommandBlock commandblocklistenerabstract = packet.getCommandBlock(this.player.level); if (commandblocklistenerabstract != null) { - commandblocklistenerabstract.setCommand(packet.getCommand()); + // Scissors start - Implement command block events + String command = packet.getCommand(); ++ CommandMinecartPlayerEditEvent event = new CommandMinecartPlayerEditEvent(this.getCraftPlayer(), commandblocklistenerabstract.getCommand(), command, new CraftMinecartCommand(this.cserver, (MinecartCommandBlock) this.player.level.getEntity(packet.entity))); + -+ if (commandblocklistenerabstract instanceof CommandMinecart commandMinecart) -+ { -+ CommandMinecartPlayerEditEvent event = new CommandMinecartPlayerEditEvent(this.getCraftPlayer(), Objects.requireNonNullElse(commandblocklistenerabstract.getCommand(), ""), command, commandMinecart); -+ event.callEvent(); -+ -+ if (event.isCancelled()) { -+ return; -+ } -+ -+ command = event.getNewCommand(); ++ if (!event.callEvent()) { ++ return; + } + ++ command = event.getNewCommand(); + commandblocklistenerabstract.setCommand(command); + -+ // commandblocklistenerabstract.setCommand(packet.getCommand()); -+ + // Scissors end -+ commandblocklistenerabstract.setTrackOutput(packet.isTrackOutput()); if (!packet.isTrackOutput()) { commandblocklistenerabstract.setLastOutput((Component) null); diff --git a/patches/server/0048-Add-depth-limit-to-SNBT.patch b/patches/server/0045-Add-depth-limit-to-SNBT.patch similarity index 85% rename from patches/server/0048-Add-depth-limit-to-SNBT.patch rename to patches/server/0045-Add-depth-limit-to-SNBT.patch index e5510ce..c1c4d8f 100644 --- a/patches/server/0048-Add-depth-limit-to-SNBT.patch +++ b/patches/server/0045-Add-depth-limit-to-SNBT.patch @@ -5,18 +5,16 @@ Subject: [PATCH] Add depth limit to SNBT diff --git a/src/main/java/net/minecraft/nbt/TagParser.java b/src/main/java/net/minecraft/nbt/TagParser.java -index fbfe810e8be6cb159742f7fd85e7491b9cefa4dc..82b1d851e310504e7373a967dfb5b0b096d36693 100644 +index fbfe810e8be6cb159742f7fd85e7491b9cefa4dc..426425e38698b06d46c5e6a41b39d362176a4ee3 100644 --- a/src/main/java/net/minecraft/nbt/TagParser.java +++ b/src/main/java/net/minecraft/nbt/TagParser.java -@@ -169,8 +169,58 @@ public class TagParser { +@@ -169,8 +169,56 @@ public class TagParser { } this.expect('}'); - return compoundTag; + -+ // Scissors start - Add depth limit to SNBT -+ return exceedsDepthLimit(compoundTag) ? new CompoundTag() : compoundTag; -+ // Scissors end ++ return exceedsDepthLimit(compoundTag) ? new CompoundTag() : compoundTag; // Scissors - Add depth limit to SNBT + } + + // Scissors start - Add depth limit to SNBT @@ -68,20 +66,16 @@ index fbfe810e8be6cb159742f7fd85e7491b9cefa4dc..82b1d851e310504e7373a967dfb5b0b0 private Tag readListTag() throws CommandSyntaxException { this.expect('['); -@@ -203,7 +253,11 @@ public class TagParser { +@@ -203,7 +251,7 @@ public class TagParser { } this.expect(']'); - return listTag; -+ -+ // Scissors start - Add depth limit to SNBT -+ return exceedsDepthLimit(listTag) ? new ListTag() : listTag; -+ // return listTag; -+ // Scissors end ++ return exceedsDepthLimit(listTag) ? new ListTag() : listTag; // Scissors - Add depth limit to SNBT } } -@@ -228,7 +282,7 @@ public class TagParser { +@@ -228,7 +276,7 @@ public class TagParser { } private List readArray(TagType arrayTypeReader, TagType typeReader) throws CommandSyntaxException { @@ -90,7 +84,7 @@ index fbfe810e8be6cb159742f7fd85e7491b9cefa4dc..82b1d851e310504e7373a967dfb5b0b0 while(true) { if (this.reader.peek() != ']') { -@@ -241,11 +295,11 @@ public class TagParser { +@@ -241,11 +289,11 @@ public class TagParser { } if (typeReader == ByteTag.TYPE) { @@ -105,7 +99,7 @@ index fbfe810e8be6cb159742f7fd85e7491b9cefa4dc..82b1d851e310504e7373a967dfb5b0b0 } if (this.hasElementSeparator()) { -@@ -257,7 +311,7 @@ public class TagParser { +@@ -257,7 +305,7 @@ public class TagParser { } this.expect(']'); diff --git a/patches/server/0045-Make-excluding-players-from-nbt-components-configura.patch b/patches/server/0045-Make-excluding-players-from-nbt-components-configura.patch deleted file mode 100644 index 427a4f3..0000000 --- a/patches/server/0045-Make-excluding-players-from-nbt-components-configura.patch +++ /dev/null @@ -1,58 +0,0 @@ -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 9f2a51fddb692f5152c32dcbe1f5a6ba150634e4..39b56ca496ed7369ead21805d476c2b813fcdd1d 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(); - } diff --git a/patches/server/0050-Limit-beacon-effectRange.patch b/patches/server/0046-Limit-beacon-effectRange.patch similarity index 92% rename from patches/server/0050-Limit-beacon-effectRange.patch rename to patches/server/0046-Limit-beacon-effectRange.patch index 1dd041e..9525f4f 100644 --- a/patches/server/0050-Limit-beacon-effectRange.patch +++ b/patches/server/0046-Limit-beacon-effectRange.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Limit beacon effectRange diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -index f2325c0c475bb465f5275f78c71949648a860d0c..4ec228ce026ee39eebd17d180fb5caea1b74e6e2 100644 +index ef740d1ad6352ca4af299001a081b720bc472d2e..63c569e05a86a590021ae6828918e5c5fce7b637 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java @@ -83,7 +83,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name diff --git a/patches/server/0047-Improve-validation-of-ResourceLocations.patch b/patches/server/0047-Improve-validation-of-ResourceLocations.patch new file mode 100644 index 0000000..3f0f967 --- /dev/null +++ b/patches/server/0047-Improve-validation-of-ResourceLocations.patch @@ -0,0 +1,18 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Luna +Date: Tue, 13 Jun 2023 18:29:18 -0300 +Subject: [PATCH] Improve validation of ResourceLocations + + +diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java b/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java +index 5014192edb9616ce725fc1592832034789527b6f..64da1b0afd51720803aba0d9e86d0b1743bdb0da 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java +@@ -21,6 +21,7 @@ public final class CraftNamespacedKey { + } + + public static NamespacedKey fromMinecraft(ResourceLocation minecraft) { ++ if (minecraft == null) throw new IllegalArgumentException("Null ResourceLocation provided"); // Scissors + return new NamespacedKey(minecraft.getNamespace(), minecraft.getPath()); + } + diff --git a/patches/server/0048-Don-t-log-on-too-many-chained-updates.patch b/patches/server/0048-Don-t-log-on-too-many-chained-updates.patch new file mode 100644 index 0000000..ed67349 --- /dev/null +++ b/patches/server/0048-Don-t-log-on-too-many-chained-updates.patch @@ -0,0 +1,19 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Luna +Date: Sat, 1 Jul 2023 21:22:29 -0300 +Subject: [PATCH] Don't log on too many chained updates + + +diff --git a/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java b/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java +index b1c594dc6a6b8a6c737b99272acab9e7dbd0ed63..1cc2e5a82652838b29a2e935d4284e5cc134724e 100644 +--- a/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java ++++ b/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java +@@ -56,7 +56,7 @@ public class CollectingNeighborUpdater implements NeighborUpdater { + this.stack.push(entry); + } + } else if (this.count - 1 == this.maxChainedNeighborUpdates) { +- LOGGER.error("Too many chained neighbor updates. Skipping the rest. First skipped position: " + pos.toShortString()); ++ // Scissors - don't log + } + + if (!bl) {