mirror of
https://github.com/BX-Team/DivineMC.git
synced 2026-01-04 15:31:43 +00:00
add recipe manager and chat message signatures
This commit is contained in:
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
@@ -4,8 +4,8 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
version: '1.20.4'
|
||||
branch: 'ver/1.20.4'
|
||||
version: '1.20.6'
|
||||
branch: 'ver/1.20.6'
|
||||
debug: 'false'
|
||||
|
||||
jobs:
|
||||
@@ -23,7 +23,7 @@ jobs:
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 17
|
||||
java-version: 21
|
||||
cache: 'gradle'
|
||||
|
||||
- name: Configure Git and Gradle
|
||||
|
||||
@@ -36,9 +36,9 @@ Global settings affect all worlds on the server as well as the core server funct
|
||||
- **description**: Sets whether the server should dump all configuration values to the server log on startup (this maybe not working)
|
||||
|
||||
### settings
|
||||
- #### disable-chat-reports
|
||||
- **default**: false
|
||||
- **description**: Disables chat signing, which was introduced in version 1.19.1 (similar to No Chat Reports mod)
|
||||
- #### chat-message-signatures
|
||||
- **default**: true
|
||||
- **description**: Whether enable chat message signature, disable will prevent players to report chat messages (similar to No Chat Reports mod)
|
||||
- #### async-pathfinding
|
||||
- ##### enable
|
||||
- **default**: true
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sun, 12 May 2024 18:12:53 +0300
|
||||
Subject: [PATCH] Carpet-Fixes: RecipeManager Optimize
|
||||
|
||||
Original project: https://github.com/fxmorin/carpet-fixes
|
||||
Improves: [Blast]Furnace/Campfire/Smoker/Stonecutter/Crafting/Sheep Color Choosing
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
index a31326e24cb68472c81cd781c5e3041772712862..8bb9c2c070717364a842e682ea6b87074157cf6d 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
@@ -21,6 +21,7 @@ import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
+import java.util.ArrayList;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.NonNullList;
|
||||
@@ -105,7 +106,7 @@ public class RecipeManager extends SimpleJsonResourceReloadListener {
|
||||
List<RecipeHolder<T>> list = this.byType(type).stream().filter((recipeholder) -> {
|
||||
return recipeholder.value().matches(inventory, world);
|
||||
}).toList();
|
||||
- Optional<RecipeHolder<T>> recipe = (list.isEmpty()) ? Optional.empty() : Optional.of(list.getLast()); // CraftBukkit - SPIGOT-4638: last recipe gets priority
|
||||
+ Optional<RecipeHolder<T>> recipe = (list.isEmpty()) ? Optional.empty() : Optional.of(list.get(list.size() - 1)); // CraftBukkit - SPIGOT-4638: last recipe gets priority
|
||||
inventory.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found
|
||||
return recipe;
|
||||
// CraftBukkit end
|
||||
@@ -125,14 +126,14 @@ public class RecipeManager extends SimpleJsonResourceReloadListener {
|
||||
List<RecipeHolder<T>> list = this.byType(type).stream().filter((recipeholder1) -> {
|
||||
return recipeholder1.value().matches(inventory, world);
|
||||
}).toList();
|
||||
- Optional<RecipeHolder<T>> recipe = (list.isEmpty()) ? Optional.empty() : Optional.of(list.getLast()); // CraftBukkit - SPIGOT-4638: last recipe gets priority
|
||||
+ Optional<RecipeHolder<T>> recipe = (list.isEmpty()) ? Optional.empty() : Optional.of(list.get(list.size() - 1)); // CraftBukkit - SPIGOT-4638: last recipe gets priority
|
||||
inventory.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found
|
||||
return recipe;
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
public <C extends Container, T extends Recipe<C>> List<RecipeHolder<T>> getAllRecipesFor(RecipeType<T> type) {
|
||||
- return List.copyOf(this.byType(type));
|
||||
+ return space.bxteam.divinemc.configuration.DivineConfig.recipeManagerOptimization ? new ArrayList<>(this.byType(type)) : List.copyOf(this.byType(type)); // DivineMC - Carpet-Fixes: RecipeManager Optimize
|
||||
}
|
||||
|
||||
public <C extends Container, T extends Recipe<C>> List<RecipeHolder<T>> getRecipesFor(RecipeType<T> type, C inventory, Level world) {
|
||||
diff --git a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
|
||||
index bf550fa360f69b714ac346333c78d7f8de2a71b9..9ae6daeb94232c2f8c5e8f9cc3a2df2f89cd4ed3 100644
|
||||
--- a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
|
||||
+++ b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
|
||||
@@ -155,8 +155,10 @@ public class DivineConfig {
|
||||
|
||||
public static boolean biomeManagerOptimization = true;
|
||||
public static boolean sheepOptimization = true;
|
||||
+ public static boolean recipeManagerOptimization = true;
|
||||
private static void optimizations() {
|
||||
biomeManagerOptimization = getBoolean("settings.optimizations.biome-manager-optimization", biomeManagerOptimization);
|
||||
sheepOptimization = getBoolean("settings.optimizations.sheep-optimization", sheepOptimization);
|
||||
+ recipeManagerOptimization = getBoolean("settings.optimizations.recipe-manager-optimization", recipeManagerOptimization);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sat, 11 May 2024 03:54:59 +0300
|
||||
Subject: [PATCH] Fix chat signing
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||||
index 300929a406905f5ff1ede664d5b99fb0938d4d2e..0dd426f37cca522934f2d0fa8d9fd6df2442c31d 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||||
@@ -50,18 +50,7 @@ public class SignedMessageChain {
|
||||
throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.OUT_OF_ORDER_CHAT, org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT); // Paper - kick event causes
|
||||
} else {
|
||||
SignedMessageChain.this.lastTimeStamp = body.timeStamp();
|
||||
- PlayerChatMessage playerChatMessage = new PlayerChatMessage(signedMessageLink, signature, body, null, FilterMask.PASS_THROUGH);
|
||||
- if (!playerChatMessage.verify(signatureValidator)) {
|
||||
- this.setChainBroken();
|
||||
- throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.INVALID_SIGNATURE);
|
||||
- } else {
|
||||
- if (playerChatMessage.hasExpiredServer(Instant.now())) {
|
||||
- SignedMessageChain.LOGGER.warn("Received expired chat: '{}'. Is the client/server system time unsynchronized?", body.content());
|
||||
- }
|
||||
-
|
||||
- SignedMessageChain.this.nextLink = signedMessageLink.advance();
|
||||
- return playerChatMessage;
|
||||
- }
|
||||
+ return new PlayerChatMessage(signedMessageLink, signature, body, null, FilterMask.PASS_THROUGH); // DivineMC - Fix chat signing
|
||||
}
|
||||
}
|
||||
}
|
||||
145
patches/server/0034-Configurable-Chat-message-signatures.patch
Normal file
145
patches/server/0034-Configurable-Chat-message-signatures.patch
Normal file
@@ -0,0 +1,145 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sun, 12 May 2024 19:49:57 +0300
|
||||
Subject: [PATCH] Configurable Chat message signatures
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
|
||||
index e83f9517b31c5171b8dc75ab63a5bfe654221c84..8883b8bbbd6cf43475d005e1a91acd9afccda92f 100644
|
||||
--- a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
|
||||
+++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
|
||||
@@ -317,7 +317,7 @@ public final class ChatProcessor {
|
||||
|
||||
private void sendToServer(final ChatType.Bound chatType, final @Nullable Function<Audience, net.minecraft.network.chat.Component> msgFunction) {
|
||||
final PlayerChatMessage toConsoleMessage = msgFunction == null ? ChatProcessor.this.message : ChatProcessor.this.message.withUnsignedContent(msgFunction.apply(ChatProcessor.this.server.console));
|
||||
- ChatProcessor.this.server.logChatMessage(toConsoleMessage.decoratedContent(), chatType, ChatProcessor.this.server.getPlayerList().verifyChatTrusted(toConsoleMessage) ? null : "Not Secure");
|
||||
+ ChatProcessor.this.server.logChatMessage(toConsoleMessage.decoratedContent(), chatType, ChatProcessor.this.server.getPlayerList().verifyChatTrusted(toConsoleMessage) ? null : (space.bxteam.divinemc.configuration.DivineConfig.chatMessageSignatures ? null : "Not Secure")); // DivineMC - Configurable Chat message signatures
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java
|
||||
index 07df3299f1d1aa5506e1f6f146347d53e0278d9c..2563cf1f1d92b294f65d4ba26fedbdb5eea57164 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java
|
||||
@@ -23,7 +23,7 @@ public record ServerboundChatPacket(String message, Instant timeStamp, long salt
|
||||
buf.writeUtf(this.message, 256);
|
||||
buf.writeInstant(this.timeStamp);
|
||||
buf.writeLong(this.salt);
|
||||
- buf.writeNullable(this.signature, MessageSignature::write);
|
||||
+ if (!space.bxteam.divinemc.configuration.DivineConfig.chatMessageSignatures) buf.writeNullable(this.signature, MessageSignature::write); // DivineMC - Configurable Chat message signatures
|
||||
this.lastSeenMessages.write(buf);
|
||||
}
|
||||
|
||||
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 50dc68a005490415b88780397ef6c26859596dd5..0f87ddae65ca5956b16974b2cd4c2ca756651767 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/status/ServerStatus.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/status/ServerStatus.java
|
||||
@@ -22,8 +22,9 @@ public record ServerStatus(
|
||||
Optional<ServerStatus.Favicon> favicon,
|
||||
boolean enforcesSecureChat
|
||||
) {
|
||||
+ // DivineMC start - Configurable Chat message signatures
|
||||
public static final Codec<ServerStatus> CODEC = RecordCodecBuilder.create(
|
||||
- instance -> instance.group(
|
||||
+ instance -> space.bxteam.divinemc.configuration.DivineConfig.chatMessageSignatures ? instance.group(
|
||||
ComponentSerialization.CODEC.lenientOptionalFieldOf("description", CommonComponents.EMPTY).forGetter(ServerStatus::description),
|
||||
ServerStatus.Players.CODEC.lenientOptionalFieldOf("players").forGetter(ServerStatus::players),
|
||||
ServerStatus.Version.CODEC.lenientOptionalFieldOf("version").forGetter(ServerStatus::version),
|
||||
@@ -31,7 +32,16 @@ public record ServerStatus(
|
||||
Codec.BOOL.lenientOptionalFieldOf("enforcesSecureChat", Boolean.valueOf(false)).forGetter(ServerStatus::enforcesSecureChat)
|
||||
)
|
||||
.apply(instance, ServerStatus::new)
|
||||
+ : instance.group(
|
||||
+ ComponentSerialization.CODEC.lenientOptionalFieldOf("description", CommonComponents.EMPTY).forGetter(ServerStatus::description),
|
||||
+ ServerStatus.Players.CODEC.lenientOptionalFieldOf("players").forGetter(ServerStatus::players),
|
||||
+ ServerStatus.Version.CODEC.lenientOptionalFieldOf("version").forGetter(ServerStatus::version),
|
||||
+ ServerStatus.Favicon.CODEC.lenientOptionalFieldOf("favicon").forGetter(ServerStatus::favicon),
|
||||
+ Codec.BOOL.lenientOptionalFieldOf("enforcesSecureChat", Boolean.FALSE).forGetter(x -> true)
|
||||
+ )
|
||||
+ .apply(instance, ServerStatus::new)
|
||||
);
|
||||
+ // DivineMC end
|
||||
|
||||
public static record Favicon(byte[] iconBytes) {
|
||||
private static final String PREFIX = "data:image/png;base64,";
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index f7db49d673853f31eacc76f5286b6a528b0390b6..40091d6c8a99a72f433520b3a703fccffadc308f 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -704,6 +704,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
|
||||
@Override
|
||||
public boolean enforceSecureProfile() {
|
||||
+ if (!space.bxteam.divinemc.configuration.DivineConfig.chatMessageSignatures) return false; // DivineMC - Configurable Chat message signatures
|
||||
DedicatedServerProperties dedicatedserverproperties = this.getProperties();
|
||||
|
||||
// Paper start - Add setting for proxy online mode status
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
index b82a72775f9de5ad65ae46a8b97f93a7ef852265..529b4c6f38e0b2dc8bd3c46059f19485b994f13b 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
@@ -323,10 +323,29 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
}
|
||||
|
||||
public void send(Packet<?> packet) {
|
||||
+ // DivineMC start - Configurable Chat message signatures
|
||||
+ if (!space.bxteam.divinemc.configuration.DivineConfig.chatMessageSignatures) {
|
||||
+ if (packet instanceof net.minecraft.network.protocol.game.ClientboundPlayerChatPacket chat) {
|
||||
+ packet = new net.minecraft.network.protocol.game.ClientboundSystemChatPacket(
|
||||
+ chat.chatType().decorate(chat.unsignedContent() != null ? chat.unsignedContent() : Component.literal(chat.body().content())), false);
|
||||
+
|
||||
+ this.send(packet);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // DivineMC end
|
||||
this.send(packet, (PacketSendListener) null);
|
||||
}
|
||||
|
||||
public void send(Packet<?> packet, @Nullable PacketSendListener callbacks) {
|
||||
+ // DivineMC start - Configurable Chat message signatures
|
||||
+ if (!space.bxteam.divinemc.configuration.DivineConfig.chatMessageSignatures) {
|
||||
+ if (packet instanceof net.minecraft.network.protocol.game.ClientboundPlayerChatPacket chat && callbacks != null) {
|
||||
+ this.send(chat);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // DivineMC end
|
||||
// CraftBukkit start
|
||||
if (packet == null || this.processedDisconnect) { // Spigot
|
||||
return;
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index b863f6fe65c796a1d3102cc3eddb5d6c5becd3ac..cc1c9fe6dfb436befbe626c53d896ac8ec58ff31 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -1468,7 +1468,7 @@ public abstract class PlayerList {
|
||||
// Paper end
|
||||
boolean flag = this.verifyChatTrusted(message);
|
||||
|
||||
- this.server.logChatMessage((unsignedFunction == null ? message.decoratedContent() : unsignedFunction.apply(this.server.console)), params, flag ? null : "Not Secure"); // Paper
|
||||
+ this.server.logChatMessage((unsignedFunction == null ? message.decoratedContent() : unsignedFunction.apply(this.server.console)), params, flag ? null : (space.bxteam.divinemc.configuration.DivineConfig.chatMessageSignatures ? null : "Not Secure")); // Paper // DivineMC - Configurable Chat message signatures
|
||||
OutgoingChatMessage outgoingchatmessage = OutgoingChatMessage.create(message);
|
||||
boolean flag1 = false;
|
||||
|
||||
@@ -1497,6 +1497,7 @@ public abstract class PlayerList {
|
||||
}
|
||||
|
||||
public boolean verifyChatTrusted(PlayerChatMessage message) { // Paper - private -> public
|
||||
+ if (!space.bxteam.divinemc.configuration.DivineConfig.chatMessageSignatures) return true; // DivineMC - Configurable Chat message signatures
|
||||
return message.hasSignature() && !message.hasExpiredServer(Instant.now());
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
|
||||
index 9ae6daeb94232c2f8c5e8f9cc3a2df2f89cd4ed3..ed92e0b8295f0ca45359612a41367874d88f2181 100644
|
||||
--- a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
|
||||
+++ b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
|
||||
@@ -161,4 +161,9 @@ public class DivineConfig {
|
||||
sheepOptimization = getBoolean("settings.optimizations.sheep-optimization", sheepOptimization);
|
||||
recipeManagerOptimization = getBoolean("settings.optimizations.recipe-manager-optimization", recipeManagerOptimization);
|
||||
}
|
||||
+
|
||||
+ public static boolean chatMessageSignatures = true;
|
||||
+ private static void chatMessageSignatures() {
|
||||
+ chatMessageSignatures = getBoolean("settings.chat-message-signatures", chatMessageSignatures);
|
||||
+ }
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sat, 13 Jan 2024 18:58:14 +0300
|
||||
Subject: [PATCH] Carpet-Fixes: RecipeManager Optimize
|
||||
|
||||
Original project: https://github.com/fxmorin/carpet-fixes
|
||||
Improves: [Blast]Furnace/Campfire/Smoker/Stonecutter/Crafting/Sheep Color Choosing
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
index a31326e24cb68472c81cd781c5e3041772712862..6113cf0ff4090e06c40a6f439fde07bf74a34745 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
@@ -12,15 +12,7 @@ import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
-import java.util.Collection;
|
||||
-import java.util.Comparator;
|
||||
-import java.util.Iterator;
|
||||
-import java.util.List;
|
||||
-import java.util.Map;
|
||||
-import java.util.Map.Entry;
|
||||
-import java.util.Optional;
|
||||
-import java.util.stream.Collectors;
|
||||
-import java.util.stream.Stream;
|
||||
+import java.util.*;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.NonNullList;
|
||||
@@ -132,7 +124,7 @@ public class RecipeManager extends SimpleJsonResourceReloadListener {
|
||||
}
|
||||
|
||||
public <C extends Container, T extends Recipe<C>> List<RecipeHolder<T>> getAllRecipesFor(RecipeType<T> type) {
|
||||
- return List.copyOf(this.byType(type));
|
||||
+ return space.bxteam.divinemc.configuration.DivineConfig.recipeManagerOptimization ? new ArrayList<>(this.byType(type)) : List.copyOf(this.byType(type)); // DivineMC - Carpet-Fixes: RecipeManager Optimize
|
||||
}
|
||||
|
||||
public <C extends Container, T extends Recipe<C>> List<RecipeHolder<T>> getRecipesFor(RecipeType<T> type, C inventory, Level world) {
|
||||
diff --git a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
|
||||
index 73b6c3590dad95cddd9cc1a1cff36492175da232..67ff4450b58c1df2f595a136c53d60bbefa2e8d5 100644
|
||||
--- a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
|
||||
+++ b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
|
||||
@@ -154,7 +154,9 @@ public class DivineConfig {
|
||||
}
|
||||
|
||||
public static boolean biomeManagerOptimization = true;
|
||||
+ public static boolean recipeManagerOptimization = true;
|
||||
private static void optimizations() {
|
||||
biomeManagerOptimization = getBoolean("settings.optimizations.biome-manager-optimization", biomeManagerOptimization);
|
||||
+ recipeManagerOptimization = getBoolean("settings.optimizations.recipe-manager-optimization", recipeManagerOptimization);
|
||||
}
|
||||
}
|
||||
@@ -1,200 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sun, 7 Jan 2024 11:56:00 +0300
|
||||
Subject: [PATCH] Configurable Chat message signatures
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
|
||||
index 1d78e8beacbc93ef2cd6beb418edca843f8a5429..9d389c5a09c090750b1c17b0d162e06e6899a063 100644
|
||||
--- a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
|
||||
+++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
|
||||
@@ -317,7 +317,7 @@ public final class ChatProcessor {
|
||||
|
||||
private void sendToServer(final ChatType.Bound chatType, final @Nullable Function<Audience, net.minecraft.network.chat.Component> msgFunction) {
|
||||
final PlayerChatMessage toConsoleMessage = msgFunction == null ? ChatProcessor.this.message : ChatProcessor.this.message.withUnsignedContent(msgFunction.apply(ChatProcessor.this.server.console));
|
||||
- ChatProcessor.this.server.logChatMessage(toConsoleMessage.decoratedContent(), chatType, ChatProcessor.this.server.getPlayerList().verifyChatTrusted(toConsoleMessage) ? null : "Not Secure");
|
||||
+ ChatProcessor.this.server.logChatMessage(toConsoleMessage.decoratedContent(), chatType, ChatProcessor.this.server.getPlayerList().verifyChatTrusted(toConsoleMessage) ? null : (space.bxteam.divinemc.configuration.DivineConfig.chatMessageSignatures ? null : "Not Secure")); // DivineMC - Configurable Chat message signatures
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundChatCommandPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundChatCommandPacket.java
|
||||
index e62ae57532ddcf12b7ebca77220cb1f3bd603717..70201f97584442b7573a3da7b9a439117aa442ca 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundChatCommandPacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundChatCommandPacket.java
|
||||
@@ -18,7 +18,7 @@ public record ServerboundChatCommandPacket(
|
||||
buf.writeUtf(this.command, 256);
|
||||
buf.writeInstant(this.timeStamp);
|
||||
buf.writeLong(this.salt);
|
||||
- this.argumentSignatures.write(buf);
|
||||
+ if (!space.bxteam.divinemc.configuration.DivineConfig.chatMessageSignatures) this.argumentSignatures.write(buf); // DivineMC - Configurable Chat message signatures
|
||||
this.lastSeenMessages.write(buf);
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java
|
||||
index 831178218ddfaa1828c00d0662b251d11bb29ff5..10a4a52b13de38791c58f2323dffd320a789b547 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java
|
||||
@@ -18,7 +18,7 @@ public record ServerboundChatPacket(String message, Instant timeStamp, long salt
|
||||
buf.writeUtf(this.message, 256);
|
||||
buf.writeInstant(this.timeStamp);
|
||||
buf.writeLong(this.salt);
|
||||
- buf.writeNullable(this.signature, MessageSignature::write);
|
||||
+ if (!space.bxteam.divinemc.configuration.DivineConfig.chatMessageSignatures) buf.writeNullable(this.signature, MessageSignature::write); // DivineMC - Configurable Chat message signatures
|
||||
this.lastSeenMessages.write(buf);
|
||||
}
|
||||
|
||||
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 5ed4a3a30657ab9e748245ad34333b915e870ae2..7b76782d7fc7bebef4248b1847ba6dd8a6c5dc8c 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/status/ServerStatus.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/status/ServerStatus.java
|
||||
@@ -23,14 +23,21 @@ public record ServerStatus(
|
||||
boolean enforcesSecureChat
|
||||
) {
|
||||
public static final Codec<ServerStatus> CODEC = RecordCodecBuilder.create(
|
||||
- instance -> instance.group(
|
||||
- ComponentSerialization.CODEC.optionalFieldOf("description", CommonComponents.EMPTY).forGetter(ServerStatus::description),
|
||||
- ServerStatus.Players.CODEC.optionalFieldOf("players").forGetter(ServerStatus::players),
|
||||
- ServerStatus.Version.CODEC.optionalFieldOf("version").forGetter(ServerStatus::version),
|
||||
- ServerStatus.Favicon.CODEC.optionalFieldOf("favicon").forGetter(ServerStatus::favicon),
|
||||
- Codec.BOOL.optionalFieldOf("enforcesSecureChat", Boolean.valueOf(false)).forGetter(ServerStatus::enforcesSecureChat)
|
||||
- )
|
||||
- .apply(instance, ServerStatus::new)
|
||||
+ instance -> space.bxteam.divinemc.configuration.DivineConfig.chatMessageSignatures ? instance.group(
|
||||
+ ComponentSerialization.CODEC.optionalFieldOf("description", CommonComponents.EMPTY).forGetter(ServerStatus::description),
|
||||
+ ServerStatus.Players.CODEC.optionalFieldOf("players").forGetter(ServerStatus::players),
|
||||
+ ServerStatus.Version.CODEC.optionalFieldOf("version").forGetter(ServerStatus::version),
|
||||
+ ServerStatus.Favicon.CODEC.optionalFieldOf("favicon").forGetter(ServerStatus::favicon),
|
||||
+ Codec.BOOL.optionalFieldOf("enforcesSecureChat", Boolean.FALSE).forGetter(x -> true)
|
||||
+ )
|
||||
+ .apply(instance, ServerStatus::new) : instance.group(
|
||||
+ ComponentSerialization.CODEC.optionalFieldOf("description", CommonComponents.EMPTY).forGetter(ServerStatus::description),
|
||||
+ ServerStatus.Players.CODEC.optionalFieldOf("players").forGetter(ServerStatus::players),
|
||||
+ ServerStatus.Version.CODEC.optionalFieldOf("version").forGetter(ServerStatus::version),
|
||||
+ ServerStatus.Favicon.CODEC.optionalFieldOf("favicon").forGetter(ServerStatus::favicon),
|
||||
+ Codec.BOOL.optionalFieldOf("enforcesSecureChat", Boolean.FALSE).forGetter(ServerStatus::enforcesSecureChat)
|
||||
+ )
|
||||
+ .apply(instance, ServerStatus::new)
|
||||
);
|
||||
|
||||
public static record Favicon(byte[] iconBytes) {
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 41cffa00d4978f46b47ac6ede2da2a256796a0ba..9fa9a1e1efab58f3133b32517bb04c2ec708816d 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -682,6 +682,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
|
||||
@Override
|
||||
public boolean enforceSecureProfile() {
|
||||
+ if (space.bxteam.divinemc.configuration.DivineConfig.chatMessageSignatures) return false; // DivineMC - Configurable Chat message signatures
|
||||
DedicatedServerProperties dedicatedserverproperties = this.getProperties();
|
||||
|
||||
// Paper start - Add setting for proxy online mode status
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 305b90d10a499e9731f5178433fb10207e428091..8206429795ec7bf81b9e628ac08ffc591ddd409a 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -2258,7 +2258,7 @@ public class ServerPlayer extends Player {
|
||||
}
|
||||
|
||||
public void sendServerStatus(ServerStatus metadata) {
|
||||
- this.connection.send(new ClientboundServerDataPacket(metadata.description(), metadata.favicon().map(ServerStatus.Favicon::iconBytes), metadata.enforcesSecureChat()));
|
||||
+ if (space.bxteam.divinemc.configuration.DivineConfig.chatMessageSignatures) this.connection.send(new ClientboundServerDataPacket(metadata.description(), metadata.favicon().map(ServerStatus.Favicon::iconBytes), true)); else this.connection.send(new ClientboundServerDataPacket(metadata.description(), metadata.favicon().map(ServerStatus.Favicon::iconBytes), metadata.enforcesSecureChat())); // DivineMC - Configurable Chat message signatures
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
index 02e65b0bd212d46855baee48fab35dc95a88b43f..9d9c1bc8bdf55998172bca5edf78d9b8b048b2c9 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
@@ -4,7 +4,7 @@ import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import java.util.Objects;
|
||||
import javax.annotation.Nullable;
|
||||
-import net.minecraft.ChatFormatting;
|
||||
+import io.papermc.paper.adventure.PaperAdventure; // DivineMC
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.CrashReportCategory;
|
||||
import net.minecraft.ReportedException;
|
||||
@@ -22,6 +22,7 @@ import net.minecraft.network.protocol.common.ServerboundKeepAlivePacket;
|
||||
import net.minecraft.network.protocol.common.ServerboundPongPacket;
|
||||
import net.minecraft.network.protocol.common.ServerboundResourcePackPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetDefaultSpawnPositionPacket;
|
||||
+import net.minecraft.network.protocol.game.ClientboundSystemChatPacket; // DivineMC
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ClientInformation;
|
||||
@@ -34,7 +35,6 @@ import org.slf4j.Logger;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
-import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
import org.bukkit.craftbukkit.util.CraftLocation;
|
||||
import org.bukkit.craftbukkit.util.Waitable;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
@@ -271,10 +271,31 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
}
|
||||
|
||||
public void send(Packet<?> packet) {
|
||||
+ // DivineMC start - Configurable Chat message signatures
|
||||
+ if (space.bxteam.divinemc.configuration.DivineConfig.chatMessageSignatures) {
|
||||
+ if (packet instanceof net.minecraft.network.protocol.game.ClientboundPlayerChatPacket chat) {
|
||||
+ packet = new ClientboundSystemChatPacket(PaperAdventure.asAdventure(chat.chatType().resolve(this.player.level().registryAccess())
|
||||
+ .get().decorate(chat.unsignedContent() != null ? chat.unsignedContent()
|
||||
+ : Component.literal(chat.body().content()))), false);
|
||||
+
|
||||
+ this.send(packet);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // DivineMC end
|
||||
this.send(packet, (PacketSendListener) null);
|
||||
}
|
||||
|
||||
public void send(Packet<?> packet, @Nullable PacketSendListener callbacks) {
|
||||
+ // DivineMC start - Configurable Chat message signatures
|
||||
+ if (space.bxteam.divinemc.configuration.DivineConfig.chatMessageSignatures) {
|
||||
+ if (packet instanceof net.minecraft.network.protocol.game.ClientboundPlayerChatPacket chat && callbacks != null) {
|
||||
+ this.send(chat);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // DivineMC end
|
||||
+
|
||||
// CraftBukkit start
|
||||
if (packet == null || this.processedDisconnect) { // Spigot
|
||||
return;
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index ac1e0c66f167218306504db6037cc1d6509072a0..7784a81f2b861e1f5c9dd7a7885e8be70b89bc8a 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -1469,7 +1469,7 @@ public abstract class PlayerList {
|
||||
// Paper end
|
||||
boolean flag = this.verifyChatTrusted(message);
|
||||
|
||||
- this.server.logChatMessage((unsignedFunction == null ? message.decoratedContent() : unsignedFunction.apply(this.server.console)), params, flag ? null : "Not Secure"); // Paper
|
||||
+ this.server.logChatMessage((unsignedFunction == null ? message.decoratedContent() : unsignedFunction.apply(this.server.console)), params, flag ? null : (space.bxteam.divinemc.configuration.DivineConfig.chatMessageSignatures ? null : "Not Secure")); // Paper // DivineMC - Configurable Chat message signatures
|
||||
OutgoingChatMessage outgoingchatmessage = OutgoingChatMessage.create(message);
|
||||
boolean flag1 = false;
|
||||
|
||||
@@ -1498,6 +1498,7 @@ public abstract class PlayerList {
|
||||
}
|
||||
|
||||
public boolean verifyChatTrusted(PlayerChatMessage message) { // Paper - private -> public
|
||||
+ if (space.bxteam.divinemc.configuration.DivineConfig.chatMessageSignatures) return true; // DivineMC - Configurable Chat message signatures
|
||||
return message.hasSignature() && !message.hasExpiredServer(Instant.now());
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
|
||||
index ef7983863da3b4febef3da2fab93fe581fbd65af..b9223f4778de0c2ed6efed6f8c192cb0212cbda8 100644
|
||||
--- a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
|
||||
+++ b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
|
||||
@@ -157,4 +157,9 @@ public class DivineConfig {
|
||||
private static void doNotProcessChatCommands() {
|
||||
doNotProcessChatCommands = getBoolean("settings.do-not-process-chat-commands", doNotProcessChatCommands);
|
||||
}
|
||||
+
|
||||
+ public static boolean chatMessageSignatures = false;
|
||||
+ private static void chatMessageSignatures() {
|
||||
+ chatMessageSignatures = getBoolean("settings.disable-chat-reports", chatMessageSignatures);
|
||||
+ }
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Tue, 16 Apr 2024 01:26:18 +0300
|
||||
Subject: [PATCH] Fix chat signing
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||||
index 67eeb39aede6908d2756e49821ca350ebe916902..740d3bd228eed7b322d98ac77c15429c3f2e3d68 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||||
@@ -41,16 +41,7 @@ public class SignedMessageChain {
|
||||
throw new SignedMessageChain.DecodeException(Component.translatable("multiplayer.disconnect.out_of_order_chat"), true, org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT); // Paper - kick event causes
|
||||
} else {
|
||||
this.lastTimeStamp = body.timeStamp();
|
||||
- PlayerChatMessage playerChatMessage = new PlayerChatMessage(signedMessageLink, signature, body, null, FilterMask.PASS_THROUGH);
|
||||
- if (!playerChatMessage.verify(signatureValidator)) {
|
||||
- throw new SignedMessageChain.DecodeException(Component.translatable("multiplayer.disconnect.unsigned_chat"), true, org.bukkit.event.player.PlayerKickEvent.Cause.UNSIGNED_CHAT); // Paper - kick event causes
|
||||
- } else {
|
||||
- if (playerChatMessage.hasExpiredServer(Instant.now())) {
|
||||
- LOGGER.warn("Received expired chat: '{}'. Is the client/server system time unsynchronized?", body.content());
|
||||
- }
|
||||
-
|
||||
- return playerChatMessage;
|
||||
- }
|
||||
+ return new PlayerChatMessage(signedMessageLink, signature, body, null, FilterMask.PASS_THROUGH); // DivineMC - Fix chat signing
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user