summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/aizistral/nochatreports/MixinConnector.java13
-rw-r--r--src/main/java/com/aizistral/nochatreports/NoChatReports.java79
-rw-r--r--src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java35
-rw-r--r--src/main/java/com/aizistral/nochatreports/handlers/NoReportsConfig.java6
-rw-r--r--src/main/java/com/aizistral/nochatreports/network/ClientChannelHandler.java26
-rw-r--r--src/main/java/com/aizistral/nochatreports/network/ServerChannelHandler.java22
-rw-r--r--src/main/resources/META-INF/MANIFEST.MF1
-rw-r--r--src/main/resources/META-INF/mods.toml12
-rw-r--r--src/main/resources/assets/nochatreports/lang/en_us.json4
-rw-r--r--src/main/resources/fabric.mod.json39
-rw-r--r--src/main/resources/pack.mcmeta6
11 files changed, 153 insertions, 90 deletions
diff --git a/src/main/java/com/aizistral/nochatreports/MixinConnector.java b/src/main/java/com/aizistral/nochatreports/MixinConnector.java
deleted file mode 100644
index dc2b9a6..0000000
--- a/src/main/java/com/aizistral/nochatreports/MixinConnector.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.aizistral.nochatreports;
-
-import org.spongepowered.asm.mixin.Mixins;
-import org.spongepowered.asm.mixin.connect.IMixinConnector;
-
-public class MixinConnector implements IMixinConnector {
-
- @Override
- public void connect() {
- Mixins.addConfigurations("nochatreports.mixins.json");
- }
-
-}
diff --git a/src/main/java/com/aizistral/nochatreports/NoChatReports.java b/src/main/java/com/aizistral/nochatreports/NoChatReports.java
index adaf08b..d45c5e8 100644
--- a/src/main/java/com/aizistral/nochatreports/NoChatReports.java
+++ b/src/main/java/com/aizistral/nochatreports/NoChatReports.java
@@ -1,70 +1,41 @@
package com.aizistral.nochatreports;
-import java.util.function.Predicate;
-
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.aizistral.nochatreports.handlers.NoReportsConfig;
-
+import com.aizistral.nochatreports.network.ServerChannelHandler;
+
+import net.fabricmc.api.ClientModInitializer;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.ModInitializer;
+import net.fabricmc.fabric.api.networking.v1.PacketSender;
+import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
+import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
+import net.fabricmc.loader.api.FabricLoader;
+import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
-import net.minecraft.world.item.ItemStack;
-import net.minecraft.world.item.Items;
-import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.fml.ModLoadingContext;
-import net.minecraftforge.fml.common.Mod;
-import net.minecraftforge.fml.config.ModConfig;
-import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
-import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
-import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent;
-import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
-import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
-import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
-import net.minecraftforge.network.NetworkRegistry;
-import net.minecraftforge.network.simple.SimpleChannel;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.network.ServerGamePacketListenerImpl;
-@Mod(NoChatReports.MODID)
-public class NoChatReports {
- public static final String MODID = "nochatreports";
+public class NoChatReports implements ModInitializer {
public static final Logger LOGGER = LogManager.getLogger();
- private static final String PTC_VERSION = "1";
- private static final Predicate<String> ANY = obj -> true;
- private static SimpleChannel packetInstance;
-
- public NoChatReports() {
- FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
- FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);
- FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC);
- FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
- FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onLoadComplete);
+ protected static final ResourceLocation CHANNEL = new ResourceLocation("nochatreports", "sync");
- MinecraftForge.EVENT_BUS.register(this);
+ @Override
+ public void onInitialize() {
+ LOGGER.info("KONNICHIWA ZA WARUDO!");
+ ServerPlayNetworking.registerGlobalReceiver(CHANNEL, ServerChannelHandler.INSTANCE);
+ ServerPlayConnectionEvents.JOIN.register(this::onPlayReady);
NoReportsConfig.loadConfig();
}
- private void onLoadComplete(final FMLLoadCompleteEvent event) {
- // NO-OP
- }
-
- private void setup(final FMLCommonSetupEvent event) {
- packetInstance = NetworkRegistry.ChannelBuilder.named(new ResourceLocation(MODID, "main"))
- .networkProtocolVersion(() -> PTC_VERSION)
- .clientAcceptedVersions(NoReportsConfig.demandsOnServer() ? PTC_VERSION::equals : ANY)
- .serverAcceptedVersions(NoReportsConfig.demandsOnClient() ? PTC_VERSION::equals : ANY)
- .simpleChannel();
- }
-
- private void doClientStuff(final FMLClientSetupEvent event) {
- // NO-OP
- }
-
- private void enqueueIMC(final InterModEnqueueEvent event) {
- // NO-OP
+ private void onPlayReady(ServerGamePacketListenerImpl handler, PacketSender sender, MinecraftServer server) {
+ server.execute(() -> {
+ if (!ServerPlayNetworking.canSend(handler, CHANNEL)) {
+ handler.disconnect(Component.translatable("disconnect.nochatreports.server"));
+ }
+ });
}
-
- private void processIMC(final InterModProcessEvent event) {
- // NO-OP
- }
-
}
diff --git a/src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java b/src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java
new file mode 100644
index 0000000..3899a5c
--- /dev/null
+++ b/src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java
@@ -0,0 +1,35 @@
+package com.aizistral.nochatreports;
+
+import com.aizistral.nochatreports.network.ClientChannelHandler;
+import com.aizistral.nochatreports.network.ServerChannelHandler;
+
+import net.fabricmc.api.ClientModInitializer;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
+import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
+import net.fabricmc.fabric.api.networking.v1.PacketSender;
+import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.multiplayer.ClientPacketListener;
+import net.minecraft.network.chat.Component;
+
+@Environment(EnvType.CLIENT)
+public class NoChatReportsClient implements ClientModInitializer {
+
+ @Override
+ public void onInitializeClient() {
+ NoChatReports.LOGGER.info("Client initialization...");
+ ClientPlayNetworking.registerGlobalReceiver(NoChatReports.CHANNEL, ClientChannelHandler.INSTANCE);
+ ClientPlayConnectionEvents.JOIN.register(this::onPlayReady);
+ }
+
+ private void onPlayReady(ClientPacketListener handler, PacketSender sender, Minecraft client) {
+ client.execute(() -> {
+ if (!ClientPlayNetworking.canSend(NoChatReports.CHANNEL)) {
+ handler.getConnection().disconnect(Component.translatable("disconnect.nochatreports.client"));
+ }
+ });
+ }
+
+}
diff --git a/src/main/java/com/aizistral/nochatreports/handlers/NoReportsConfig.java b/src/main/java/com/aizistral/nochatreports/handlers/NoReportsConfig.java
index 2a9068a..bfc77bf 100644
--- a/src/main/java/com/aizistral/nochatreports/handlers/NoReportsConfig.java
+++ b/src/main/java/com/aizistral/nochatreports/handlers/NoReportsConfig.java
@@ -11,11 +11,11 @@ import javax.annotation.Nullable;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import net.minecraftforge.common.ForgeConfigSpec;
-import net.minecraftforge.fml.loading.FMLPaths;
+import net.fabricmc.loader.api.FabricLoader;
+import net.minecraft.client.Minecraft;
public class NoReportsConfig {
- private static final File CONFIG_FOLDER = FMLPaths.CONFIGDIR.get().toFile();
+ private static final File CONFIG_FOLDER = FabricLoader.getInstance().getConfigDir().toFile();
private static final File CONFIG_FILE = new File(CONFIG_FOLDER, "NoChatReports.json");
private static NoReportsConfig INSTANCE;
private boolean demandOnClient, demandOnServer;
diff --git a/src/main/java/com/aizistral/nochatreports/network/ClientChannelHandler.java b/src/main/java/com/aizistral/nochatreports/network/ClientChannelHandler.java
new file mode 100644
index 0000000..179a090
--- /dev/null
+++ b/src/main/java/com/aizistral/nochatreports/network/ClientChannelHandler.java
@@ -0,0 +1,26 @@
+package com.aizistral.nochatreports.network;
+
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking.PlayChannelHandler;
+import net.fabricmc.fabric.api.networking.v1.PacketSender;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.multiplayer.ClientPacketListener;
+import net.minecraft.network.FriendlyByteBuf;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.level.ServerPlayer;
+import net.minecraft.server.network.ServerGamePacketListenerImpl;
+
+@Environment(EnvType.CLIENT)
+public class ClientChannelHandler implements PlayChannelHandler {
+ public static final ClientChannelHandler INSTANCE = new ClientChannelHandler();
+
+ private ClientChannelHandler() {
+ // Can't touch this
+ }
+
+ @Override
+ public void receive(Minecraft client, ClientPacketListener handler, FriendlyByteBuf buf, PacketSender responseSender) {
+ // NO-OP
+ }
+}
diff --git a/src/main/java/com/aizistral/nochatreports/network/ServerChannelHandler.java b/src/main/java/com/aizistral/nochatreports/network/ServerChannelHandler.java
new file mode 100644
index 0000000..c649e71
--- /dev/null
+++ b/src/main/java/com/aizistral/nochatreports/network/ServerChannelHandler.java
@@ -0,0 +1,22 @@
+package com.aizistral.nochatreports.network;
+
+import net.fabricmc.fabric.api.networking.v1.PacketSender;
+import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking.PlayChannelHandler;
+import net.minecraft.network.FriendlyByteBuf;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.level.ServerPlayer;
+import net.minecraft.server.network.ServerGamePacketListenerImpl;
+
+public class ServerChannelHandler implements PlayChannelHandler {
+ public static final ServerChannelHandler INSTANCE = new ServerChannelHandler();
+
+ private ServerChannelHandler() {
+ // Can't touch this
+ }
+
+ @Override
+ public void receive(MinecraftServer server, ServerPlayer player, ServerGamePacketListenerImpl handler, FriendlyByteBuf buf, PacketSender responseSender) {
+ // NO-OP
+ }
+
+}
diff --git a/src/main/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF
deleted file mode 100644
index 520b722..0000000
--- a/src/main/resources/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1 +0,0 @@
-MixinConnector: com.aizistral.nochatreports.MixinConnector
diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml
deleted file mode 100644
index d3afb8e..0000000
--- a/src/main/resources/META-INF/mods.toml
+++ /dev/null
@@ -1,12 +0,0 @@
-license="WTFPL"
-modLoader="javafml"
-loaderVersion="[31,)"
-[[mods]]
-modId="nochatreports"
-version="1.0.0"
-displayName="No Chat Reports"
-authors="Aizistral"
-logoFile="NCR_logo.png"
-description='''
-None
-''' \ No newline at end of file
diff --git a/src/main/resources/assets/nochatreports/lang/en_us.json b/src/main/resources/assets/nochatreports/lang/en_us.json
index 28caa07..19fed74 100644
--- a/src/main/resources/assets/nochatreports/lang/en_us.json
+++ b/src/main/resources/assets/nochatreports/lang/en_us.json
@@ -1,3 +1,5 @@
{
- "gui.nochatreport.secureChat": "This option cannot work with No Chat Reports, since there are no signatures to verify."
+ "gui.nochatreport.secureChat": "This option cannot work with No Chat Reports, since there are no signatures to verify.",
+ "disconnect.nochatreports.client": "This server does not have No Chat Reports, and you have it configured to require itself on server.",
+ "disconnect.nochatreports.server": "You do not have No Chat Reports, and this server is configured to require it on client!"
} \ No newline at end of file
diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json
new file mode 100644
index 0000000..4d06ffd
--- /dev/null
+++ b/src/main/resources/fabric.mod.json
@@ -0,0 +1,39 @@
+{
+ "schemaVersion": 1,
+ "id": "nochatreports",
+ "version": "${version}",
+
+ "name": "No Chat Reports",
+ "description": "Strips cryptographic signatures from player messages, making it impossible to track and associate them with your Mojang/Microsoft account, as well as use Player Chat Reporting feature.",
+ "authors": [
+ "Aizistral"
+ ],
+ "contact": {
+ "homepage": "https://www.curseforge.com/minecraft/mc-mods/no-chat-reports",
+ "sources": "https://github.com/Aizistral-Studios/No-Chat-Reports"
+ },
+
+ "license": "WTFPL",
+ "icon": "NCR_logo.png",
+
+ "environment": "*",
+ "entrypoints": {
+ "main": [
+ "com.aizistral.nochatreports.NoChatReports"
+ ],
+ "client": [
+ "com.aizistral.nochatreports.NoChatReportsClient"
+ ]
+ },
+ "mixins": [
+ "nochatreports.mixins.json"
+ ],
+
+ "depends": {
+ "fabricloader": ">=0.14.6",
+ "fabric": "*",
+ "minecraft": "~1.19",
+ "java": ">=17"
+ },
+ "suggests": {}
+}
diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta
deleted file mode 100644
index 1a52c3a..0000000
--- a/src/main/resources/pack.mcmeta
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "pack": {
- "description": "No Chat Reports Resources",
- "pack_format": 6
- }
-}