aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLéo Kosman <leo.kosman@proton.me>2024-08-31 14:04:12 +0200
committerLéo Kosman <leo.kosman@proton.me>2024-08-31 14:04:12 +0200
commite760fcfbeb930cc3e31f01c8c2d33f1fbd1977dd (patch)
tree9614b97880c69f7e5cb74aa1b2c7937e3d4592dd /src
parent6f65825e1504a1090405685404e7cbc59bd0f44b (diff)
parentd5732c6f04c8718e8734b9794d3e1dbc5c33aec5 (diff)
Merge branch 'refs/heads/main' into feat/role-command
Diffstat (limited to 'src')
-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
+ }
+}