aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/world/anhgelus/molehunt/mixin/NoJoinLeaveMessage.java18
-rw-r--r--src/main/resources/molehunt.mixins.json27
2 files changed, 32 insertions, 13 deletions
diff --git a/src/main/java/world/anhgelus/molehunt/mixin/NoJoinLeaveMessage.java b/src/main/java/world/anhgelus/molehunt/mixin/NoJoinLeaveMessage.java
new file mode 100644
index 0000000..a82a21e
--- /dev/null
+++ b/src/main/java/world/anhgelus/molehunt/mixin/NoJoinLeaveMessage.java
@@ -0,0 +1,18 @@
+package world.anhgelus.molehunt.mixin;
+
+import net.minecraft.server.PlayerManager;
+import net.minecraft.text.Text;
+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.CallbackInfo;
+
+@Mixin(PlayerManager.class)
+public class NoJoinLeaveMessage {
+ @Inject(at = @At("HEAD"), method = "broadcast*", cancellable = true)
+ public void broadcastNoJoinLeaveMessage(Text message, boolean overlay, CallbackInfo ci) {
+ final var content = message.getContent().toString();
+ if (content.startsWith("translation{key='multiplayer.player.joined")) ci.cancel();
+ else if (content.startsWith("translation{key='multiplayer.player.left")) ci.cancel();
+ }
+}
diff --git a/src/main/resources/molehunt.mixins.json b/src/main/resources/molehunt.mixins.json
index 287cfc4..e9ec77e 100644
--- a/src/main/resources/molehunt.mixins.json
+++ b/src/main/resources/molehunt.mixins.json
@@ -1,13 +1,14 @@
-{
- "required": true,
- "minVersion": "0.8",
- "package": "world.anhgelus.molehunt.mixin",
- "compatibilityLevel": "JAVA_21",
- "mixins": [
- "NoMsgCommand",
- "NoPortals"
- ],
- "injectors": {
- "defaultRequire": 1
- }
-}
+{
+ "required": true,
+ "minVersion": "0.8",
+ "package": "world.anhgelus.molehunt.mixin",
+ "compatibilityLevel": "JAVA_21",
+ "mixins": [
+ "NoJoinLeaveMessage",
+ "NoMsgCommand",
+ "NoPortals"
+ ],
+ "injectors": {
+ "defaultRequire": 1
+ }
+}