diff options
Diffstat (limited to 'src/main/java')
8 files changed, 91 insertions, 79 deletions
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/MixinClientPacketListener.java b/src/main/java/com/aizistral/nochatreports/mixins/MixinClientPacketListener.java index 396832a..7121bbe 100644 --- a/src/main/java/com/aizistral/nochatreports/mixins/MixinClientPacketListener.java +++ b/src/main/java/com/aizistral/nochatreports/mixins/MixinClientPacketListener.java @@ -1,11 +1,12 @@ package com.aizistral.nochatreports.mixins; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; - import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.client.multiplayer.PlayerInfo; import net.minecraft.network.chat.PlayerChatMessage; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(ClientPacketListener.class) public class MixinClientPacketListener { @@ -13,11 +14,12 @@ public class MixinClientPacketListener { /** * @reason Prevents client from trying to validate chat messages relayed * by the server. They will come unsigned as in good old days, so no point. - * @author Aizistral + * @author Aizistral (Overwrite) + * @author Aven (Inject) */ - @Overwrite - private boolean hasValidSignature(PlayerChatMessage message, PlayerInfo info) { - return true; - } + @Inject(method = "hasValidSignature", at = @At("TAIL"), cancellable = true) + private void preventServerValidataion(PlayerChatMessage playerChatMessage, PlayerInfo playerInfo, CallbackInfoReturnable<Boolean> cir) { + cir.setReturnValue(true); + } } diff --git a/src/main/java/com/aizistral/nochatreports/mixins/MixinClientTelemetryManager.java b/src/main/java/com/aizistral/nochatreports/mixins/MixinClientTelemetryManager.java index 30f4926..588f02e 100644 --- a/src/main/java/com/aizistral/nochatreports/mixins/MixinClientTelemetryManager.java +++ b/src/main/java/com/aizistral/nochatreports/mixins/MixinClientTelemetryManager.java @@ -1,16 +1,13 @@ package com.aizistral.nochatreports.mixins; -import java.util.concurrent.Executor; - +import com.mojang.authlib.minecraft.TelemetrySession; +import com.mojang.authlib.minecraft.UserApiService; +import net.minecraft.client.ClientTelemetryManager; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; -import com.mojang.authlib.minecraft.TelemetrySession; -import com.mojang.authlib.minecraft.UserApiService; - -import net.minecraft.client.ClientTelemetryManager; +import java.util.concurrent.Executor; @Mixin(ClientTelemetryManager.class) public class MixinClientTelemetryManager { diff --git a/src/main/java/com/aizistral/nochatreports/mixins/MixinDedicatedServer.java b/src/main/java/com/aizistral/nochatreports/mixins/MixinDedicatedServer.java index 49ce5a8..7ab69b2 100644 --- a/src/main/java/com/aizistral/nochatreports/mixins/MixinDedicatedServer.java +++ b/src/main/java/com/aizistral/nochatreports/mixins/MixinDedicatedServer.java @@ -1,10 +1,10 @@ package com.aizistral.nochatreports.mixins; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; - -import net.minecraft.server.MinecraftServer; import net.minecraft.server.dedicated.DedicatedServer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(DedicatedServer.class) public class MixinDedicatedServer { @@ -12,12 +12,13 @@ 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 + * @author Aizistral (Overwrite) + * @author Aven (Inject) */ - @Overwrite - public boolean enforceSecureProfile() { - return false; + @Inject(method = "enforceSecureProfile", at = @At("RETURN"), cancellable = true) + private void enforceSecureProfile(CallbackInfoReturnable<Boolean> cir) { + cir.setReturnValue(false); } }
\ No newline at end of file diff --git a/src/main/java/com/aizistral/nochatreports/mixins/MixinLocalPlayer.java b/src/main/java/com/aizistral/nochatreports/mixins/MixinLocalPlayer.java index 24ed9d0..ed8a926 100644 --- a/src/main/java/com/aizistral/nochatreports/mixins/MixinLocalPlayer.java +++ b/src/main/java/com/aizistral/nochatreports/mixins/MixinLocalPlayer.java @@ -1,18 +1,18 @@ package com.aizistral.nochatreports.mixins; -import javax.annotation.Nullable; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; - import com.mojang.brigadier.ParseResults; - import net.minecraft.client.player.LocalPlayer; import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.commands.arguments.ArgumentSignatures; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MessageSignature; import net.minecraft.network.chat.MessageSigner; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import javax.annotation.Nullable; @Mixin(LocalPlayer.class) public class MixinLocalPlayer { @@ -20,22 +20,24 @@ 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 + * @author Aizistral (Overwrite) + * @author Aven (Inject) */ - @Overwrite - private MessageSignature signMessage(MessageSigner signer, Component message) { - return MessageSignature.unsigned(); + @Inject(method = "signMessage", at = @At("HEAD"), cancellable = true) + private void preventSigning(MessageSigner signer, Component message, CallbackInfoReturnable<MessageSignature> cir) { + cir.setReturnValue(MessageSignature.unsigned()); } /** * @reason Same as above, except commands mostly concern only server. - * @author Aizistral + * @author Aizistral (Overwrite) + * @author Aven (Inject) */ - @Overwrite - private ArgumentSignatures signCommandArguments(MessageSigner signer, ParseResults<SharedSuggestionProvider> results, @Nullable Component component) { - return ArgumentSignatures.empty(); + @Inject(method = "signCommandArguments", at = @At("HEAD"), cancellable = true) + private void preventSigningArgs(MessageSigner signer, ParseResults<SharedSuggestionProvider> results, @Nullable Component component, CallbackInfoReturnable<ArgumentSignatures> cir) { + cir.setReturnValue(ArgumentSignatures.empty()); } } diff --git a/src/main/java/com/aizistral/nochatreports/mixins/MixinOptions.java b/src/main/java/com/aizistral/nochatreports/mixins/MixinOptions.java index 0c53d51..1bb2bd4 100644 --- a/src/main/java/com/aizistral/nochatreports/mixins/MixinOptions.java +++ b/src/main/java/com/aizistral/nochatreports/mixins/MixinOptions.java @@ -1,15 +1,15 @@ package com.aizistral.nochatreports.mixins; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; - import com.google.common.collect.ImmutableList; import com.mojang.serialization.Codec; - import net.minecraft.client.OptionInstance; import net.minecraft.client.Options; import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Options.class) public class MixinOptions { @@ -17,11 +17,12 @@ public class MixinOptions { /** * @reason Disable secure chat option, since it will not work anyways. - * @author Aizistral + * @author Aizistral (Overwrite) + * @author Aven (Inject) */ - @Overwrite - public OptionInstance<Boolean> onlyShowSecureChat() { + @Inject(method = "onlyShowSecureChat", at = @At("RETURN"), cancellable = true) + private void onlyShowSecureChat(CallbackInfoReturnable<OptionInstance<Boolean>> cir) { if (this.alternativeOption == null) { this.alternativeOption = new OptionInstance<>("options.onlyShowSecureChat", OptionInstance.cachedConstantTooltip(Component.translatable("gui.nochatreport.secureChat")), @@ -29,7 +30,7 @@ public class MixinOptions { new OptionInstance.Enum<>(ImmutableList.of(Boolean.FALSE), Codec.BOOL), false, (value) -> {}); } - return this.alternativeOption; + cir.setReturnValue(this.alternativeOption); } } diff --git a/src/main/java/com/aizistral/nochatreports/mixins/MixinPlayer.java b/src/main/java/com/aizistral/nochatreports/mixins/MixinPlayer.java index e4326fa..0dccdcf 100644 --- a/src/main/java/com/aizistral/nochatreports/mixins/MixinPlayer.java +++ b/src/main/java/com/aizistral/nochatreports/mixins/MixinPlayer.java @@ -1,10 +1,11 @@ package com.aizistral.nochatreports.mixins; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; - import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.ProfilePublicKey; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Player.class) public class MixinPlayer { @@ -12,12 +13,13 @@ 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 + * @author Aizistral (Overwrite) + * @author Aven (Inject) */ - @Overwrite - public ProfilePublicKey getProfilePublicKey() { - return null; + @Inject(method = "getProfilePublicKey", at = @At("HEAD"), cancellable = true) + private void noServerValidation(CallbackInfoReturnable<ProfilePublicKey> cir) { + cir.setReturnValue(null); } } diff --git a/src/main/java/com/aizistral/nochatreports/mixins/MixinProfileKeyPairManager.java b/src/main/java/com/aizistral/nochatreports/mixins/MixinProfileKeyPairManager.java index 7796180..fe67d2c 100644 --- a/src/main/java/com/aizistral/nochatreports/mixins/MixinProfileKeyPairManager.java +++ b/src/main/java/com/aizistral/nochatreports/mixins/MixinProfileKeyPairManager.java @@ -1,46 +1,51 @@ package com.aizistral.nochatreports.mixins; -import java.util.Optional; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; - +import net.minecraft.client.multiplayer.ClientHandshakePacketListenerImpl; import net.minecraft.client.multiplayer.ProfileKeyPairManager; import net.minecraft.util.Signer; import net.minecraft.world.entity.player.ProfilePublicKey; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.Optional; @Mixin(ProfileKeyPairManager.class) public class MixinProfileKeyPairManager { /** * @reason We don't have to send our keys anywhere, and thus we won't. - * @author Aizistral + * @author Aizistral (Overwrite) + * @author Aven (Inject) */ - @Overwrite - public Optional<ProfilePublicKey> profilePublicKey() { - return Optional.empty(); + @Inject(method = "profilePublicKey", at = @At("HEAD"), cancellable = true) + private void preventServerValidation(CallbackInfoReturnable<Optional<ProfilePublicKey>> cir) { + cir.setReturnValue(Optional.empty()); } /** * @reason We don't have to send our keys anywhere, and thus we won't. - * @author Aizistral + * @author Aizistral (Overwrite) + * @author Aven (Inject) */ - @Overwrite - public Optional<ProfilePublicKey.Data> profilePublicKeyData() { - return Optional.empty(); + @Inject(method = "profilePublicKeyData", at = @At("HEAD"), cancellable = true) + private void dontSendKeys(CallbackInfoReturnable<Optional<ProfilePublicKey.Data>> cir) { + cir.setReturnValue(Optional.empty()); } /** * @reason Prevent client from trying to produce signature in - * {@link ClientHandshakePacketListenerImpl#handleHello(ClientboundHelloPacket)}. - * @author Aizistral + * {@link ClientHandshakePacketListenerImpl#handleHello}. + * @author Aizistral (Overwrite) + * @author Aven (Inject) */ - @Overwrite - public Signer signer() { - return null; + @Inject(method = "signer", at = @At("HEAD"), cancellable = true) + private void preventSignature(CallbackInfoReturnable<Optional<Signer>> cir) { + cir.setReturnValue(null); } } diff --git a/src/main/java/com/aizistral/nochatreports/mixins/MixinServerboundChatPacket.java b/src/main/java/com/aizistral/nochatreports/mixins/MixinServerboundChatPacket.java index d1f1814..600d2c6 100644 --- a/src/main/java/com/aizistral/nochatreports/mixins/MixinServerboundChatPacket.java +++ b/src/main/java/com/aizistral/nochatreports/mixins/MixinServerboundChatPacket.java @@ -1,12 +1,13 @@ package com.aizistral.nochatreports.mixins; -import java.util.UUID; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; - import net.minecraft.network.chat.MessageSignature; import net.minecraft.network.protocol.game.ServerboundChatPacket; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.UUID; @Mixin(ServerboundChatPacket.class) public class MixinServerboundChatPacket { @@ -15,12 +16,13 @@ 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 + * @author Aizistral (Overwrite) + * @author Aven (Inject) */ - @Overwrite - public MessageSignature getSignature(UUID uuid) { - return MessageSignature.unsigned(); + @Inject(method = "getSignature", at = @At("HEAD"), cancellable = true) + private void stripSignatures(UUID uUID, CallbackInfoReturnable<MessageSignature> cir) { + cir.setReturnValue(MessageSignature.unsigned()); } } |
