98 lines
5.0 KiB
Diff
98 lines
5.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MrHua269 <novau233@163.com>
|
|
Date: Sat, 27 Jan 2024 07:55:42 +0000
|
|
Subject: [PATCH] Add config for chat sign
|
|
|
|
|
|
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
|
index a49da370c91211d4e2274f72d62c911a1912296a..8d1ce8eae252fcf05b6a62d2dc467d6d503d3df4 100644
|
|
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
|
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
|
@@ -13,6 +13,7 @@ public class LuminolConfig {
|
|
|
|
public static String serverModName = "Luminol";
|
|
public static boolean fakeVanillaModeEnabled = false;
|
|
+ public static boolean disableChatSign = false;
|
|
|
|
public static boolean safeTeleportation = true;
|
|
public static boolean enableSandDuping = false;
|
|
@@ -36,6 +37,7 @@ public class LuminolConfig {
|
|
public static void initValues(){
|
|
serverModName = get("misc.server_mod_name",serverModName,"The servermod name will be sent to players,and you can see it in F3 or motd responses");
|
|
fakeVanillaModeEnabled = get("misc.enable_fake_vanilla_mode",fakeVanillaModeEnabled,"Enable this to make the ping response of your server like a vanilla server");
|
|
+ disableChatSign = get("misc.disable_chat_sign",disableChatSign,"Set this to true to disable mojang's chat sign");
|
|
|
|
safeTeleportation = get("fixes.enable_safe_teleportation",safeTeleportation,"If this enabled,the end portals will not teleport removed entities.");
|
|
enableSandDuping = get("fixes.enable_sand_duping",enableSandDuping,"If this enabled,The value of safe teleportation will always be false and sand duping will be enabled");
|
|
diff --git a/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java b/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java
|
|
index 72a8aa676836fcb3b4578689d16af65e18f55bbe..04653d58f2493d796e61bc97f0481cb628539c37 100644
|
|
--- a/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java
|
|
+++ b/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java
|
|
@@ -4,6 +4,8 @@ import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import javax.annotation.Nullable;
|
|
+
|
|
+import me.earthme.luminol.LuminolConfig;
|
|
import net.minecraft.network.FriendlyByteBuf;
|
|
import net.minecraft.network.chat.MessageSignature;
|
|
import net.minecraft.network.chat.SignableCommand;
|
|
@@ -14,8 +16,16 @@ public record ArgumentSignatures(List<ArgumentSignatures.Entry> entries) {
|
|
private static final int MAX_ARGUMENT_NAME_LENGTH = 16;
|
|
|
|
public ArgumentSignatures(FriendlyByteBuf buf) {
|
|
- this(buf.readCollection(FriendlyByteBuf.limitValue(ArrayList::new, 8), ArgumentSignatures.Entry::new));
|
|
+ this(readSign(buf));
|
|
+ }
|
|
+
|
|
+ //Luminol start - Add config for chat sign
|
|
+ private static List<ArgumentSignatures.Entry> readSign(FriendlyByteBuf buf) {
|
|
+ var entries = buf.readCollection(FriendlyByteBuf.limitValue(ArrayList::new, 8), Entry::new);
|
|
+ return LuminolConfig.disableChatSign ? List.of() : entries;
|
|
}
|
|
+ //Luminol end
|
|
+
|
|
|
|
@Nullable
|
|
public MessageSignature get(String argumentName) {
|
|
diff --git a/src/main/java/net/minecraft/network/FriendlyByteBuf.java b/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
|
index b863249ff7e13cf4939c8961601f0564c62fd661..4e9bfce4fd188e832c15feedebe4d10b6873b764 100644
|
|
--- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
|
+++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
|
@@ -48,6 +48,8 @@ import java.util.function.Function;
|
|
import java.util.function.IntFunction;
|
|
import java.util.function.ToIntFunction;
|
|
import javax.annotation.Nullable;
|
|
+
|
|
+import me.earthme.luminol.LuminolConfig;
|
|
import net.minecraft.Util;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.core.Direction;
|
|
@@ -83,6 +85,8 @@ import org.joml.Vector3f;
|
|
|
|
import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit
|
|
|
|
+import net.minecraft.network.protocol.status.ServerStatus;
|
|
+
|
|
public class FriendlyByteBuf extends ByteBuf {
|
|
|
|
public static final int DEFAULT_NBT_QUOTA = 2097152;
|
|
@@ -143,6 +147,17 @@ public class FriendlyByteBuf extends ByteBuf {
|
|
// Paper end - Adventure; add max length parameter
|
|
DataResult<JsonElement> dataresult = codec.encodeStart(JsonOps.INSTANCE, value);
|
|
|
|
+
|
|
+ //Luminol start - Add config for chat sign
|
|
+ if (codec == ServerStatus.CODEC) {
|
|
+ JsonElement element = Util.getOrThrow(dataresult, string -> new EncoderException("Failed to encode: " + string + " " + value));
|
|
+ element.getAsJsonObject().addProperty("preventsChatReports", LuminolConfig.disableChatSign);
|
|
+
|
|
+ this.writeUtf(GSON.toJson(element));
|
|
+ return;
|
|
+ }
|
|
+ //Luminol end
|
|
+
|
|
this.writeUtf(FriendlyByteBuf.GSON.toJson((JsonElement) Util.getOrThrow(dataresult, (s) -> {
|
|
return new EncoderException("Failed to encode: " + s + " " + value);
|
|
})), maxLength); // Paper - Adventure; add max length parameter
|