feat: add mixin login/leave messages
Build and Release / build (push) Successful in 20m11s
Details
Build and Release / build (push) Successful in 20m11s
Details
This commit is contained in:
parent
4e5682c6b1
commit
998157c3c9
|
|
@ -29,7 +29,7 @@ mod_name=whitelist
|
||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=All Rights Reserved
|
mod_license=All Rights Reserved
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
mod_version=0.1-BETA
|
mod_version=0.2-BETA
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||||
# This should match the base package used for the mod sources.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
|
|
|
||||||
|
|
@ -4,34 +4,18 @@ import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.server.players.PlayerList;
|
import net.minecraft.server.players.PlayerList;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
@Mixin(PlayerList.class)
|
@Mixin(PlayerList.class)
|
||||||
public class PlayerListMixin {
|
public abstract class PlayerListMixin {
|
||||||
|
|
||||||
/**
|
@Redirect(
|
||||||
* Suppress ALL player join/leave messages
|
method = "placeNewPlayer",
|
||||||
* Intercepts ALL calls to broadcastSystemMessage and filters out join/leave messages
|
at = @At(
|
||||||
*/
|
value = "INVOKE",
|
||||||
@ModifyArg(method = "*",
|
target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V"
|
||||||
at = @At(value = "INVOKE",
|
)
|
||||||
target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V"),
|
)
|
||||||
index = 0)
|
private void itqop$skipJoinBroadcast(PlayerList self, Component message, boolean bypassHiddenChat) {
|
||||||
private Component suppressJoinLeaveMessages(Component original) {
|
|
||||||
String messageString = original.getString();
|
|
||||||
|
|
||||||
// Check if this is a join or leave message
|
|
||||||
// Common patterns: "Player joined the game", "Player left the game"
|
|
||||||
// Russian: "Игрок присоединился к игре", "Игрок покинул игру"
|
|
||||||
if (messageString.contains("joined the game") ||
|
|
||||||
messageString.contains("left the game") ||
|
|
||||||
messageString.contains("присоединился") ||
|
|
||||||
messageString.contains("покинул")) {
|
|
||||||
// Return empty component to suppress the message
|
|
||||||
return Component.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
// For all other messages, return the original
|
|
||||||
return original;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package org.itqop.whitelist.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||||
|
import net.minecraft.server.players.PlayerList;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
@Mixin(ServerGamePacketListenerImpl.class)
|
||||||
|
public abstract class ServerGamePacketListenerMixin {
|
||||||
|
|
||||||
|
@Redirect(
|
||||||
|
method = "removePlayerFromWorld",
|
||||||
|
at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
private void itqop$skipLeaveBroadcast(PlayerList list, Component message, boolean overlay) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,7 +5,8 @@
|
||||||
"compatibilityLevel": "JAVA_21",
|
"compatibilityLevel": "JAVA_21",
|
||||||
"refmap": "whitelist.refmap.json",
|
"refmap": "whitelist.refmap.json",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"PlayerListMixin"
|
"PlayerListMixin",
|
||||||
|
"ServerGamePacketListenerMixin"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue