[enhancement] Serialize and parse color codes, hex codes from placeholders
LcorpOfficial opened this issue ยท 21 comments
Thanks for the suggestion! I've split this in two:
- fix: remove formatting codes
- feature: use formatting codes to display colours
The fix is available now already in version 1.7.2, the feature will have to wait until the next major release
wonderful! that's gonna make this much nicer already!
I'm now working on converting the formatting codes. Where does the format from your screenshot come from? Could you link me to some documentation maybe?
It can come from either legacy &
codes, from adventure Minimessage, or via the &#xxxxxx
method usually. there is also the &x
method comes from the plugin EssentialsX and sometimes others that use MiniMessage, but idk what library they use, unfortunately.
Thanks! I think I have all colour and formatting codes working correctly now. If you want, you can check first if it all works on your server before I mark the feature as done and merge it. It should be as easy as putting these files in the correct location:
- https://github.com/Dantevg/WebStats/blob/eab325983b8117fb79352c9177bf2e32103f975f/web/WebStats-dist.js
- https://github.com/Dantevg/WebStats/blob/eab325983b8117fb79352c9177bf2e32103f975f/web/example/style.css
If you use the internal web server, you can put them in plugins/WebStats/resources/WebStats-dist.js
and plugins/WebStats/resources/style.css
(create folder if it does not exist. These files do not get updated when you update the plugin so remember to remove them when you update the plugin)
Actually, it does seem to hide the colors' codes but the style isn't being applied for the colors. hmmmmmmm.
There must be something wrong with the js file. Did you try hard-reloading (with ctrl+shift+r or ctrl+f5)?
EDIT: you can check if the right js file is active by seeing if entering webstats.display.constructor.convertFormattingCodes
in the browser console gives a value
ah I'll give it a try in the morning then! good point.
Hi, did you get around to trying what I suggested?
No worries, I'm not in a hurry ๐
The new js file is not being served properly. It looks like you're using the internal web server, maybe you didn't place it in the correct location? (plugins/WebStats/resources/WebStats-dist.js
)
Are you using version 1.7.2? Maybe you can try re-downloading the latest version: https://github.com/Dantevg/WebStats/releases/download/v1.7.2/WebStats-1.7.2.jar.
Otherwise, the only thing I can think of is that you may have saved the file as .js.txt
? (Simple, yes, but who knows?)
Another way to check if the js file is being served is by going to ip:port/WebStats-dist.js
and searching for convertFormattingCodes
. Changing the js file should be directly visible there, no need to reload the plugin or server.
Update: reboot to server did not change, it seems internal webserver doesn't accept the files. I'll try to also run a standalone
Oh I see it, it's case-sensitive so it has to be WebStats-dist.js
(I now realise I could better have kept it all lowercase)
hahaha, either way, I noticed that on local. upon running a local server I get this in console
EDIT this is present when getting the js to load on internal server as well
Uncaught TypeError TypeError: Cannot read properties of undefined (reading 'colour')
at parseFormattingCode (x:\inetpub\wwwroot\audio\webstats-dist.js:419:18)
at parseFormattingCodes (x:\inetpub\wwwroot\audio\webstats-dist.js:400:23)
at convertFormattingCodes (x:\inetpub\wwwroot\audio\webstats-dist.js:372:11)
at updateScoreboard (x:\inetpub\wwwroot\audio\webstats-dist.js:286:26)
at updateStats (x:\inetpub\wwwroot\audio\webstats-dist.js:309:8)
at init (x:\inetpub\wwwroot\audio\webstats-dist.js:186:8)
at init (x:\inetpub\wwwroot\audio\webstats-dist.js:553:16)
at <anonymous> (x:\inetpub\wwwroot\audio\webstats-dist.js:519:48)
--- Promise.then ---
at WebStats (x:\inetpub\wwwroot\audio\webstats-dist.js:519:30)
at <anonymous> (x:\inetpub\wwwroot\audio\index.html:15:18)
--- load ---
at <anonymous> (x:\inetpub\wwwroot\audio\index.html:14:10)
seems to be that undefined lines in the map could cause the script to crash?
Whoops, I didn't test it on strings starting with a formatting code. Should be fixed in https://github.com/Dantevg/WebStats/blob/397995b490a7493a7cf6d1b55558a7351950b6b7/web/WebStats-dist.js ๐ณ
Whew, nice. Looking good!
yessir! time to finally get started on the API interface for the profile page lookup system, whenever I find the time