ProtocolLib

3M Downloads

Paper Component outdated

Galajus opened this issue ยท 1 comments

commented

Describe the bug
I cant get Component.text from Objective send packet

To Reproduce
Steps to reproduce the behavior:

Code causing error:
Component component = (Component) packet.getModifier().read(1);

I'm trying too with TextComponent and ScoreComponent

Whole method:

this.protocolManager.addPacketListener
                (new PacketAdapter(galajus.getPlugin(), ListenerPriority.NORMAL, PacketType.Play.Server.SCOREBOARD_OBJECTIVE) {

            @Override
            public void onPacketSending(PacketEvent e) {
                if (e.getPacketType() != PacketType.Play.Server.SCOREBOARD_OBJECTIVE) return;
                Player p = e.getPlayer();
                PacketContainer packet = e.getPacket();
                HelpGalajus.infoLogToConsole(packet.toString());



                HelpGalajus.infoLogToConsole(packet.getStrings().read(0));
                try {
                    Component component = (Component) packet.getModifier().read(1);
                    HelpGalajus.infoLogToConsole(component.toString()); //log to console
                } catch (ClassCastException ex) {
                    ex.printStackTrace();
                }
            }
        });
        ```
        
        Error:
        ```
        [14:26:26 WARN]: java.lang.ClassCastException: class io.papermc.paper.adventure.AdventureComponent cannot be cast to class net.kyori.adventure.text.ScoreComponent (io.papermc.paper.adventure.AdventureComponent and net.kyori.adventure.text.ScoreComponent are in unnamed module of loader 'app')
[14:26:26 WARN]:        at galajus-1.9.jar//pl.galajus.Protocolib.PacketListenerScoreboardObjectives$1.onPacketSending(PacketListenerScoreboardObjectives.java:42)
[14:26:26 WARN]:        at ProtocolLib.jar//com.comphenix.protocol.injector.SortedPacketListenerList.invokeSendingListener(SortedPacketListenerList.java:195)[14:26:26 WARN]:        at ProtocolLib.jar//com.comphenix.protocol.injector.SortedPacketListenerList.invokePacketSending(SortedPacketListenerList.java:149)

Expected behavior
I want get Objective title

Screenshots
none

Version Info

ProtocolLib Dump
Timestamp: 08/30/21 15:36:33

ProtocolLib Version: ProtocolLib v4.7.0
Bukkit Version: 1.17.1-R0.1-SNAPSHOT
Server Version: git-Purpur-1334 (MC: 1.17.1)
Java Version: 16.0.2

ProtocolLib: com.comphenix.protocol.ProtocolLib@27e6e94e[
  statistics=com.comphenix.protocol.metrics.Statistics@376e9096
  backgroundCompiler=com.comphenix.protocol.reflect.compiler.BackgroundCompiler@5539bd9b
  packetTask=8
  tickCounter=654462
  unhookTask=com.comphenix.protocol.injector.DelayedSingleTask@40eb9cb4
  configExpectedMod=1
  updater=com.comphenix.protocol.updater.SpigotUpdater@5057b17e
  redirectHandler=com.comphenix.protocol.ProtocolLib$2@13fe61c2
  commandProtocol=com.comphenix.protocol.CommandProtocol@b33c343
  commandPacket=com.comphenix.protocol.CommandPacket@17a1e0ad
  commandFilter=com.comphenix.protocol.CommandFilter@7a107f66
  packetLogging=com.comphenix.protocol.PacketLogging@1a80f197
  skipDisable=false
  isEnabled=true
  loader=org.bukkit.plugin.java.JavaPluginLoader@fbc005f
  server=CraftServer{serverName=Purpur,serverVersion=git-Purpur-1334,minecraftVersion=1.17.1}
  file=plugins\ProtocolLib.jar
  description=org.bukkit.plugin.PluginDescriptionFile@6e128b44
  dataFolder=plugins\ProtocolLib
  classLoader=PluginClassLoader{plugin=ProtocolLib v4.7.0, pluginEnabled=true, url=plugins\ProtocolLib.jar}
  naggable=true
  newConfig=YamlConfiguration[path='', root='YamlConfiguration']
  configFile=plugins\ProtocolLib\config.yml
  logger=com.destroystokyo.paper.utils.PaperPluginLogger@1c528b9f
]
Manager: com.comphenix.protocol.injector.PacketFilterManager@a28a1dd[
  unhookTask=com.comphenix.protocol.injector.DelayedSingleTask@40eb9cb4
  packetListeners=[PacketAdapter[plugin=Galajus, sending=ListeningWhitelist[priority=NORMAL, packets=[SCOREBOARD_SCORE[class=PacketPlayOutScoreboardScore, id=86]], gamephase=PLAYING, options=[]], receiving=EMPTY_WHITELIST], PacketAdapter[plugin=HolographicDisplays, sending=ListeningWhitelist[priority=NORMAL, packets=[SPAWN_ENTITY[class=PacketPlayOutSpawnEntity, id=0], SPAWN_ENTITY_LIVING[class=PacketPlayOutSpawnEntityLiving, id=2], ENTITY_METADATA[class=PacketPlayOutEntityMetadata, id=77], REL_ENTITY_MOVE[class=PacketPlayOutRelEntityMove, id=41], REL_ENTITY_MOVE_LOOK[class=PacketPlayOutRelEntityMoveLook, id=42]], gamephase=PLAYING, options=[]], receiving=EMPTY_WHITELIST], PacketAdapter[plugin=Galajus, sending=ListeningWhitelist[priority=NORMAL, packets=[SCOREBOARD_OBJECTIVE[class=PacketPlayOutScoreboardObjective, id=83]], gamephase=PLAYING, options=[]], receiving=EMPTY_WHITELIST], PacketAdapter[plugin=CMI, sending=ListeningWhitelist[priority=HIGH, packets=[UNLOAD_CHUNK[class=PacketPlayOutUnloadChunk, id=29]], gamephase=PLAYING, options=[]], receiving=EMPTY_WHITELIST]]
  packetInjector=com.comphenix.protocol.injector.netty.ProtocolInjector$5@701a4377
  playerInjection=com.comphenix.protocol.injector.netty.ProtocolInjector$4@1d6ec73f
  inputBufferedPackets=[]
  recievedListeners=com.comphenix.protocol.injector.SortedPacketListenerList@15e8a97e
  sendingListeners=com.comphenix.protocol.injector.SortedPacketListenerList@5a81c457
  hasClosed=false
  classLoader=PluginClassLoader{plugin=ProtocolLib v4.7.0, pluginEnabled=true, url=plugins\ProtocolLib.jar}
  reporter=com.comphenix.protocol.ProtocolLib$1@7822358b
  server=CraftServer{serverName=Purpur,serverVersion=git-Purpur-1334,minecraftVersion=1.17.1}
  library=ProtocolLib v4.7.0
  asyncFilterManager=com.comphenix.protocol.async.AsyncFilterManager@139e428f
  knowsServerPackets=true
  knowsClientPackets=true
  phaseLoginCount=0
  phasePlayingCount=4
  packetCreation=false
  nettyInjector=com.comphenix.protocol.injector.netty.ProtocolInjector@1f9623e2
  pluginVerifier=com.comphenix.protocol.injector.PluginVerifier@3103f9a9
  hasRecycleDistance=true
  minecraftVersion=(MC: 1.17.1)
  debug=false
]

Listeners:
pl.galajus.Protocolib.PacketListenerScoreboardObjectives$2@218d2929[
  plugin=Galajus v1.9
  connectionSide=SERVER_SIDE
  receivingWhitelist=EMPTY_WHITELIST
  sendingWhitelist=ListeningWhitelist[priority=NORMAL, packets=[SCOREBOARD_SCORE[class=PacketPlayOutScoreboardScore, id=86]], gamephase=PLAYING, options=[]]
]
com.gmail.filoghost.holographicdisplays.bridge.protocollib.current.ProtocolLibHookImpl$1@33d1817d[
  plugin=HolographicDisplays v2.4.8
  connectionSide=SERVER_SIDE
  receivingWhitelist=EMPTY_WHITELIST
  sendingWhitelist=ListeningWhitelist[priority=NORMAL, packets=[SPAWN_ENTITY[class=PacketPlayOutSpawnEntity, id=0], SPAWN_ENTITY_LIVING[class=PacketPlayOutSpawnEntityLiving, id=2], ENTITY_METADATA[class=PacketPlayOutEntityMetadata, id=77], REL_ENTITY_MOVE[class=PacketPlayOutRelEntityMove, id=41], REL_ENTITY_MOVE_LOOK[class=PacketPlayOutRelEntityMoveLook, id=42]], gamephase=PLAYING, options=[]]
]
pl.galajus.Protocolib.PacketListenerScoreboardObjectives$1@4621338d[
  plugin=Galajus v1.9
  connectionSide=SERVER_SIDE
  receivingWhitelist=EMPTY_WHITELIST
  sendingWhitelist=ListeningWhitelist[priority=NORMAL, packets=[SCOREBOARD_OBJECTIVE[class=PacketPlayOutScoreboardObjective, id=83]], gamephase=PLAYING, options=[]]
]
com.Zrips.CMI.AllListeners.ProtocolEvent$1@4254f2ba[
  plugin=CMI v9.0.1.2
  connectionSide=SERVER_SIDE
  receivingWhitelist=EMPTY_WHITELIST
  sendingWhitelist=ListeningWhitelist[priority=HIGH, packets=[UNLOAD_CHUNK[class=PacketPlayOutUnloadChunk, id=29]], gamephase=PLAYING, options=[]]
]

Plugins Using ProtocolLib:
Galajus by [Galajus]
HolographicDisplays by [filoghost]
CMI by [Zrips]

Additional context
I dont want create second threat but i have a question, why every packet is firing twice? I have that with protocolib and por expample waterfall (when i get map of commands sended to player).

Example - protocolib:

[14:26:26 INFO]: [GALAJUS] PacketContainer[type=SCOREBOARD_SCORE[class=PacketPlayOutScoreboardScore, id=86], structureModifier=StructureModifier[fieldType=class java.lang.Object, data=[private final java.lang.String net.minecraft.network.protocol.game.PacketPlayOutScoreboardScore.a, private final java.lang.String net.minecraft.network.protocol.game.PacketPlayOutScoreboardScore.b, private final int net.minecraft.network.protocol.game.PacketPlayOutScoreboardScore.c, private final net.minecraft.server.ScoreboardServer$Action net.minecraft.network.protocol.game.PacketPlayOutScoreboardScore.d]]]
[14:26:26 INFO]: [GALAJUS] Galajusek
[14:26:26 INFO]: [GALAJUS] Daily_Galajusek
[14:26:26 INFO]: [GALAJUS] 0
[14:26:26 INFO]: [GALAJUS] PacketContainer[type=SCOREBOARD_SCORE[class=PacketPlayOutScoreboardScore, id=86], structureModifier=StructureModifier[fieldType=class java.lang.Object, data=[private final java.lang.String net.minecraft.network.protocol.game.PacketPlayOutScoreboardScore.a, private final java.lang.String net.minecraft.network.protocol.game.PacketPlayOutScoreboardScore.b, private final int net.minecraft.network.protocol.game.PacketPlayOutScoreboardScore.c, private final net.minecraft.server.ScoreboardServer$Action net.minecraft.network.protocol.game.PacketPlayOutScoreboardScore.d]]]
[14:26:26 INFO]: [GALAJUS] Galajusek
[14:26:26 INFO]: [GALAJUS] Daily_Galajusek
[14:26:26 INFO]: [GALAJUS] 12

what is intresting look that (post problem error)

[14:26:26 WARN]: java.lang.ClassCastException: class io.papermc.paper.adventure.AdventureComponent cannot be cast to class net.kyori.adventure.text.ScoreComponent (io.papermc.paper.adventure.AdventureComponent and net.kyori.adventure.text.ScoreComponent are in unnamed module of loader 'app')

second fire of a same packet:

[14:26:26 WARN]: java.lang.ClassCastException: class net.minecraft.network.chat.ChatComponentText cannot be cast to class net.kyori.adventure.text.ScoreComponent (net.minecraft.network.chat.ChatComponentText and net.kyori.adventure.text.ScoreComponent are in unnamed module of loader 'app')

Two other classes (nms and paper -> maybe this is error from paper?)

Paper geting map of commands result

14:40:22 [INFO] [Beblok] <-> ServerConnector [lobby] has connected
14:40:22 [INFO] [GALAJUSBUNGEE] forceresourcepacks | Command(name=frp, permission=forceresourcepacks.command, aliases=[forceresourcepacks], permissionMessage=null)
14:40:22 [INFO] [GALAJUSBUNGEE] server | Command(name=server, permission=bungeecord.command.server, aliases=[], permissionMessage=null)
14:40:22 [INFO] [GALAJUSBUNGEE] bf | Command(name=aegis, permission=null, aliases=[escanorproxy, botfilter, bf, antibot, proxy], permissionMessage=null)
14:40:22 [INFO] [GALAJUSBUNGEE] resetpack | Command(name=resetpack, permission=forceresourcepacks.command.resetpack, aliases=[], permissionMessage=null)
14:40:22 [INFO] [GALAJUSBUNGEE] log | Command(name=login, permission=null, aliases=[log, l], permissionMessage=null)
[... more commands...]

double...

14:40:22 [INFO] [GALAJUSBUNGEE] log | Command(name=login, permission=null, aliases=[log, l], permissionMessage=null)
14:40:22 [INFO] [GALAJUSBUNGEE] login | Command(name=login, permission=null, aliases=[log, l], permissionMessage=null)
14:40:22 [INFO] [GALAJUSBUNGEE] l | Command(name=login, permission=null, aliases=[log, l], permissionMessage=null)
14:40:22 [INFO] [GALAJUSBUNGEE] logout | Command(name=logout, permission=null, aliases=[], permissionMessage=null)
14:40:22 [INFO] [GALAJUSBUNGEE] reg | Command(name=register, permission=null, aliases=[reg], permissionMessage=null)
14:40:22 [INFO] [GALAJUSBUNGEE] register | Command(name=register, permission=null, aliases=[reg], permissionMessage=null)
14:40:23 [INFO] [GALAJUSBUNGEE] forceresourcepacks | Command(name=frp, permission=forceresourcepacks.command, aliases=[forceresourcepacks], permissionMessage=null)
[...morecommands...]

Code of getting map of commands:

@EventHandler
    public void onDefineCommand(ProxyDefineCommandsEvent e) {


        if (e.getReceiver() instanceof ProxiedPlayer p) {

            if (p.hasPermission("galajus")) return;

            e.getCommands().clear();
            Map<String, Command> commandMap = galajusBungee.getPluginData().getCommandMap();
            e.getCommands().putAll(commandMap);
        }
    }
    ```
commented

Up, i'm forgot about that:
This is error when i try convert packet Objective title, e packet is not exist in 1.17.1

[04:15:10 ERROR]: Parameters:
  net.minecraft.network.protocol.game.PacketPlayOutScoreboardObjective@699a05ae[
    d=Arena
    e=io.papermc.paper.adventure.AdventureComponent@7794bdea
    f=INTEGER
    g=0
  ]

Ok, i found :d

#WrappedChatComponent.fromHandle();