|
2 | 2 |
|
3 | 3 | import java.util.HashSet; |
4 | 4 | import java.util.UUID; |
5 | | -import com.google.gson.Gson; |
6 | | -import com.mojang.serialization.JsonOps; |
7 | 5 | import net.evmodder.EvLib.util.Command; |
8 | 6 | import net.evmodder.EvLib.util.FileIO; |
9 | 7 | import net.evmodder.EvLib.util.PacketHelper; |
|
17 | 15 | import net.minecraft.client.MinecraftClient; |
18 | 16 | import net.minecraft.client.network.PlayerListEntry; |
19 | 17 | 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; |
21 | 25 |
|
22 | 26 | public final class GameMessageListener{ |
23 | 27 | private final void saveMyIgnores(final UUID myUUID, final UUID ignoredUUID, final boolean ignored){ |
@@ -69,11 +73,20 @@ public GameMessageListener(RemoteServerSender rms, EpearlLookupFabric epl, Whisp |
69 | 73 |
|
70 | 74 | ClientReceiveMessageEvents.GAME.register((msg, overlay) -> { |
71 | 75 | 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 | + |
74 | 87 | final String literal = msg.getString(); |
75 | 88 | 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); |
77 | 90 |
|
78 | 91 | if(literal.matches("^\\w+ whispers: .*")){// TODO: per-server format support |
79 | 92 | // Main.LOGGER.info("GameMsgListener: whisper detected"); |
|
0 commit comments