Chat Heads compat#297
Conversation
|
thanks for the PR! i'm gonna do some testing before i decide how to proceed with this. if you could provide some of your test messages so we can compare outputs that'd be great and i can of course send results afterward. my concerns are:
tl;dr: aside from generally wanting to stray away from overcomplication, i need to make sure that messages with multiple or incorrect heads should even be reconstructed in the first place. (maybe that's why you couldn't trigger the reconstruction branch - although it could be that the custom playername format is off or the player who is supposedly sending the message is not real.) |
Oh, those are gone, I constructed messages in code like in various forms of indentation, moving the head to different places etc, logging the
Wait, with "should it be modifying the message period," you mean the question is whether it should do the whole message reformatting thing, aka run this block at all - did I get this right? If so, I guess it just depends on whether you want to or not. Currently messages with heads by their name do match Theoretically you could just say "frick it" and disallow reformatting of anything other an exact vanilla format, disallowing handling of messages with chat heads. This could be done by changing the regex to match only possible usernames in between If you go this route, you could throw the whole compatibility thing out, on the cost of not being able to reformat those messages.
They are vanilla in the sense that the vanilla client will happily accept it.
We're talking about
You mean
At least one issue I see with this is that the playername of the head need not match the playername of the, uh, player. Other than that, I just don't like working with strings when it's really components, it feels inexact to me, but that may just be the random server BS PTSD I got from working on Chat Heads.
Just checked, it was because I had a nickname, without it, it does hit the branch. And uhh... it worked that one time, but that other time it did not? |
|
Oops, the recursion ended too early when it got too deep. |
okay perf 👍
yes exactly.
yeah that makes this kind of difficult as you've explained and go on to explain...
yeah that's what makes this tricky: i want to support Chat Heads compatibility, but i don't want to implement an entire parser just because servers could send heads.
bc if it's not something a vanilla server would send then chat patches shouldn't reconstruct the message - it shouldn't matter whether the chat format is as vanilla-like as
yes that should also be valid for Chat Patches. again, because the format isn't vanilla's
i totally understand that, it's appalling how insane minecraft text can drive you lmao. but here i think it would make sense bc if the check is false, we should exit early and not modify anything, so the parsing wouldn't even be necessary. -
sorry i'm not sure what you're talking about here.. are you saying the original message formatting/style was stripped? also just a heads up my free time has dried up again so i'll take a bit longer to respond. |
…the head in the latter case
|
I rewrote the thing, here's what is does now: I wrote a regex matching "playername" or "[playername head]playername":
The latter is using a backreference to ensure the names are the same. Plugging that in the original With that, one can simply check whether the backreference aka group 4 exists to see if the head is by the playername and extract it with the original form of |
yay i'm glad! i realize it's quite convoluted so thanks for sticking with me lol.
yeah it should keep the red styling because although the style is different the text still abides by the format, so this is an issue. if it hasn't magically gone away, would you mind toggling "log message structures" in the help section of Chat Patches' config and sending me what it says after you send a message on that server? i'd really appreciate it 😄 thanks! (definitely turn it off after though it will bloat the logs like crazy.)
thank you so much for doing all of this - i really really appreciate it. if it lets me i'll make a couple nitpicky changes, but i think you pretty much nailed it. my only concern with the backreference and |
Oh yeah, that breaks it. 😰 The prefixes and suffixes can literally be anything, including spaces, "<>", "[]", head components etc, so in general you could only match them with This is unsolvable in regex alone. Actually, after looking around for a bit, in the case of system messages (so any server with FreedomChat/No Chat Reports, also EssentialsX) you're already assuming I was originally gonna also suggest this "solution":
But that assumes you already know the player name, which works for player messages but not for system messages as we just saw. So I think a "tight" regex is probably the best compromise so I commited that for now.
Not sure if it's actually helpful since this gives the info after the message has already been modified, i.e. in The issue is actually pretty clear: P.S. |
|
thanks for looking into all that! i trust your judgement but i'll do a few regex tests of my own and log them just to make sure, and for future reference. hopefully i can approve this within the week! also, thanks for attaching the log snippet, i appreciate it. i have no clue how that message doesn't look entirely broken, from my reading it looks like it should say "[12:27:29] test> test" but good to know regardless. yes, it should color the messages, i didn't pass the style bc i assumed all the coloring would come from the name itself but assumptions are the bane of robust code so i'll have to get on that lmao. and about the chat log, those options clear the internal log and not the actual chat history you see on the hud - good ol' vanilla F3 + D will take care of that for ya! i'll have to add a note about that though, it's definitely confused people (including myself) before lol |
No, I mean even after a restart the history is still there! |
Aha, the history does get cleared but it only saves it to the file if another message is added! |
|
final thoughts post merge - following the thinking outlined a few comments up, to sidestep some unavoidable issues with team pre/suf-fixes, what if i kept both the updated regex and a new version of the old one? when chat heads is installed i'd use the one you made, otherwise it uses basically the old one but with some tweaks pulled from the new. in theory at least this should prevent issues with vanilla team messages being seemingly unmodifiable, and it "carves out" an exception for Chat Heads without totally wrecking the regex. additionally, if a vanilla team message can't be formatted with both mods installed, there would literally be no way to fix it without writing some gnarly library to fix it (imho) - so it's kind of intentional (wontfix). it is almost 2am for me so maybe i'm off my rocker but lmk if i'm missing anything. thanks again for all your help 🙏 🫡 |
Depends on what tweaks you'd want to pull.
Yeah, I was thinking too, this whole ordeal is mostly fixable, but only by writing a system akin to what Chat Heads uses, collecting data (playernames, team names/prefixes/suffixes etc), then trying to parse/match the message with the known data. |



As mentioned here.
Instead of passing the whole message to
formatPlayername(), only an (optional) head component is passed.In the translatable case is only searches for a head in the sender part and in the non-translatable case it stops searching for a head once a '>' is found.
I removed the
if(/*ChatHeadsIntegration.*/installed() && usingBeforeName())check since this is not Chat Heads specific, as servers can add head components in the name part as well.Technically,
extractHeadComponent()thus shouldn't really be part ofChatHeadsIntegration.Actually, the whole class can be nuked I just realized, I'll leave that up to you.
I added "chat.type.text" translatable handling to
extractHeadComponentso it aborts early when it encounters it as well - I don't think it's actually needed but I thought might as well. (Left out the "chat.type.team.*" ones though.)A bit concerning but I couldn't get the whole vanilla branch to trigger on my test EssentialsX server (even though the chat is of the form
<name> message). Not sure what's up with that.Ended up doing some manual tests via code.
P.S.
I feel this could have taken an hour less if it weren't for Modstitch/Stonecutter or whatever the multiversion build thing is, took some time to figure it out. 😅
(
org.gradle.jvmargs=-Xmx2Gis also too little and Gradle ran OOM a few times.)