summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAizistral2022-07-11 23:09:18 +0200
committerAizistral2022-07-11 23:09:18 +0200
commit5eb3ac268a7877ceb9bafc1010fadc1a1ee89d25 (patch)
treeae1f9fc0cd8e661852632e9b458478bd417a57b4
parente6acfdbed63685627cc169742cbd684becfddb15 (diff)
Expand mixin documentation
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/AccessorDisconnectedScreen.java10
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatListener.java4
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatScreen.java5
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/MixinClientboundHelloPacket.java8
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/MixinConnectScreen.java6
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/MixinJoinMultiplayerScreen.java5
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/MixinLocalPlayer.java6
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/MixinMinecraft.java5
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/MixinOptions.java8
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/MixinPlayerEntry.java2
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/MixinProfileKeyPairManager.java15
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/MixinTitleScreen.java5
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/server/MixinDedicatedServer.java7
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/server/MixinPlayer.java3
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/server/MixinServerGamePacketListenerImpl.java6
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/server/MixinServerboundChatPacket.java11
16 files changed, 74 insertions, 32 deletions
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/AccessorDisconnectedScreen.java b/src/main/java/com/aizistral/nochatreports/mixins/client/AccessorDisconnectedScreen.java
index 1cf76f5..e6e5205 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/AccessorDisconnectedScreen.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/AccessorDisconnectedScreen.java
@@ -3,12 +3,22 @@ package com.aizistral.nochatreports.mixins.client;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
+import com.aizistral.nochatreports.NoChatReportsClient;
+import com.aizistral.nochatreports.gui.UnsafeServerScreen;
+
import net.minecraft.client.gui.screens.DisconnectedScreen;
import net.minecraft.network.chat.Component;
@Mixin(DisconnectedScreen.class)
public interface AccessorDisconnectedScreen {
+ /**
+ * @return Disconnect reason of this screen. This is used in {@link NoChatReportsClient} to detect
+ * when player have been kicked out of server because client refused to send account's public key,
+ * and subsequently swap the screen for {@link UnsafeServerScreen} where player can choose to
+ * reconnect and expose their key.
+ */
+
@Accessor
public Component getReason();
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatListener.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatListener.java
index ae46f06..2dc5f6c 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatListener.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatListener.java
@@ -22,7 +22,9 @@ import net.minecraft.network.chat.PlayerChatMessage;
public class MixinChatListener {
/**
- * @reason No annoying safety notices, thanks. Your system is unsafe anyways.
+ * @reason Removes "Not Secure" and "Modified" statuses of chat messages. They ultimately
+ * server no purpose but to annoy the user and scare them away from servers that actually
+ * try to protect them by stripping message signatures.
* @author Aizistral
*/
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatScreen.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatScreen.java
index 234a737..c9c5e37 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatScreen.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatScreen.java
@@ -33,6 +33,11 @@ import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.FormattedCharSequence;
+/**
+ * This is responsible for adding safety status indicator to the bottom-right corner of chat screen.
+ * @author Aizistral
+ */
+
@Mixin(ChatScreen.class)
public abstract class MixinChatScreen extends Screen {
private static final ResourceLocation CHAT_STATUS_ICONS = new ResourceLocation("nochatreports", "textures/gui/chat_status_icons.png");
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinClientboundHelloPacket.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinClientboundHelloPacket.java
index 81ed384..dfb94ad 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinClientboundHelloPacket.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinClientboundHelloPacket.java
@@ -6,6 +6,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+import com.aizistral.nochatreports.core.ServerSafetyLevel;
import com.aizistral.nochatreports.core.ServerSafetyState;
import net.minecraft.network.protocol.login.ClientLoginPacketListener;
@@ -14,6 +15,13 @@ import net.minecraft.network.protocol.login.ClientboundHelloPacket;
@Mixin(ClientboundHelloPacket.class)
public class MixinClientboundHelloPacket {
+ /**
+ * @reason If server is operated in the offline mode - we will never receive this type of packet
+ * from it, which allows us to conclude we have no necessity to expose account's public key.
+ * By acknowledging this we can update current {@link ServerSafetyLevel} accordingly.
+ * @author Aizistral
+ */
+
@Inject(method = "handle", at = @At("HEAD"))
private void onHandle(ClientLoginPacketListener listener, CallbackInfo info) {
ServerSafetyState.setSessionRequestedKey(true);
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinConnectScreen.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinConnectScreen.java
index a086b28..6b3fcf1 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinConnectScreen.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinConnectScreen.java
@@ -20,6 +20,12 @@ import net.minecraft.client.multiplayer.resolver.ServerAddress;
@Mixin(ConnectScreen.class)
public class MixinConnectScreen {
+ /**
+ * @reason Intercept initiation of any new server connection. This way we can keep track of which
+ * server client currently tries to connect to
+ * @author Aizistral
+ */
+
@Inject(method = "startConnecting", at = @At("HEAD"))
private static void onStartConnecting(Screen screen, Minecraft minecraft, ServerAddress serverAddress,
@Nullable ServerData serverData, CallbackInfo info) {
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinJoinMultiplayerScreen.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinJoinMultiplayerScreen.java
index 0e7584c..b6c8b71 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinJoinMultiplayerScreen.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinJoinMultiplayerScreen.java
@@ -28,6 +28,11 @@ import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.FormattedCharSequence;
+/**
+ * This is responsible for adding config reload button to server selection menu.
+ * @author Aizistral
+ */
+
@Mixin(JoinMultiplayerScreen.class)
public abstract class MixinJoinMultiplayerScreen extends Screen {
private static final ResourceLocation RELOAD_TEXTURE = new ResourceLocation("nochatreports", "textures/gui/config_reload_button.png");
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinLocalPlayer.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinLocalPlayer.java
index 31319e1..516b987 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinLocalPlayer.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinLocalPlayer.java
@@ -29,8 +29,7 @@ public class MixinLocalPlayer {
/**
* @reason Never sign messages, so that neither server nor other clients have
* proof of them being sent from your account.
- * @author Aizistral (Overwrite)
- * @author Aven (Inject)
+ * @author Aizistral
*/
@Inject(method = "signMessage", at = @At("HEAD"), cancellable = true)
@@ -42,8 +41,7 @@ public class MixinLocalPlayer {
/**
* @reason Same as above, except commands mostly concern only server.
- * @author Aizistral (Overwrite)
- * @author Aven (Inject)
+ * @author Aizistral
*/
@Inject(method = "signCommandArguments", at = @At("HEAD"), cancellable = true)
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinMinecraft.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinMinecraft.java
index a9f8929..0d9c796 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinMinecraft.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinMinecraft.java
@@ -21,6 +21,11 @@ import net.minecraft.world.entity.player.ChatVisiblity;
@Mixin(Minecraft.class)
public class MixinMinecraft {
+ /**
+ * @reason Replace "1.19.1" with "1.19.84" in game window title. No functional purpose.
+ * @author Aizistral
+ */
+
@Inject(method = "createTitle", at = @At("RETURN"), cancellable = true, require = 0)
private void onCreateTitle(CallbackInfoReturnable<String> info) {
if (info.getReturnValue().contains("1.19.1")) {
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinOptions.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinOptions.java
index 934a503..08e94db 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinOptions.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinOptions.java
@@ -16,9 +16,9 @@ public class MixinOptions {
private OptionInstance<Boolean> alternativeOption;
/**
- * @reason Disable secure chat option, since it will not work anyways.
- * @author Aizistral (Overwrite)
- * @author Aven (Inject)
+ * @reason Disable secure chat option, since it will not work anyways. I would prefer to have
+ * the button greyed out instead, but there is no elegant solution to implement this.
+ * @author Aizistral
*/
@Inject(method = "onlyShowSecureChat", at = @At("RETURN"), cancellable = true)
@@ -27,7 +27,7 @@ public class MixinOptions {
this.alternativeOption = new OptionInstance<>("options.onlyShowSecureChat",
OptionInstance.cachedConstantTooltip(Component.translatable("gui.nochatreport.secureChat")),
(component, value) -> value ? CommonComponents.OPTION_ON : CommonComponents.OPTION_OFF,
- new OptionInstance.Enum<>(ImmutableList.of(Boolean.FALSE), Codec.BOOL), false, (value) -> {});
+ new OptionInstance.Enum<>(ImmutableList.of(Boolean.FALSE), Codec.BOOL), false, (value) -> {});
}
cir.setReturnValue(this.alternativeOption);
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinPlayerEntry.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinPlayerEntry.java
index 3cf92d8..880388a 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinPlayerEntry.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinPlayerEntry.java
@@ -41,7 +41,7 @@ public class MixinPlayerEntry {
}
/**
- * @reason Disable chat report button if we are on client.
+ * @reason Disable (or hide if configured respectively) chat report button on client.
* @author Aizistral
*/
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinProfileKeyPairManager.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinProfileKeyPairManager.java
index a02a952..e1dc8f2 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinProfileKeyPairManager.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinProfileKeyPairManager.java
@@ -18,9 +18,9 @@ import java.util.Optional;
public class MixinProfileKeyPairManager {
/**
- * @reason We don't have to send our keys anywhere, and thus we won't.
- * @author Aizistral (Overwrite)
- * @author Aven (Inject)
+ * @reason Prevent the client from exposing its public key, unless it is necessary
+ * and user agreed to do so.
+ * @author Aizistral
*/
@Inject(method = "profilePublicKey", at = @At("HEAD"), cancellable = true)
@@ -31,9 +31,9 @@ public class MixinProfileKeyPairManager {
}
/**
- * @reason We don't have to send our keys anywhere, and thus we won't.
- * @author Aizistral (Overwrite)
- * @author Aven (Inject)
+ * @reason Prevent the client from exposing its public key, unless it is necessary
+ * and user agreed to do so.
+ * @author Aizistral
*/
@Inject(method = "profilePublicKeyData", at = @At("HEAD"), cancellable = true)
@@ -46,8 +46,7 @@ public class MixinProfileKeyPairManager {
/**
* @reason Prevent client from trying to produce signature in
* {@link ClientHandshakePacketListenerImpl#handleHello}.
- * @author Aizistral (Overwrite)
- * @author Aven (Inject)
+ * @author Aizistral
*/
@Inject(method = "signer", at = @At("HEAD"), cancellable = true)
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinTitleScreen.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinTitleScreen.java
index eee3bdd..11def95 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinTitleScreen.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinTitleScreen.java
@@ -12,6 +12,11 @@ import net.minecraft.client.gui.screens.TitleScreen;
@Mixin(TitleScreen.class)
public class MixinTitleScreen {
+ /**
+ * @reason Replace "1.19.1" with "1.19.84" in title screen. No functional purpose.
+ * @author Aizistral
+ */
+
@Redirect(method = "render", at = @At(value = "INVOKE", remap = true, target =
"Lnet/minecraft/WorldVersion;getName()Ljava/lang/String;"), require = 0)
private String onGetVersionName(WorldVersion version) {
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/server/MixinDedicatedServer.java b/src/main/java/com/aizistral/nochatreports/mixins/server/MixinDedicatedServer.java
index 7bb6819..2ec92b7 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/server/MixinDedicatedServer.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/server/MixinDedicatedServer.java
@@ -10,10 +10,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
public class MixinDedicatedServer {
/**
- * @reason If we are present on server - we won't be using keys for anything,
- * so this option ceases to make sense.
- * @author Aizistral (Overwrite)
- * @author Aven (Inject)
+ * @reason If mod is installed on server - it does the exact opposite of what this option is
+ * designed to enforce, so there's no reason to have it enabled.
+ * @author Aizistral
*/
@Inject(method = "enforceSecureProfile", at = @At("RETURN"), cancellable = true)
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/server/MixinPlayer.java b/src/main/java/com/aizistral/nochatreports/mixins/server/MixinPlayer.java
index c97bde5..780d93c 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/server/MixinPlayer.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/server/MixinPlayer.java
@@ -15,8 +15,7 @@ public class MixinPlayer {
/**
* @reason Prevents server from trying to validate signatures on incoming
* chat messages. Also prevents it from relaying public keys to other clients.
- * @author Aizistral (Overwrite)
- * @author Aven (Inject)
+ * @author Aizistral
*/
@Inject(method = "getProfilePublicKey", at = @At("HEAD"), cancellable = true)
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/server/MixinServerGamePacketListenerImpl.java b/src/main/java/com/aizistral/nochatreports/mixins/server/MixinServerGamePacketListenerImpl.java
index 75aa7e0..8373fe6 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/server/MixinServerGamePacketListenerImpl.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/server/MixinServerGamePacketListenerImpl.java
@@ -20,8 +20,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ServerGamePacketListenerImpl.class)
public abstract class MixinServerGamePacketListenerImpl implements ServerPlayerConnection {
-
- @Shadow public ServerPlayer player;
+ @Shadow
+ public ServerPlayer player;
/**
* @reason Convert player message to system message if mod is configured respectively.
@@ -35,7 +35,7 @@ public abstract class MixinServerGamePacketListenerImpl implements ServerPlayerC
if (NoReportsConfig.convertToGameMessage()) {
if (packet instanceof ClientboundPlayerChatPacket chat) {
Component component = chat.unsignedContent().orElse(chat.signedContent());
- ChatTypeDecoration decoration = player.level.registryAccess().registryOrThrow(Registry.CHAT_TYPE_REGISTRY).byId(chat.typeId()).chat();
+ ChatTypeDecoration decoration = this.player.level.registryAccess().registryOrThrow(Registry.CHAT_TYPE_REGISTRY).byId(chat.typeId()).chat();
component = decoration.decorate(component, chat.sender());
packet = new ClientboundSystemChatPacket(component, false);
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/server/MixinServerboundChatPacket.java b/src/main/java/com/aizistral/nochatreports/mixins/server/MixinServerboundChatPacket.java
index 93da925..fb7fb0a 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/server/MixinServerboundChatPacket.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/server/MixinServerboundChatPacket.java
@@ -10,17 +10,18 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+import com.aizistral.nochatreports.core.NoReportsConfig;
+
import java.util.UUID;
@Mixin(ServerboundChatPacket.class)
public class MixinServerboundChatPacket {
/**
- * @reason Strip signatures before relaying messages to other clients,
- * if they somehow arrive signed. This is important for mod to be able
- * to operate in server-only mode.
- * @author Aizistral (Overwrite)
- * @author Aven (Inject)
+ * @reason Strip signatures before relaying messages to other clients, if they arrive signed
+ * This is important for mod to be able to operate in server-only mode without
+ * {@link NoReportsConfig#convertToGameMessage()} enabled.
+ * @author Aizistral
*/
@Inject(method = "getSignature", at = @At("RETURN"), cancellable = true)