ProtocolLib

3M Downloads

ProtocolLib 1.17 ScoreboardTeams

Ste3et opened this issue ยท 14 comments

commented

I think the Protocollib use the wrong PacketPlayOutScoreboardTeam Class for the PacketType.Play.Server.SCOREBOARD_TEAM
Object.
On my Test Server for 1.17 i receive these kind of exception:

https://hastebin.com/duzevaviyo.apache

as i have debug the PacketType i figure out that ProtocolLib use that NMS Class:

PacketContainer[type=SCOREBOARD_TEAM[class=PacketPlayOutScoreboardTeam, id=85], structureModifier=StructureModifier[fieldType=class java.lang.Object, data=[private final int net.minecraft.network.protocol.game.PacketPlayOutScoreboardTeam.h, private final java.lang.String net.minecraft.network.protocol.game.PacketPlayOutScoreboardTeam.i, private final java.util.Collection net.minecraft.network.protocol.game.PacketPlayOutScoreboardTeam.j, private final java.util.Optional net.minecraft.network.protocol.game.PacketPlayOutScoreboardTeam.k]]]

It is the internal NMS Class net.minecraft.network.protocol.game.PacketPlayOutScoreboardTeam but it should use the class net.minecraft.network.protocol.game.PacketPlayOutScoreboardTeam$b

These is the WrapperClass that i work with

https://hastebin.com/zeqekiceso.php

My Test Enviroment:
Paper 1.17 first experimentel build (i didn't have the time to test it on an normal Spigot Server)
ProtocolLib build #510

Best regrads and thank you for your hard work:
Ste3et_C0st

commented

Can confirm. Mojang put an Optional into the class which holds the additional team information (such as the display name). If the mode is 0 (create) or 2 (update) it is present

commented

Good catch. I'll try to fix this today

commented

@Ste3et latest dev build should fix this

commented

@dmulloy2 still having the same issue using ProtocolLib build #520. https://hastebin.com/uzuzoseruj

/protocol version output:

ProtocolLib v4.7.0-SNAPSHOT-b520
Authors: dmulloy2 and Comphenix
Issues: https://github.com/dmulloy2/ProtocolLib/issues

Also using Paper 1.17:
This server is running Paper version git-Paper-"33d6b6f" (MC: 1.17) (Implementing API version 1.17-R0.1-SNAPSHOT)

commented

@Ste3et latest dev build should fix this

Thank you for your effort,
Id look into your commit 583ed4b it looks fine, but the error is still present sorry about that.
Please didn't understand me wrong, i can change the wrapper methods to work with an Bukkit Team but if i do that then the teams are real registred to the server and i can't give players two teams at the same time.
My exception is that: https://hastebin.com/etiwinegun.sql

And the exception debug is that:
[20:39:43] [Server thread/INFO]: PacketContainer[type=SCOREBOARD_TEAM[class=PacketPlayOutScoreboardTeam, id=85], structureModifier=StructureModifier[fieldType=class java.lang.Object, data=[private final int net.minecraft.network.protocol.game.PacketPlayOutScoreboardTeam.h, private final java.lang.String net.minecraft.network.protocol.game.PacketPlayOutScoreboardTeam.i, private final java.util.Collection net.minecraft.network.protocol.game.PacketPlayOutScoreboardTeam.j, private final java.util.Optional net.minecraft.network.protocol.game.PacketPlayOutScoreboardTeam.k]]]

Looks like the PacketType use PacketPlayOutScoreboardTeam again and not PacketPlayOutScoreboardTeam$b

Best regrads,
Ste3et_C0st

commented

Looking at this a little closer, it looks like PacketPlayOutScoreboardTeam is the right packet, but that the useful data is stored in the inner class b. I had an interesting idea though that might be worth trying out:

PacketContainer container = new PacketContainer(PacketType.Play.Server.SCOREBOARD_TEAM);
Optional<InternalStructure> optStruct = container.getOptionalStructures().read(0);
assertTrue(optStruct.isPresent());
InternalStructure struct = optStruct.get();
struct.getChatComponents().write(0, WrappedChatComponent.fromText("hi there")); // displayName
container.getOptionalStructures().write(0, Optional.of(struct));

I drafted the backing code for this and it seems to be a decent proof of concept. Basically it leverages the already existing conversion methods that were in PacketContainer to easily modify internal classes like this. Let me know what y'all think

commented

Though not probably the same, this issue I am having on latest Paper 1.17 when using LibsDisguises might be related:

https://pastebin.com/FFaecuhM

Or should I create a separate issue for that?

commented

Looking at this a little closer, it looks like PacketPlayOutScoreboardTeam is the right packet, but that the useful data is stored in the inner class b. I had an interesting idea though that might be worth trying out:

PacketContainer container = new PacketContainer(PacketType.Play.Server.SCOREBOARD_TEAM);
Optional<InternalStructure> optStruct = container.getOptionalStructures().read(0);
assertTrue(optStruct.isPresent());
InternalStructure struct = optStruct.get();
struct.getChatComponents().write(0, WrappedChatComponent.fromText("hi there")); // displayName
container.getOptionalStructures().write(0, Optional.of(struct));

I drafted the backing code for this and it seems to be a decent proof of concept. Basically it leverages the already existing conversion methods that were in PacketContainer to easily modify internal classes like this. Let me know what y'all think

Sounds for a very good solution for me ๐Ÿ‘

commented

@dawon looks like the same issue

commented

@Ste3et the new API (same usage as above) should be available on both Jenkins and the repo

commented

Thank you @dmulloy2 I want to look into it tommorrow, atm I only want to sleep, I have an Travel behind me of 3000km.

commented

I think it can be marked as close here is my code with the new ProtocolLib build.

https://gist.github.com/Ste3et/b66c7f6e2b6e98f8d6853c50f0bcb44f

That is the current protocol specification https://wiki.vg/Protocol#Teams
There is only a problem what should i fixed by myself the scoreboard is looking like that at the moment

Minecraft 1.17:
https://i.imgur.com/ZMsH4fJ.jpg

Minecraft 1.1.6:
https://i.imgur.com/LyNXdRc.png

I need to make some resarch work to figure out my problem.
Thank you for work @dmulloy2

best regrads,
Ste3et_C0st

commented

Ok i figured out for everyone who has the same problem, every IChatBaseComponent must be filled with an empty string if they isn't use by urself

commented

@Ste3et that would probably be a good thing to add to sendPacket in that wrapper