festino-mc-plugins / ClickableLinks

Return clickable links to minecraft chat
MIT License
1 stars 0 forks source link

plugin messes with hex colors #2

Closed GitNether closed 8 months ago

GitNether commented 9 months ago

image_2024-03-06_045156959

I've used this code in my server to translate hex codes, maybe you are able to reuse it. Then we'd be able to use your plugin again :)

public String translateHexColorCodes(String startTag, String endTag, String message)
    {
        final Pattern hexPattern = Pattern.compile(startTag + "([A-Fa-f0-9]{6})" + endTag);
        Matcher matcher = hexPattern.matcher(message);
        StringBuffer buffer = new StringBuffer(message.length() + 4 * 8);
        while (matcher.find())
        {
            String group = matcher.group(1);
            matcher.appendReplacement(buffer, COLOR_CHAR + "x"
                    + COLOR_CHAR + group.charAt(0) + COLOR_CHAR + group.charAt(1)
                    + COLOR_CHAR + group.charAt(2) + COLOR_CHAR + group.charAt(3)
                    + COLOR_CHAR + group.charAt(4) + COLOR_CHAR + group.charAt(5)
            );
        }
        return matcher.appendTail(buffer).toString();
    }
festino commented 8 months ago

Could you please tell me which color chat plugin you are using so I can easily reproduce?

GitNether commented 8 months ago

We're using EssentialsX.

Also, if you have a colored message, the link resets the color, and the message after it turns white. Maybe there is an easy way around that, just wanted to mention it.

GitNether commented 8 months ago

Another idea I had, which would probably be fairly easy to add since you already have the structure going on:

If there is a command in the message such as ./cmd or /cmd, you could make that clickable aswell to execute the command directly. Arguments could be added using smth like /cmd_arg1_arg2 to prevent it to interfere with the sentence (just as an idea I had).

festino commented 8 months ago

As a player with an underscore in my nickname, I would prefer not to use "_". The idea itself is not bad, you can open a feature request. =)

festino commented 8 months ago

Update: there was an incorrect assumption that color characters can only be in the format string. I need to implement style preserversion, so the fix will take some more time.

festino commented 8 months ago

I believe I fixed it with ac9fe05, but I will test it properly before releasing.

GitNether commented 8 months ago

If you release it, I'll test it on our server :)

festino commented 8 months ago

I have published a fix in the new release: https://github.com/festino-mc-plugins/ClickableLinks/releases/tag/v1.2.0 Check if the issue is gone. =)

GitNether commented 8 months ago

Hmmm.. seems like something else is still messing with the colors image

festino commented 8 months ago

Ohhh I think I have added hex support for messages but not for nicknames 😅 Fortunately, now it’s easy to add this too.

festino commented 8 months ago

I believe it is fixed now https://github.com/festino-mc-plugins/ClickableLinks/releases/tag/v1.2.1 (I should request more information to reproduce, in the future) UPD. Will fix prefixes and postfixes soon

GitNether commented 8 months ago

Bad news image

festino commented 8 months ago

Sorry for release flooding https://github.com/festino-mc-plugins/ClickableLinks/releases/tag/v1.2.2

GitNether commented 8 months ago

Colors work! :D image

but bold is gone :o

GitNether commented 8 months ago

image Also a funny bug

festino commented 8 months ago

Could you tell if any formatting (bold, etc) is currently working anywhere with the plugin?

GitNether commented 8 months ago

In the message it works image

GitNether commented 8 months ago

any formatting turns purple though ^ i didnt put any color

festino commented 8 months ago

Oh, I see. Color codes should be inserted before formatting codes

festino commented 8 months ago

image Also a funny bug

I don't understand what is going on. When I send "&4hello google.com 12345", extra "4" does not appear

festino commented 8 months ago

I have updated v1.2.2 jar, formatting is fixed https://github.com/festino-mc-plugins/ClickableLinks/releases/tag/v1.2.2

GitNether commented 8 months ago

Still no bold on my end, weirdly enough

festino commented 8 months ago

Could you temporarily enable "/links log-debug-info true" and copy-paste raw JSON of the message?

GitNether commented 8 months ago

&4 1234 google.com 1234 produced these two:

16.03 15:36:56 [Server] [INFO] [ClickableLinks] Sending raw JSON: [{"color":"#8701ff","text":"<"},{"color":"#fbf896","text":"★"},{"color":"#9062fe","text":"I"},{"color":"#aa87f7","text":"X"},{"color":"#fbf895","text":"★"},{"color":"#8701ff","text":"> "},{"color":"#FF0000","text":"["},{"color":"#E70505","text":"A"},{"color":"#CF0909","text":"D"},{"color":"#B70E0E","text":"M"},{"color":"#9F1313","text":"I"},{"color":"#871717","text":"N"},{"color":"#6F1C1C","text":"] "},{"color":"#fdfbff","text":"["},{"color":"#bf6bff","text":"I Voted✔"},{"color":"#fdfbff","text":"] "},{"color":"#240000","text":"N"},{"color":"#480000","text":"e"},{"color":"#6d0000","text":"t"},{"color":"#910000","text":"h"},{"color":"#b60000","text":"e"},{"color":"#da0000","text":"r"},{"color":"#fe0000","text":". "},{"text":"§7➣"},{"text":"§f "},[{"text":"§41234 "},{"text":"§4§ngoogle.com","clickEvent":{"action":"open_url","value":"https://google.com"}},{"text":"§4 1234"}]] 16.03 15:36:56 [Server] [INFO] [ClickableLinks] Sending raw JSON: [{"color":"#8701ff","text":"<"},{"color":"#fbf896","text":"★"},{"color":"#9062fe","text":"I"},{"color":"#aa87f7","text":"X"},{"color":"#fbf895","text":"★"},{"color":"#8701ff","text":"> "},{"color":"#FF0000","text":"["},{"color":"#E70505","text":"A"},{"color":"#CF0909","text":"D"},{"color":"#B70E0E","text":"M"},{"color":"#9F1313","text":"I"},{"color":"#871717","text":"N"},{"color":"#6F1C1C","text":"] "},{"color":"#fdfbff","text":"["},{"color":"#bf6bff","text":"I Voted✔"},{"color":"#fdfbff","text":"] "},{"color":"#240000","text":"N"},{"color":"#480000","text":"e"},{"color":"#6d0000","text":"t"},{"color":"#910000","text":"h"},{"color":"#b60000","text":"e"},{"color":"#da0000","text":"r"},{"color":"#fe0000","text":". "},{"text":"§7➣"},{"text":"§f "},[{"text":"§41234 "},{"text":"§4§ngoogle.com","clickEvent":{"action":"open_url","value":"https://google.com"}},{"text":"§4 1234"}]]

festino commented 8 months ago

Yeah, this is weird. Not a single bold code "§l" Also, is it still "hello google.com4 12345" in the chat?

GitNether commented 8 months ago

Yep, still the extra 4 and wrong colouring weirdly enough image

festino commented 8 months ago

I will try to reproduce and fix it tomorrow

festino commented 8 months ago

I found another bug: the first style after any hex color was disappearing. I believe that is why bold was gone As before, I updated .jar: https://github.com/festino-mc-plugins/ClickableLinks/releases/tag/v1.2.2

GitNether commented 8 months ago

Color still buggy, but Bold works! :D image

festino commented 8 months ago

Can you give me a minimal reproducible example? I could not reproduce the color bug Also, are you using Spigot or some other server core?

GitNether commented 8 months ago

Yes, Spigot. It seems like it only happens if there is a number after the link image

festino commented 8 months ago

I couldn't come up with a message format that would reproduce "extra 4" bug, but I did reproduce the color bug. I hope it is fixed now: https://github.com/festino-mc-plugins/ClickableLinks/releases/tag/v1.2.2

GitNether commented 8 months ago

image Weirdly still happens. The link resets the color, but only if theres numbers directly after, which is weird. image

GitNether commented 8 months ago

Other than that it's looking fine, so thank you!

GitNether commented 8 months ago

Oh i just found this funny bug! Might help image

GitNether commented 8 months ago

seems like the ampersand & is missing.

festino commented 8 months ago

Again, I couldn't reproduce this. For the latest bug fixes I used (/plugins/Essentials/config.yml): format: '&r&#00FF00&l<&7&l<&r<{DISPLAYNAME}&r&l&#00FF00>&l&7>&r> &3{MESSAGE}' I would like to get your format or minimal reproducible example to fix this

GitNether commented 8 months ago

Our current format: '{PREFIX} {deluxetags_tag} &r{NICKNAME} &7➣&f {MESSAGE}'

festino commented 8 months ago

format: '{PREFIX} &r{DISPLAYNAME} &7➣&f {MESSAGE}' T-T image My configuration:

GitNether commented 8 months ago

That's so weird lol image EssentialsX and Chat 2.20.1

We're using Paper, but thats fundamentally Spigot too.

festino commented 8 months ago

I have no idea how can it be. I set up a server from scratch: Paper-196 EssentialsX and Chat 2.20.1 ClickableLinks 1.2.2 +used vanilla 1.20.1 client with default settings. I gave myself an op to get color permission.

Neither the default format nor '{PREFIX} &r{DISPLAYNAME} &7➣&f {MESSAGE}' could reproduce the bug

GitNether commented 8 months ago

Damn that's really weird. Some other plugin then must interfere with it, I suppose. Well, the main issue is fixed, and links are working properly now, so thank you for that and we can close this ticket finally!

festino commented 8 months ago

Ok. But I just want to polish the plugin: if you find any clues, then open a new ticket :)