ProtocolLib

3M Downloads

protocol API not receiving packets

PickleOnAString opened this issue ยท 1 comments

commented

Make sure you're doing the following

  • [Y] You're using the latest build for your server version
  • [Y] This isn't an issue caused by another plugin
  • [Y] You've checked for duplicate issues
  • [Y] You didn't use /reload

Describe the question
i am trying to listen to the PacketType.Play.Server.BLOCK_BREAK_ANIMATION. nothing is being received

API method(s) used
addPacketListener

Expected behavior
i should get "RAN THE LISTENER" in the console

Code
@Override public void onEnable() { // Plugin startup logic ProtocolManager manager = ProtocolLibrary.getProtocolManager(); manager.addPacketListener(new PacketAdapter(this, PacketType.Play.Server.BLOCK_BREAK_ANIMATION) { @Override public void onPacketReceiving(PacketEvent event) { getLogger().info("RAN THE LISTENER"); } }); }

Additional context
on purpur 1.20.2
my dump:
`
ProtocolLib Dump
Timestamp: 12/18/23 21:07:58

ProtocolLib Version: ProtocolLib v5.2.0-SNAPSHOT-678
Bukkit Version: 1.20.2-R0.1-SNAPSHOT
Server Version: git-Purpur-2095 (MC: 1.20.2)
Java Version: 21.0.1

ProtocolLib: com.comphenix.protocol.ProtocolLib@28ee87cd[
statistics=com.comphenix.protocol.metrics.Statistics@649810b2
packetTask=com.comphenix.protocol.scheduler.DefaultTask@43deb9af
tickCounter=149
configExpectedMod=1
updater=com.comphenix.protocol.updater.SpigotUpdater@4feaf2bb
redirectHandler=com.comphenix.protocol.ProtocolLib$2@1366d464
scheduler=com.comphenix.protocol.scheduler.DefaultScheduler@37df5b3a
commandProtocol=com.comphenix.protocol.CommandProtocol@1fa8faf
commandPacket=com.comphenix.protocol.CommandPacket@191dda01
commandFilter=com.comphenix.protocol.CommandFilter@3c7df8b2
packetLogging=com.comphenix.protocol.PacketLogging@71b6728c
skipDisable=false
isEnabled=true
loader=io.papermc.paper.plugin.manager.DummyBukkitPluginLoader@24e41ce2
server=CraftServer{serverName=Purpur,serverVersion=git-Purpur-2095,minecraftVersion=1.20.2}
file=plugins/ProtocolLib.jar
description=org.bukkit.plugin.PluginDescriptionFile@35dd1c
pluginMeta=org.bukkit.plugin.PluginDescriptionFile@35dd1c
dataFolder=plugins/ProtocolLib
classLoader=PluginClassLoader{plugin=ProtocolLib v5.2.0-SNAPSHOT-678, pluginEnabled=true, url=plugins/ProtocolLib.jar}
naggable=true
newConfig=YamlConfiguration[path='', root='YamlConfiguration']
configFile=plugins/ProtocolLib/config.yml
logger=com.destroystokyo.paper.utils.PaperPluginLogger@4652ea20
]
Manager: com.comphenix.protocol.injector.PacketFilterManager@7560e123[
plugin=ProtocolLib v5.2.0-SNAPSHOT-678
server=CraftServer{serverName=Purpur,serverVersion=git-Purpur-2095,minecraftVersion=1.20.2}
reporter=com.comphenix.protocol.ProtocolLib$1@6592fe28
minecraftVersion=(MC: 1.20.2)
asyncFilterManager=com.comphenix.protocol.async.AsyncFilterManager@4b6112bb
pluginVerifier=com.comphenix.protocol.injector.PluginVerifier@26b57f8e
inboundListeners=com.comphenix.protocol.injector.SortedPacketListenerList@77e79292
outboundListeners=com.comphenix.protocol.injector.SortedPacketListenerList@57641f8
registeredListeners=[PacketAdapter[plugin=HyperFlare, sending=ListeningWhitelist[priority=NORMAL, packets=[BLOCK_BREAK_ANIMATION[class=PacketPlayOutBlockBreakAnimation, id=6]], gamephase=PLAYING, options=[]], receiving=EMPTY_WHITELIST], PacketAdapter[plugin=HyperFlare, sending=ListeningWhitelist[priority=NORMAL, packets=[BLOCK_BREAK[PLAY, SERVER, 241, classNames: [net.minecraft.network.protocol.game.PacketPlayOutBlockBreak, net.minecraft.network.protocol.game.ClientboundBlockBreakPacket] (unregistered)]], gamephase=PLAYING, options=[]], receiving=EMPTY_WHITELIST]]
packetInjector=com.comphenix.protocol.injector.netty.manager.NetworkManagerPacketInjector@46c16f27
playerInjectionHandler=com.comphenix.protocol.injector.netty.manager.NetworkManagerPlayerInjector@4b05317e
networkManagerInjector=com.comphenix.protocol.injector.netty.manager.NetworkManagerInjector@3d498e
debug=false
closed=false
injected=true
]

Listeners:
net.picklestring.hyperflare.HyperFlare$1@514e4f5c[
plugin=HyperFlare v1.0-SNAPSHOT
connectionSide=SERVER_SIDE
receivingWhitelist=EMPTY_WHITELIST
sendingWhitelist=ListeningWhitelist[priority=NORMAL, packets=[BLOCK_BREAK_ANIMATION[class=PacketPlayOutBlockBreakAnimation, id=6]], gamephase=PLAYING, options=[]]
]
net.picklestring.hyperflare.HyperFlare$2@6203b9b[
plugin=HyperFlare v1.0-SNAPSHOT
connectionSide=SERVER_SIDE
receivingWhitelist=EMPTY_WHITELIST
sendingWhitelist=ListeningWhitelist[priority=NORMAL, packets=[BLOCK_BREAK[PLAY, SERVER, 241, classNames: [net.minecraft.network.protocol.game.PacketPlayOutBlockBreak, net.minecraft.network.protocol.game.ClientboundBlockBreakPacket] (unregistered)]], gamephase=PLAYING, options=[]]
]

Plugins Using ProtocolLib:
HyperFlare by []
`

commented

The packet you are listening on is sent by the server to the client. Thus, overriding onPacketReceiving is never called. This method is only called when the server receives a packet from the client.

Instead, overrideonPacketSending(PacketEvent event) to receive events when the server sends the packet to a client.