ProtocolLib

3M Downloads

ping.setFavicon(WrappedServerPing.CompressedImage image) wont show favicon on 1.19-1.20.1 servers.

NamerPRO opened this issue ยท 18 comments

commented
  • This issue is not solved in a development build

Describe the bug
Calling setFavicon method from WrappedServerPing class has no affect in changing server motd favicon.

Base64 string of favicon is generated here in getRandomFavicon method:
https://github.com/NamerPRO/AdvancedNMotd/blob/main/src/ru/namerpro/AdvancedNMotd/Templates/PluginMotdTemplate.java

Usage of setFavicon method could be found here:
https://github.com/NamerPRO/AdvancedNMotd/blob/main/src/ru/namerpro/AdvancedNMotd/Bukkit/ProtocolLibMotd.java
(line: ((WrappedServerPing) motdPingInstance).setFavicon(WrappedServerPing.CompressedImage.fromBase64Png(base64Favicon));)

To Reproduce
Steps to reproduce the behavior:

  1. Download AdvancedNMotd 10.0.1 (here: https://www.spigotmc.org/resources/advancednmotd-let-your-motd-smile.58677/).
  2. Start it on, for example, 1.18.2 server.
  3. See that favicon is displaying.
  4. Start AdvancedNMotd on 1.20.1 server.
  5. See that favicon is not displaying although code is the same.

Expected behavior
Expected to see displaying favicon in motd.

Screenshots
1.18.2:
1 18 2

1.20.1:
1 20 1

Version Info
https://pastebin.com/9kbt6tGb

Additional context
Thank you for the great work you had done developing ProtocolLIB.

commented

I already have this code

(https://github.com/NamerPRO/AdvancedNMotd/blob/main/src/ru/namerpro/AdvancedNMotd/Bukkit/ProtocolLibMotd.java)

    public void onPacketSending(final PacketEvent event) {
        try {
            WrappedServerPing ping = event.getPacket().getServerPings().read(0);
            template.setMotdPingInstance(ping);
            template.setAdvnacedNMotdMotd();
            event.getPacket().getServerPings().write(0, ping);
        } catch (Exception err) {
            Bukkit.getConsoleSender().sendMessage(PluginMessagesTemplate.couldNotSetMotd);
            err.printStackTrace();
        }
    }

Favicon is set like so:

((WrappedServerPing) motdPingInstance).setFavicon(WrappedServerPing.CompressedImage.fromBase64Png(base64Favicon));

But this does not work sadly :(
Is there anything else I can try to do?

commented

Please, respond to topic. If you need any additional information, I am open to provide it by your request. I understand you may have a lot of work. However, your help is required and is strongly appreciated.

commented

@lukalt, hello!

As far as I understand you are one of people who provide help with ProtocolLib. Currently, I am facing a problem, described above. However, I am afraid my issue could be missed since I got no replies for more than a week. This is the reason I am tagging you. If it's not a part of your responsibility to comment on this issue, passing it to right people would be higly appreciated by me.

I am sorry if I am mistaken with the fact you can provide help.
However, it is requiered now and any answer is very important to me.

commented

Hi,

sorry, that no one responded so far. I am not part of the ProtocolLib team but I can help you anyways.
I think the problem you described is the same as in #2354.
Please try to explicitly write the modified server ping back after modifying it as described in the linked issue.

commented

Hi,

sorry, that no one responded so far. I am not part of the ProtocolLib team but I can help you anyways. I think the problem you described is the same as in #2354. Please try to explicitly write the modified server ping back after modifying it as described in the linked issue.

Please, respond whether you are trying to solve my problem or there is something else I can do or if I should contact another people (mentioning whom is appreciated). Mentioned issue #2354 does describe the same problem.
However, its author confirmed problem was not solved:
img

commented

I currently do not have time to deeply investigate this. But please have a look at your Minecraft Client's Log file in der %appdata%/.minecraft folder and check if there are any errors

commented

I currently do not have time to deeply investigate this. But please have a look at your Minecraft Client's Log file in der %appdata%/.minecraft folder and check if there are any errors

I have this error:

[02:15:59] [Render thread/ERROR]: Invalid icon for server AdvancedNMotd (127.0.0.1:25565)
java.io.IOException: Could not load image: Image not of any known type, or corrupt
	at ehk.a(SourceFile:138) ~[1.20.1.jar:?]
	at ehk.a(SourceFile:111) ~[1.20.1.jar:?]
	at ehk.a(SourceFile:119) ~[1.20.1.jar:?]
	at exq$d.a(SourceFile:386) ~[1.20.1.jar:?]
	at exq$d.a(SourceFile:312) ~[1.20.1.jar:?]
	at epc.a(SourceFile:462) ~[1.20.1.jar:?]
	at epc.b(SourceFile:447) ~[1.20.1.jar:?]
	at epc.a(SourceFile:227) ~[1.20.1.jar:?]
	at exn.a(SourceFile:251) ~[1.20.1.jar:?]
	at euq.b(SourceFile:110) ~[1.20.1.jar:?]
	at fjq.a(SourceFile:945) ~[1.20.1.jar:?]
	at enn.f(SourceFile:1219) ~[1.20.1.jar:?]
	at enn.e(SourceFile:802) ~[1.20.1.jar:?]
	at net.minecraft.client.main.Main.main(SourceFile:250) ~[1.20.1.jar:?]

This does not appear when tested, for example, with 1.18.2 server.

commented

Okay, could you please share the base64 you are setting as the favicon?

commented

Okay, could you please share the base64 you are setting as the favicon?

Sure, here it is:

iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAACLxJREFUeJztWGlwFMcVnt6dnWtnb+2uDsQNQogrYA7bYGNHUAYRjBEOUDHoAAxSkBYkggXiRhDhmBiDTbADxKRiBxNwAi4nIZgUgSiUHQTCOIFYQuYQIMIh0Mmpl9ezQp5Z7cjL39R8VV9J2+97X795M909uwxjwIABAwYMGDBgwIABAwYMGDBgwIABAwZawTPEVGiSXDtNknsn4a3bGELW4Pg85ACdHBY5F7kiDEepdIORi5CFLVzSQvr/YmQBMouw/FY2qms16+1xi/X1bGB9CQ3KX2/328QibEINp5mdkDlmV/wljFN9I+tPaELeoTQ7Yq6E1PCdGCkkpTT7C/8FlL6CMvDmlYA78yMwyd5qjFvC5MSKAyeDb8Hnbch1fKIO48MUldmyxxv4G3jn/13xbOV8yiPgDRwC64jsh2x0b4hZWw0xxdchdt1NiH09yJjiayANmXaPNkk199Nc56H3o1d+E9Qr2ppWOidvhpbGRowC54/eh5jXa9tQGpIGOt30ScMywuZEzSsBwtv+g5oo5K7oNVfD6h7RMXEDWGL76sa9C0+A2dPlEnrZkHEm0XXcV/CVrt455Ze05sKIrx4f+z3e19CwuLYNPVkHqNkGKgtJs4oDfhg2h9I+4c1mYubeQd1Wb36pro7S8fIWYP2JEF18O2ycjttfXE/rWIVL5U05eXG7fs6p26l2aaTX72Jj+5X7i2og+qd1behfexvMjrhvaOdDE/leY+6Hy1Hy1tQAxmkhpfaXNoJ3UTn4V/43RHMLfMuqwP7SJrzD3Rr9q6+H9VK0RTfB7O7ShJ7t6iidU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AAQMGDBgwYMCAAQMGDBgwYMCAAQP/3/gfme7YvYIQ83wAAAAASUVORK5CYII=
commented

@dmulloy2, hello!

I am sorry to interruprt you. However, the solution to my problem has been taking a long time, no progress is visible, so it apparently requires your participation. I understand that we can all be busy. Since lukalt is currently unable to assist me, I am attempting to contact you. Please, see above. If you need any additional information, I am always open to provide it.

commented

@dmulloy2, hello!

I am sorry to interruprt you. However, the solution to my problem has been taking a long time, no progress is visible, so it apparently requires your participation. I understand that we can all be busy. Since lukalt is currently unable to assist me, I am attempting to contact you. Please, see above. If you need any additional information, I am always open to provide it.

@dmulloy2 @Ingrim4 @BradBot1, please see above and respond.

commented

Setting motd in event together with server icon will not help either since I need to set hover box and version motd with this motd together as well (and these stuff cannot be set via event, so I will still need to use ProtocolLib). I do not know whether Bukkit or ProtocolLib event will be called first. Even if I do there will be a problem of passing data (which motd configuration file was chosen) from one event to another one. Perhaps, you may take a look at this class: https://github.com/NamerPRO/AdvancedNMotd/blob/main/src/ru/namerpro/AdvancedNMotd/Templates/PluginMotdTemplate.java

Could you not just use the Bukkit implementation only for the favicons for now? This way you get what you want while this gets resolved?

I will have to abandon the feature described above. Lukalt also pointed me to an issue page describing same problem #2354 opened about 5 months ago that still was not solved. This is why I will be glad if you could take a look at it now.

commented

Why are you using ProtocolLib for this? The ServerListPingEvent from Bukkit should meet your needs
This method allows you to set the image that a player is sent

You would just need something like so:

/**
* Not set until needed, images are expensive!
*/
private static CachedServerIcon icon;

@EventHandler
public final void onServerPing(final ServerListPingEvent event) {
    if (image == null) {
        try {
            icon = Bukkit.getServer().loadServerIcon(ImageIO.read(new ByteArrayInputStream(Base64.getDecoder().decode("YOUR_BASE_64_GOES_HERE"))));
        } catch (IOException e) {
            return; // failed to parse the base64
        }
    }
    event.setServerIcon(icon);
}
commented

Why are you using ProtocolLib for this? The ServerListPingEvent from Bukkit should meet your needs This method allows you to set the image that a player is sent

You would just need something like so:

/**
* Not set until needed, images are expensive!
*/
private static CachedServerIcon icon;

@EventHandler
public final void onServerPing(final ServerListPingEvent event) {
    if (image == null) {
        try {
            icon = Bukkit.getServer().loadServerIcon(ImageIO.read(new ByteArrayInputStream(Base64.getDecoder().decode("YOUR_BASE_64_GOES_HERE"))));
        } catch (IOException e) {
            return; // failed to parse the base64
        }
    }
    event.setServerIcon(icon);
}

@BradBot1, Thank you for responding!

This will not help me since I need an option to specify concrete icons to be displayed in pair with concrete motd.
Configuration example:

Motd:

    # Text to be displayed in line 1 of your motd
    LineOne: 'format: c{&b&m~~~&r %#0ACFFE->#4463FE: AdvancedNMotd; &l% &7~&f sea adventure &b&m~~~&r}'

    # Text to be displayed in line 2 of your motd
    LineTwo: 'format: c{&7&n<&r %#A3A3A3->#EBEBEB: [ what a beauty ]; &o% &7&n>&r}'

    # Icons to take from icons folder in pair to this motd
    # (several icons are separated by commas; if any icon
    # can be selected, leave the field empty)
    Icons: 'icon1.png'

Setting motd in event together with server icon will not help either since I need to set hover box and version motd with this motd together as well (and these stuff cannot be set via event, so I will still need to use ProtocolLib). I do not know whether Bukkit or ProtocolLib event will be called first. Even if I do there will be a problem of passing data (which motd configuration file was chosen) from one event to another one.
Perhaps, you may take a look at this class:
https://github.com/NamerPRO/AdvancedNMotd/blob/main/src/ru/namerpro/AdvancedNMotd/Templates/PluginMotdTemplate.java

commented

Setting motd in event together with server icon will not help either since I need to set hover box and version motd with this motd together as well (and these stuff cannot be set via event, so I will still need to use ProtocolLib). I do not know whether Bukkit or ProtocolLib event will be called first. Even if I do there will be a problem of passing data (which motd configuration file was chosen) from one event to another one. Perhaps, you may take a look at this class: https://github.com/NamerPRO/AdvancedNMotd/blob/main/src/ru/namerpro/AdvancedNMotd/Templates/PluginMotdTemplate.java

Could you not just use the Bukkit implementation only for the favicons for now? This way you get what you want while this gets resolved?

commented

Before I continue I want to make clear that ProtocolLib is an open source project. It is based on work done by people during their free time. So you cannot expect an enterprise grade support here...
As I am super busy at the moment, I did not have time to debug this closely.
Today, I was able to narrow the problem down and implement a fix, please validate if this build fixes the problem: https://github.com/lukalt/ProtocolLib/suites/16100238960/artifacts/919148113.

commented

Before I continue I want to make clear that ProtocolLib is an open source project. It is based on work done by people during their free time. So you cannot expect an enterprise grade support here... As I am super busy at the moment, I did not have time to debug this closely. Today, I was able to narrow the problem down and implement a fix, please validate if this build fixes the problem: https://github.com/lukalt/ProtocolLib/suites/16100238960/artifacts/919148113.

Having not received a response from you for a long time, a fear occured that you might have forgotten about my problem. Regardless of the misunderstanding that arose between us, I express my gratitude to you for your help. Fix solves the problem I described. I truly appreciate the work you do and the time you spend to make ProtocolLib better, knowing that you generally don't have to spend it.

commented

Okay, thank you for the confirmation. I will open a pull request for this problem so it will be available in the next release of ProtocolLib