ProtocolLib

3M Downloads

List converter not compatible with singleton lists

games647 opened this issue ยท 4 comments

commented

Original ticket at: games647/ChangeSkin#227

Describe the bug
List converter at

Constructor<?> ctor = listClass.getConstructor();

cannot find available constructors for singleton lists, because there are no empty constructors.

To Reproduce
Steps to reproduce the behavior:

            removeInfo = new PacketContainer(PLAYER_INFO);
            removeInfo.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER);
            removeInfo.getPlayerInfoDataLists().write(0, Collections.singletonList(playerInfoData));

Error
https://pastebin.com/vyYt4j8x

Should singleton lists be forbidden or is it just an bug? Earlier < 4.7 seemed to work fine. Potential problematic commit: 153dd61.

commented

Few questions:

  1. The paste is no longer accesible. Is it by any chance something similar to this? https://paste.helpch.at/ufufixugox.md
  2. Does the commit 4c0c18d "fix" this issue or will plugins still need to apply a workaround?
    My guess is the later because I encounter those exact issues here with a plugin while using latest dev build.
commented

@Andre601

  1. It appears so
  2. It was only a debug message. If ProtocolLib fails to create the list object it will fallback to create a new ArrayList instead. At this step the exception got printed. No changes are required here, because of the fallback. However, by passing an already working type, you don't have the overhead of the exception.
commented

Yeah that's just a debug message I accidentally left in. You should be good to keep using it, but fwiw I would recommend using an array list instead because it'll be slightly more efficient. There's not going to be any functional difference

commented

Thanks for the information. Then I'm going to use an ArrayList from now on.