Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-20 06:50:08 +01:00
Fixup ComponentUtil#trimStrings detection (#3888)
Dieser Commit ist enthalten in:
Ursprung
d8aa3c4b39
Commit
af393c564f
@ -23,6 +23,7 @@ import com.viaversion.nbt.tag.CompoundTag;
|
|||||||
import com.viaversion.nbt.tag.StringTag;
|
import com.viaversion.nbt.tag.StringTag;
|
||||||
import com.viaversion.nbt.tag.Tag;
|
import com.viaversion.nbt.tag.Tag;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import net.lenni0451.mcstructs.text.ATextComponent;
|
import net.lenni0451.mcstructs.text.ATextComponent;
|
||||||
import net.lenni0451.mcstructs.text.Style;
|
import net.lenni0451.mcstructs.text.Style;
|
||||||
@ -38,6 +39,8 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
*/
|
*/
|
||||||
public final class ComponentUtil {
|
public final class ComponentUtil {
|
||||||
|
|
||||||
|
private static final int MAX_UNSIGNED_SHORT = 65535;
|
||||||
|
|
||||||
public static JsonObject emptyJsonComponent() {
|
public static JsonObject emptyJsonComponent() {
|
||||||
return plainToJson("");
|
return plainToJson("");
|
||||||
}
|
}
|
||||||
@ -83,10 +86,10 @@ public final class ComponentUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return TagUtil.handleDeep(input, (key, tag) -> {
|
return TagUtil.handleDeep(input, (key, tag) -> {
|
||||||
if (tag instanceof StringTag) {
|
if (tag instanceof StringTag stringTag) {
|
||||||
final String value = ((StringTag) tag).getValue();
|
final byte[] value = stringTag.getValue().getBytes(StandardCharsets.UTF_8);
|
||||||
if (value.length() > Short.MAX_VALUE) {
|
if (value.length > MAX_UNSIGNED_SHORT) {
|
||||||
((StringTag) tag).setValue("{}");
|
stringTag.setValue("{}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tag;
|
return tag;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren