mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
NoChatReports Implementation
This commit is contained in:
@@ -8,3 +8,5 @@
|
||||
# To import classes from the vanilla Minecraft jar use `minecraft` as the artifactId:
|
||||
# minecraft net.minecraft.world.level.entity.LevelEntityGetterAdapter
|
||||
# minecraft net/minecraft/world/level/entity/LevelEntityGetter.java
|
||||
|
||||
minecraft net.minecraft.network.protocol.status.ServerStatus.java
|
||||
173
patches/server/0051-NoChatReports-Implementation.patch
Normal file
173
patches/server/0051-NoChatReports-Implementation.patch
Normal file
@@ -0,0 +1,173 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sun, 19 Mar 2023 19:07:20 +0300
|
||||
Subject: [PATCH] NoChatReports Implementation
|
||||
|
||||
|
||||
diff --git a/src/main/java/gq/bxteam/divinemc/DivineConfig.java b/src/main/java/gq/bxteam/divinemc/DivineConfig.java
|
||||
index 541acfc832fe4caa13b5fb46bc455fc6a7294af8..8749af60221b53efa9f4bce43bbdad166a3f4506 100644
|
||||
--- a/src/main/java/gq/bxteam/divinemc/DivineConfig.java
|
||||
+++ b/src/main/java/gq/bxteam/divinemc/DivineConfig.java
|
||||
@@ -131,4 +131,14 @@ public class DivineConfig {
|
||||
return config.getStringList(key);
|
||||
}
|
||||
|
||||
+ public static boolean noChatReportsEnable = true;
|
||||
+ public static boolean noChatReportsConvertToGameMessage = true;
|
||||
+ public static boolean noChatReportsAddQueryData = true;
|
||||
+
|
||||
+ private static void noChatReportsConfig() {
|
||||
+ setComment("no-chat-reports", "[ No Chat Reports ] Player Chat Reporting Control Mod");
|
||||
+ noChatReportsEnable = getBoolean("no-chat-reports.enable", noChatReportsEnable);
|
||||
+ noChatReportsConvertToGameMessage = getBoolean("no-chat-reports.convert-to-game-message", noChatReportsConvertToGameMessage) && noChatReportsEnable;
|
||||
+ noChatReportsAddQueryData = getBoolean("no-chat-reports.add-query-data", noChatReportsAddQueryData) && noChatReportsEnable;
|
||||
+ }
|
||||
}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/status/ServerStatus.java b/src/main/java/net/minecraft/network/protocol/status/ServerStatus.java
|
||||
index 6e0a3086da142f1c42007a16bbec7edbab17da04..60ad75fdf0c43a19cdfaf73fd07ad0a8b4d0da96 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/status/ServerStatus.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/status/ServerStatus.java
|
||||
@@ -28,6 +28,14 @@ public class ServerStatus {
|
||||
private String favicon;
|
||||
private boolean enforcesSecureChat;
|
||||
|
||||
+ // DivineMC start - NoChatReports
|
||||
+ /**
|
||||
+ * Special additional variable that allows the client to know whether server prevents chat reports
|
||||
+ * upon pinging it.
|
||||
+ */
|
||||
+ private boolean preventsChatReports;
|
||||
+ // DivineMC end
|
||||
+
|
||||
@Nullable
|
||||
public Component getDescription() {
|
||||
return this.description;
|
||||
@@ -68,9 +76,23 @@ public class ServerStatus {
|
||||
this.enforcesSecureChat = secureChatEnforced;
|
||||
}
|
||||
|
||||
+ // DivineMC start - NoChatReports
|
||||
public boolean enforcesSecureChat() {
|
||||
- return this.enforcesSecureChat;
|
||||
+ return gq.bxteam.divinemc.DivineConfig.noChatReportsConvertToGameMessage ? true : this.enforcesSecureChat;
|
||||
+ }
|
||||
+
|
||||
+ public boolean preventsChatReports() {
|
||||
+ if (this.getVersion() != null && this.getVersion().getProtocol() < 759
|
||||
+ && this.getVersion().getProtocol() > 0)
|
||||
+ return true;
|
||||
+
|
||||
+ return this.preventsChatReports;
|
||||
+ }
|
||||
+
|
||||
+ public void setPreventsChatReports(boolean prevents) {
|
||||
+ this.preventsChatReports = prevents;
|
||||
}
|
||||
+ // DivineMC end
|
||||
|
||||
public static class Players {
|
||||
private final int maxPlayers;
|
||||
@@ -173,6 +195,12 @@ public class ServerStatus {
|
||||
serverStatus.setEnforcesSecureChat(GsonHelper.getAsBoolean(jsonObject, "enforcesSecureChat"));
|
||||
}
|
||||
|
||||
+ // DivineMC start - NoChatReports
|
||||
+ if (jsonObject.has("preventsChatReports")) {
|
||||
+ serverStatus.setPreventsChatReports(GsonHelper.getAsBoolean(jsonObject, "preventsChatReports"));
|
||||
+ }
|
||||
+ // DivineMC end
|
||||
+
|
||||
return serverStatus;
|
||||
}
|
||||
|
||||
@@ -196,6 +224,12 @@ public class ServerStatus {
|
||||
jsonObject.addProperty("favicon", serverStatus.getFavicon());
|
||||
}
|
||||
|
||||
+ // DivineMC start - NoChatReports
|
||||
+ if (gq.bxteam.divinemc.DivineConfig.noChatReportsAddQueryData) {
|
||||
+ jsonObject.addProperty("preventsChatReports", true);
|
||||
+ }
|
||||
+ // DivineMC end
|
||||
+
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 40f11933defbac1a5d4494e643b19af20e5997f1..fc37cbaaf0dc5994ae8e3f7fd5dd087db4e5212c 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -19,6 +19,8 @@ import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import gq.bxteam.divinemc.DivineConfig;
|
||||
import net.minecraft.DefaultUncaughtExceptionHandler;
|
||||
import net.minecraft.DefaultUncaughtExceptionHandlerWithName;
|
||||
import net.minecraft.SharedConstants;
|
||||
@@ -642,7 +644,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
|
||||
@Override
|
||||
public boolean enforceSecureProfile() {
|
||||
- return this.getProperties().enforceSecureProfile && this.getProperties().onlineMode;
|
||||
+ return DivineConfig.noChatReportsEnable ? false : this.getProperties().enforceSecureProfile && this.getProperties().onlineMode;
|
||||
}
|
||||
|
||||
protected boolean convertOldUsers() {
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 2ca19bbe3a71091843fc7175d726c70321d1fee3..83433dc5b9ff683bbb4949e2acfdb14193405a73 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2139,12 +2139,25 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
}
|
||||
}
|
||||
|
||||
+ // DivineMC start - NoChatReports
|
||||
@Override
|
||||
public void send(Packet<?> packet) {
|
||||
+ if (gq.bxteam.divinemc.DivineConfig.noChatReportsConvertToGameMessage) {
|
||||
+ if (packet instanceof net.minecraft.network.protocol.game.ClientboundPlayerChatPacket chat) {
|
||||
+ packet = new net.minecraft.network.protocol.game.ClientboundSystemChatPacket(chat.chatType().resolve(this.player.level.registryAccess()).get().decorate(chat.unsignedContent() != null ? chat.unsignedContent()
|
||||
+ : Component.literal(chat.body().content())), false);
|
||||
+ }
|
||||
+ }
|
||||
this.send(packet, (PacketSendListener) null);
|
||||
}
|
||||
|
||||
public void send(Packet<?> packet, @Nullable PacketSendListener callbacks) {
|
||||
+ if (gq.bxteam.divinemc.DivineConfig.noChatReportsConvertToGameMessage) {
|
||||
+ if (packet instanceof net.minecraft.network.protocol.game.ClientboundPlayerChatPacket chat && callbacks != null) {
|
||||
+ this.send(chat);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
// CraftBukkit start
|
||||
if (packet == null || this.processedDisconnect) { // Spigot
|
||||
return;
|
||||
@@ -2166,6 +2179,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
throw new ReportedException(crashreport);
|
||||
}
|
||||
}
|
||||
+ // DivineMC end
|
||||
|
||||
@Override
|
||||
public void handleSetCarriedItem(ServerboundSetCarriedItemPacket packet) {
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 68fb745e74ec4a0c367b0d80d7d437bd3b99a10d..cb2016596c3f519f17a0dc5e7bee0ca0c35471ba 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -1414,9 +1414,11 @@ public abstract class PlayerList {
|
||||
|
||||
}
|
||||
|
||||
+ // DivineMC start - NoChatReports
|
||||
public boolean verifyChatTrusted(PlayerChatMessage message) { // Paper - private -> public
|
||||
- return message.hasSignature() && !message.hasExpiredServer(Instant.now());
|
||||
+ return gq.bxteam.divinemc.DivineConfig.noChatReportsEnable ? true : message.hasSignature() && !message.hasExpiredServer(Instant.now());
|
||||
}
|
||||
+ // DivineMC end
|
||||
|
||||
// CraftBukkit start
|
||||
public ServerStatsCounter getPlayerStats(ServerPlayer entityhuman) {
|
||||
Reference in New Issue
Block a user