Skip to content

Commit ed03388

Browse files
Added an option to disable unverified message banners
1 parent 80d44b2 commit ed03388

File tree

6 files changed

+46
-2
lines changed

6 files changed

+46
-2
lines changed

1.19.1/src/main/java/me/doclic/noencryption/compatibility/CompatiblePacketListener.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.minecraft.network.chat.*;
77
import net.minecraft.network.protocol.game.ClientboundPlayerChatHeaderPacket;
88
import net.minecraft.network.protocol.game.ClientboundPlayerChatPacket;
9+
import net.minecraft.network.protocol.game.ClientboundServerDataPacket;
910
import net.minecraft.network.protocol.game.ClientboundSystemChatPacket;
1011
import org.bukkit.craftbukkit.v1_19_R1.util.CraftChatMessage;
1112

@@ -60,6 +61,16 @@ public Object writePacket(ChannelHandlerContext channelHandlerContext, Object pa
6061
new MessageSignature(new byte[0]),
6162
clientboundPlayerChatHeaderPacket.bodyDigest()
6263
);
64+
} else if (packet instanceof final ClientboundServerDataPacket clientboundServerDataPacket) {
65+
if (ConfigurationHandler.getDisableBanner()) {
66+
// recreate a new packet
67+
return new ClientboundServerDataPacket(
68+
clientboundServerDataPacket.getMotd().get(),
69+
clientboundServerDataPacket.getIconBase64().orElse(""),
70+
clientboundServerDataPacket.previewsChat(),
71+
true
72+
);
73+
}
6374
}
6475

6576
return packet;

1.19.1/src/main/java/me/doclic/noencryption/config/ConfigNodes.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,14 @@ public enum ConfigNodes {
5656
"# Note: Enabling this option may cause chat messages to not be fully stripped, thus showing the red bar, and red exclamation mark",
5757
"# ",
5858
"# Added in v3.1",
59-
"# Default: false");
59+
"# Default: false"),
60+
61+
DISABLE_BANNER(null, "disable_banner", true,
62+
" ",
63+
"# Disabled the modified chats banner on the top right of the client",
64+
"# ",
65+
"# Added in v3.2",
66+
"# Default: true");
6067

6168

6269
private final String Notice;

1.19.1/src/main/java/me/doclic/noencryption/config/ConfigurationHandler.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,8 @@ public static String getLoginProtectionMessage() {
185185
public static boolean getForwardUUID() {
186186
return getBoolean(ConfigNodes.FORWARD_UUID);
187187
}
188+
189+
public static boolean getDisableBanner() {
190+
return getBoolean(ConfigNodes.DISABLE_BANNER);
191+
}
188192
}

1.19.2/src/main/java/me/doclic/noencryption/compatibility/CompatiblePacketListener.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.minecraft.network.chat.*;
77
import net.minecraft.network.protocol.game.ClientboundPlayerChatHeaderPacket;
88
import net.minecraft.network.protocol.game.ClientboundPlayerChatPacket;
9+
import net.minecraft.network.protocol.game.ClientboundServerDataPacket;
910
import net.minecraft.network.protocol.game.ClientboundSystemChatPacket;
1011
import org.bukkit.craftbukkit.v1_19_R1.util.CraftChatMessage;
1112

@@ -60,6 +61,16 @@ public Object writePacket(ChannelHandlerContext channelHandlerContext, Object pa
6061
new MessageSignature(new byte[0]),
6162
clientboundPlayerChatHeaderPacket.bodyDigest()
6263
);
64+
} else if (packet instanceof final ClientboundServerDataPacket clientboundServerDataPacket) {
65+
if (ConfigurationHandler.getDisableBanner()) {
66+
// recreate a new packet
67+
return new ClientboundServerDataPacket(
68+
clientboundServerDataPacket.getMotd().get(),
69+
clientboundServerDataPacket.getIconBase64().orElse(""),
70+
clientboundServerDataPacket.previewsChat(),
71+
true
72+
);
73+
}
6374
}
6475

6576
return packet;

1.19.2/src/main/java/me/doclic/noencryption/config/ConfigNodes.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,14 @@ public enum ConfigNodes {
5656
"# Note: Enabling this option may cause chat messages to not be fully stripped, thus showing the red bar, and red exclamation mark",
5757
"# ",
5858
"# Added in v3.1",
59-
"# Default: false");
59+
"# Default: false"),
60+
61+
DISABLE_BANNER(null, "disable_banner", true,
62+
" ",
63+
"# Disabled the modified chats banner on the top right of the client",
64+
"# ",
65+
"# Added in v3.2",
66+
"# Default: true");
6067

6168

6269
private final String Notice;

1.19.2/src/main/java/me/doclic/noencryption/config/ConfigurationHandler.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,8 @@ public static String getLoginProtectionMessage() {
185185
public static boolean getForwardUUID() {
186186
return getBoolean(ConfigNodes.FORWARD_UUID);
187187
}
188+
189+
public static boolean getDisableBanner() {
190+
return getBoolean(ConfigNodes.DISABLE_BANNER);
191+
}
188192
}

0 commit comments

Comments
 (0)