mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-29 11:59:24 +00:00
Originally vanilla logic is to use stream, and Mojang switched it to Guava's Collections2 since 1.21.4. It is much faster than using stream or manually adding to a new ArrayList. Manually adding to a new ArrayList requires allocating a new object array. However, the Collections2 lazy handles filter condition on iteration, so much better.
30 lines
2.0 KiB
Diff
30 lines
2.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
|
Date: Sun, 15 Jun 2025 02:20:26 +0800
|
|
Subject: [PATCH] Fix crash during parsing unknown command message
|
|
|
|
Use direct impl for unknown commands message parse to prevent crash
|
|
|
|
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
|
index 32a9d6e9b18ac1cf66c12462221ebb53f86eac3e..5f80c7b06411e0ad9b0f71f03bb4568daea3ea4d 100644
|
|
--- a/net/minecraft/commands/Commands.java
|
|
+++ b/net/minecraft/commands/Commands.java
|
|
@@ -660,7 +660,7 @@ public class Commands {
|
|
net.kyori.adventure.text.Component detailComponent = null;
|
|
|
|
if (rawMessage.contains("<message>")) {
|
|
- messageComponent = io.papermc.paper.command.brigadier.MessageComponentSerializer.message().deserialize(commandSyntaxException.getRawMessage());
|
|
+ messageComponent = io.papermc.paper.adventure.PaperAdventure.asAdventure(ComponentUtils.fromMessage(commandSyntaxException.getRawMessage())); // Leaf - Fix crash during parsing unknown command message
|
|
}
|
|
|
|
final String input = commandSyntaxException.getInput();
|
|
@@ -703,7 +703,7 @@ public class Commands {
|
|
private static net.kyori.adventure.text.Component getVanillaUnknownCommandMessage(
|
|
net.kyori.adventure.text.TextComponent.Builder builder, CommandSyntaxException var7, String command
|
|
) {
|
|
- builder.color(net.kyori.adventure.text.format.NamedTextColor.RED).append(io.papermc.paper.command.brigadier.MessageComponentSerializer.message().deserialize(var7.getRawMessage()));
|
|
+ builder.color(net.kyori.adventure.text.format.NamedTextColor.RED).append(io.papermc.paper.adventure.PaperAdventure.asAdventure(ComponentUtils.fromMessage(var7.getRawMessage()))); // Leaf - Fix crash during parsing unknown command message
|
|
|
|
if (var7.getInput() != null && var7.getCursor() >= 0) {
|
|
int min = Math.min(var7.getInput().length(), var7.getCursor());
|