summaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
authorAizistral2022-06-25 17:25:12 +0200
committerAizistral2022-06-25 17:25:12 +0200
commit5b2182003a142a882b5aaac51b61d040edf64a43 (patch)
tree92f997c67c90c9e6f41b5e00b54d6551a00182df /src/test/java
parentf2afd3c41ec83500c976e30fc445ae03e4bdf165 (diff)
Document test mod
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/com/aizistral/nochatreports/debug/ReportWriter.java7
-rw-r--r--src/test/java/com/aizistral/nochatreports/debug/mixins/MixinAbuseReportSenderServices.java6
-rw-r--r--src/test/java/com/aizistral/nochatreports/debug/mixins/MixinPlayerEntry.java7
3 files changed, 20 insertions, 0 deletions
diff --git a/src/test/java/com/aizistral/nochatreports/debug/ReportWriter.java b/src/test/java/com/aizistral/nochatreports/debug/ReportWriter.java
index 5e8ee0f..bc663d3 100644
--- a/src/test/java/com/aizistral/nochatreports/debug/ReportWriter.java
+++ b/src/test/java/com/aizistral/nochatreports/debug/ReportWriter.java
@@ -8,6 +8,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Date;
+import com.aizistral.nochatreports.debug.mixins.MixinAbuseReportSenderServices;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.ibm.icu.text.SimpleDateFormat;
@@ -17,6 +18,12 @@ import com.mojang.authlib.yggdrasil.request.AbuseReportRequest;
import net.fabricmc.loader.api.FabricLoader;
+/**
+ * Allows to save chat reports locally. See {@link MixinAbuseReportSenderServices} for details.
+ *
+ * @author Aizistral
+ */
+
public class ReportWriter {
private static final ObjectMapper MAPPER = ObjectMapper.create();
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
diff --git a/src/test/java/com/aizistral/nochatreports/debug/mixins/MixinAbuseReportSenderServices.java b/src/test/java/com/aizistral/nochatreports/debug/mixins/MixinAbuseReportSenderServices.java
index 9ce6933..aa16ae1 100644
--- a/src/test/java/com/aizistral/nochatreports/debug/mixins/MixinAbuseReportSenderServices.java
+++ b/src/test/java/com/aizistral/nochatreports/debug/mixins/MixinAbuseReportSenderServices.java
@@ -21,6 +21,12 @@ public class MixinAbuseReportSenderServices {
@Shadow @Final
private ReportEnvironment environment;
+ /**
+ * @reason Write report locally instead of trying to send it to Mojang.
+ * Allows to intercept and examine contents of the report.
+ * @author Aizistral
+ */
+
@Overwrite
public CompletableFuture<Unit> send(UUID uuid, AbuseReport abuseReport) {
AbuseReportRequest abuseReportRequest = new AbuseReportRequest(uuid,
diff --git a/src/test/java/com/aizistral/nochatreports/debug/mixins/MixinPlayerEntry.java b/src/test/java/com/aizistral/nochatreports/debug/mixins/MixinPlayerEntry.java
index 1f671ca..e7e4cfc 100644
--- a/src/test/java/com/aizistral/nochatreports/debug/mixins/MixinPlayerEntry.java
+++ b/src/test/java/com/aizistral/nochatreports/debug/mixins/MixinPlayerEntry.java
@@ -10,6 +10,13 @@ import net.minecraft.client.multiplayer.chat.report.AbuseReportSender;
@Mixin(PlayerEntry.class)
public class MixinPlayerEntry {
+ /**
+ * @reason Always allow to report players on server, even if services are
+ * unreachable (which they are in IDE). Useful when used along with
+ * {@link MixinAbuseReportSenderServices}.
+ * @author Aizistral
+ */
+
@Redirect(method = "<init>", at = @At(value = "INVOKE", target =
"Lnet/minecraft/client/multiplayer/chat/report/AbuseReportSender;isEnabled()Z"))
private boolean forceEnableReporting(AbuseReportSender sender) {