diff options
| author | Aizistral | 2022-08-26 20:39:22 +0200 |
|---|---|---|
| committer | Aizistral | 2022-08-26 20:39:51 +0200 |
| commit | 3a7a0340c52c437ac12a0ab0b442823b9da935c4 (patch) | |
| tree | 864ca1ed032eccbff4fa68c5e3452164ca8947b5 /src/main/java/com | |
| parent | 304af8d893d9d91bca0e08fec07b812623d65d2e (diff) | |
Make `demandOnClient` disconnect message configurable
Closes #48
Diffstat (limited to 'src/main/java/com')
4 files changed, 15 insertions, 5 deletions
diff --git a/src/main/java/com/aizistral/nochatreports/NoChatReports.java b/src/main/java/com/aizistral/nochatreports/NoChatReports.java index d716171..3db427f 100644 --- a/src/main/java/com/aizistral/nochatreports/NoChatReports.java +++ b/src/main/java/com/aizistral/nochatreports/NoChatReports.java @@ -35,8 +35,8 @@ public final class NoChatReports implements ModInitializer { private void onPlayReady(ServerGamePacketListenerImpl handler, PacketSender sender, MinecraftServer server) { server.execute(() -> { - if (NCRConfig.getCommon().demandsOnClient() && !ServerPlayNetworking.canSend(handler, CHANNEL)) { - handler.disconnect(Component.literal("You do not have No Chat Reports, and this server is configured to require it on client!")); + if (NCRConfig.getCommon().demandOnClient() && !ServerPlayNetworking.canSend(handler, CHANNEL)) { + handler.disconnect(Component.literal(NCRConfig.getCommon().demandOnClientMessage())); } //handler.disconnect(Component.translatable("multiplayer.disconnect.missing_public_key")); diff --git a/src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java b/src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java index 4c69153..62c4185 100644 --- a/src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java +++ b/src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java @@ -102,7 +102,7 @@ public final class NoChatReportsClient implements ClientModInitializer { } } - if (NCRConfig.getClient().demandsOnServer() && !ClientPlayNetworking.canSend(NoChatReports.CHANNEL)) { + if (NCRConfig.getClient().demandOnServer() && !ClientPlayNetworking.canSend(NoChatReports.CHANNEL)) { handler.getConnection().disconnect(Component.translatable("disconnect.nochatreports.client")); } }); diff --git a/src/main/java/com/aizistral/nochatreports/config/NCRClientConfig.java b/src/main/java/com/aizistral/nochatreports/config/NCRClientConfig.java index de7f739..adb3d36 100644 --- a/src/main/java/com/aizistral/nochatreports/config/NCRClientConfig.java +++ b/src/main/java/com/aizistral/nochatreports/config/NCRClientConfig.java @@ -32,7 +32,7 @@ public final class NCRClientConfig extends JSONConfig { * This is false by default. */ - public boolean demandsOnServer() { + public boolean demandOnServer() { return this.demandOnServer; } diff --git a/src/main/java/com/aizistral/nochatreports/config/NCRCommonConfig.java b/src/main/java/com/aizistral/nochatreports/config/NCRCommonConfig.java index d6c3251..3491f0d 100644 --- a/src/main/java/com/aizistral/nochatreports/config/NCRCommonConfig.java +++ b/src/main/java/com/aizistral/nochatreports/config/NCRCommonConfig.java @@ -2,6 +2,7 @@ package com.aizistral.nochatreports.config; public final class NCRCommonConfig extends JSONConfig { protected static final String FILE_NAME = "NoChatReports/NCR-Common.json"; + protected String demandOnClientMessage = "You do not have No Chat Reports, and this server is configured to require it on client!"; protected boolean demandOnClient = true, enableDebugLog = false, convertToGameMessage = false, addQueryData = true; @@ -16,11 +17,20 @@ public final class NCRCommonConfig extends JSONConfig { * This is false by default. */ - public boolean demandsOnClient() { + public boolean demandOnClient() { return this.demandOnClient; } /** + * @return Disconnect message that should be shown to client if <code>demandOnClient</code> is + * true and it tries to join without No Chat Reports installed. + */ + + public String demandOnClientMessage() { + return this.demandOnClientMessage; + } + + /** * @return True if server should convert all player messages to system messages. System messages * do not feature signatures and look completely identical in the chat, with exception of gray line * next to them added in pre-release 3. They are also unselectable for chat reporting.<br><br> |
