Skip to content

Commit a986e8d

Browse files
committed
(currently disabled) in-chat mention detection
1 parent f959448 commit a986e8d

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

src/main/java/net/evmodder/evmod/listeners/GameMessageListener.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import java.util.HashSet;
44
import java.util.UUID;
5-
import com.google.gson.Gson;
6-
import com.mojang.serialization.JsonOps;
75
import net.evmodder.EvLib.util.Command;
86
import net.evmodder.EvLib.util.FileIO;
97
import net.evmodder.EvLib.util.PacketHelper;
@@ -17,7 +15,13 @@
1715
import net.minecraft.client.MinecraftClient;
1816
import net.minecraft.client.network.PlayerListEntry;
1917
import net.minecraft.text.Text;
20-
import net.minecraft.text.TextCodecs;
18+
19+
//import net.minecraft.registry.RegistryOps;
20+
//import net.minecraft.registry.RegistryWrapper;
21+
//import net.minecraft.text.TextCodecs;
22+
//import com.google.gson.Gson;
23+
//import com.google.gson.JsonElement;
24+
//import com.mojang.serialization.JsonOps;
2125

2226
public final class GameMessageListener{
2327
private final void saveMyIgnores(final UUID myUUID, final UUID ignoredUUID, final boolean ignored){
@@ -69,11 +73,20 @@ public GameMessageListener(RemoteServerSender rms, EpearlLookupFabric epl, Whisp
6973

7074
ClientReceiveMessageEvents.GAME.register((msg, overlay) -> {
7175
if(overlay) return;
72-
final String json = new Gson().toJson(TextCodecs.CODEC.encodeStart(JsonOps.INSTANCE, msg).getOrThrow());
73-
if(json.contains("EvModder")) Main.LOGGER.info("GameMsgListener: EvModder mentioned (json):\n"+json);
76+
77+
// //========== TODO: remove this
78+
// final String myName = MinecraftClient.getInstance().getSession().getUsername();
79+
// try{
80+
// final RegistryWrapper.WrapperLookup lookup = MinecraftClient.getInstance().world.getRegistryManager();
81+
// final RegistryOps<JsonElement> ops = lookup.getOps(JsonOps.INSTANCE);
82+
// final String json = new Gson().toJson(TextCodecs.CODEC.encodeStart(ops, msg).getOrThrow(err -> new IllegalStateException("Failed to encode: " + err)));
83+
// if(json.contains(myName)) Main.LOGGER.info("GameMsgListener: Account mentioned!:\n"+json);
84+
// }catch(Exception e){e.printStackTrace();}
85+
// //==========
86+
7487
final String literal = msg.getString();
7588
if(literal == null) return;
76-
if(literal.contains("EvModder")) Main.LOGGER.info("GameMsgListener: EvModder mentioned (literal):\n"+literal);
89+
// if(literal.contains(myName)) Main.LOGGER.info("GameMsgListener: Account mentioned (literal):\n"+literal);
7790

7891
if(literal.matches("^\\w+ whispers: .*")){// TODO: per-server format support
7992
// Main.LOGGER.info("GameMsgListener: whisper detected");

0 commit comments

Comments
 (0)