[API] PacketListenerAPI 3.9.8-SNAPSHOT

Simple API to manipulate sent and received packets | compatible with all versions

  1. inventivetalent
    Tested Minecraft Versions:
    • 1.16
    • 1.17
    Source Code:
    https://github.com/InventivetalentDev/PacketListenerAPI
    This API provides an easy way to listen for when a Packet is sent or received and includes functions to modify Fields of the Packet.

    Versions after 3.8 require Java 11+

    Code (Text):

    PacketListenerAPI.addPacketHandler(new PacketHandler() {

                @Override
                public void onSend(SentPacket packet) {
                }

                @Override
                public void onReceive(ReceivedPacket packet) {
                }

            });
     
    The processed packets can also be limited by adding the @PacketOptions annotation.

    If you are interested in manipulating packets directly on your BungeeCord server, check out the BungeeCord version of this API.

    Examples

    Checking a Packet

    1.) Not version save
    Code (Java):

            PacketListenerAPI.addPacketHandler(new PacketHandler() {

                @Override
                public void onSend(SentPacket packet) {
                    if (packet.getPacket() instanceof PacketPlayOutSpawnEntity) {// instanceof requires an import of the Packet, therefore not Version save
                        // Currently spawning an entity.
                    }
                }

                @Override
                public void onReceive(ReceivedPacket packet) {
                }

            });
     

    2.) version save (recommended)
    Code (Java):

        PacketListenerAPI.addPacketHandler(new PacketHandler() {

                @Override
                public void onSend(SentPacket packet) {
                    if (packet.getPacketName().equals("PacketPlayOutSpawnEntity")) {
                        // Currently spawning an entity.
                    }
                }

                @Override
                public void onReceive(ReceivedPacket packet) {
                }

            });
     

    1.) Not version save
    Code (Text):
        @EventHandler
        public void onPacketSend(PacketSendEvent e) {
            if (e.getPacket() instanceof PacketPlayOutSpawnEntity) {// instanceof requires an import of the Packet, therefore not Version save
                // Currently spawning an entity.
            }
        }
    2.) version save (recommended)
    Code (Text):
    @EventHandler
        public void onPacketSend(PacketSendEvent e) {
            if(e.getPacketName().equals("PacketPlayOutSpawnEntity")) {
                // Currently spawning an entity.
            }
        }
     

    Modifying Field values

    Code (Java):

    PacketListenerAPI.addPacketHandler(new PacketHandler() {

                @Override
                public void onSend(SentPacket packet) {
                    if(packet.getPacketName().equals("PacketPlayOutSpawnEntity")) {
                        packet.setPacketValue("f", <EntityID>);//f is the Field in the packet which defines the Entity-type as an Integer
                    }
                }

                @Override
                public void onReceive(ReceivedPacket packet) {
                }

            });
     
    1.) version save
    Code (Text):
        @EventHandler
        public void onPacketSend(PacketSendEvent e) {
            if(e.getPacketName().equals("PacketPlayOutSpawnEntity")) {
                e.setPacketValue("f", <EntityID>);//f is the Field in the packet which defines the Entity-type as an Integer
            }
        }



    Maven
    Code (Text):
        <dependency>
            <groupId>org.inventivetalent.packetlistenerapi</groupId>
            <artifactId>api</artifactId>
            <version>VERSION-SNAPSHOT</version>
        </dependency>
    https://jitpack.io/#org.inventivetalent/packetlistenerapi

    APIManager
    This API is compatible with APIManger.
    Click here for information on how to implement it.



    Links



    Please leave a rating if you like this resource.
    Donations to support me or this resource are also very much appreciated.

Recent Updates

  1. fix
  2. 1.17 support
  3. Fix

Recent Reviews

  1. xemles
    xemles
    5/5,
    Version: 3.9.8-SNAPSHOT
    For the idiots saying "I can't download unless I install a browser extension", they just don't know how to read. You click on DOWNLOAD on Spigot, scroll a bit, and you get a Direct Link.
  2. Abcik
    Abcik
    1/5,
    Version: 3.9.3-SNAPSHOT
    If you want to receive a monetary reward for your work, use a premium resource. It is not possible to download this plugin.
  3. rick_kik
    rick_kik
    5/5,
    Version: 3.9.3-SNAPSHOT
    Check github issues for a link to version snapshot-3.9.5 which fixes some of the problems that we still had with snapshot-3.9.3!
  4. xIsm4PvP
    xIsm4PvP
    5/5,
    Version: 3.9.3-SNAPSHOT
    Excelent api, also thanks to add 1.17 support, good for edit packets :)




    (Lmao so long)
  5. Gunging
    Gunging
    2/5,
    Version: 3.9.2-SNAPSHOT
    Impossible to download unless you install a browser extension.

    Forces you to Install some java compiler and git clone the source, if you dont want malware in your machine.
  6. xGhostnice
    xGhostnice
    3/5,
    Version: 3.9.2-SNAPSHOT
    [11:01:56 WARN]: Exception in thread "pool-73-thread-1" java.lang.RuntimeException: java.lang.IllegalArgumentException: Duplicate handler name: packet_listener_player
    [11:01:56 WARN]: at org.inventivetalent.packetlistener.channel.INCChannel$1.run(INCChannel.java:33)
    [11:01:56 WARN]: at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    [11:01:56 WARN]: at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    [11:01:56 WARN]: at java.base/java.lang.Thread.run(Thread.java:834)
    [11:01:56 WARN]: Caused by: java.lang.IllegalArgumentException: Duplicate handler name: packet_listener_player
    [11:01:56 WARN]: at io.netty.channel.DefaultChannelPipeline.checkDuplicateName(DefaultChannelPipeline.java:1055)
    [11:01:56 WARN]: at io.netty.channel.DefaultChannelPipeline.filterName(DefaultChannelPipeline.java:284)
    [11:01:56 WARN]: at io.netty.channel.DefaultChannelPipeline.addBefore(DefaultChannelPipeline.java:247)
    [11:01:56 WARN]: at io.netty.channel.DefaultChannelPipeline.addBefore(DefaultChannelPipeline.java:237)
    [11:01:56 WARN]: at com.comphenix.protocol.injector.netty.PipelineProxy.addBefore(PipelineProxy.java:61)
    [11:01:56 WARN]: at com.comphenix.protocol.injector.netty.ChannelInjector$3$1.addBefore(ChannelInjector.java:314)
    [11:01:56 WARN]: at org.inventivetalent.packetlistener.channel.INCChannel$1.run(INCChannel.java:31)
    [11:01:56 WARN]: ... 3 more help me
  7. mfnalex
    mfnalex
    5/5,
    Version: 3.9.1-SNAPSHOT
    To everyone giving one star reviews: READ THE DESCRIPTION! It's Java 11+ only! All the errors you people are posting clearly indicate that you must update your Java version...
  8. titivermeesch
    titivermeesch
    5/5,
    Version: 3.9.1-SNAPSHOT
    This is just awesome for any developer working with packets. About all those putting stupid 1/2 stars, just read the description. JAVA11+ is required. So stop complaining about your ClassVersion errors and read the god damn description
  9. danil20028191
    danil20028191
    1/5,
    Version: 3.9.1-SNAPSHOT
    [20:47:37] [Server thread/WARN]: Legacy plugin PacketListenerApi v3.9.1-SNAPSHOT does not specify an api-version.
    [20:47:37] [Server thread/ERROR]: Could not load 'plugins\PacketListenerAPI.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: org/inventivetalent/packetlistener/PacketListenerPlugin has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:141) ~[patched_1.16.5.jar:git-Paper-675]
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:397) ~[patched_1.16.5.jar:git-Paper-675]
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:305) ~[patched_1.16.5.jar:git-Paper-675]
    at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:389) ~[patched_1.16.5.jar:git-Paper-675]
    at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:252) ~[patched_1.16.5.jar:git-Paper-675]
    at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1066) ~[patched_1.16.5.jar:git-Paper-675]
    at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:290) ~[patched_1.16.5.jar:git-Paper-675]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_291]
    Caused by: java.lang.UnsupportedClassVersionError: org/inventivetalent/packetlistener/PacketListenerPlugin has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
    at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_291]
    at java.lang.ClassLoader.defineClass(Unknown Source) ~[?:1.8.0_291]
    at java.security.SecureClassLoader.defineClass(Unknown Source) ~[?:1.8.0_291]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:178) ~[patched_1.16.5.jar:git-Paper-675]
    at org.bukkit.plugin.java.JavaPluginLoader.getClassByName(JavaPluginLoader.java:216) ~[patched_1.16.5.jar:git-Paper-675]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:122) ~[patched_1.16.5.jar:git-Paper-675]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:111) ~[patched_1.16.5.jar:git-Paper-675]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_291]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_291]
    at java.lang.Class.forName0(Native Method) ~[?:1.8.0_291]
    at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_291]
    at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:79) ~[patched_1.16.5.jar:git-Paper-675]
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:137) ~[patched_1.16.5.jar:git-Paper-675]
    ... 7 more
  10. taylorfin16
    taylorfin16
    1/5,
    Version: 3.9.1-SNAPSHOT
    24.02 16:27:00 [Server] ERROR Could not load 'plugins/PacketListenerAPI_v3.8.0-SNAPSHOT (2).jar' in folder 'plugins'
    24.02 16:27:00 [Server] INFO org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: org/inventivetalent/packetlistener/PacketListenerPlugin has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
    24.02 16:27:00 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:141) ~[patched_1.16.4.jar:git-Paper-416]
    24.02 16:27:00 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:397) ~[patched_1.16.4.jar:git-Paper-416]
    24.02 16:27:00 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:305) ~[patched_1.16.4.jar:git-Paper-416]
    24.02 16:27:00 [Server] INFO at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:389) ~[patched_1.16.4.jar:git-Paper-416]
    24.02 16:27:00 [Server] INFO at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:206) ~[patched_1.16.4.jar:git-Paper-416]
    24.02 16:27:00 [Server] INFO at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:935) ~[patched_1.16.4.jar:git-Paper-416]
    24.02 16:27:00 [Server] INFO at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:173) ~[patched_1.16.4.jar:git-Paper-416]
    24.02 16:27:00 [Server] INFO at java.lang.Thread.run(Thread.java:748) [?:1.8.0_265]
    24.02 16:27:00 [Server] INFO Caused by: java.lang.UnsupportedClassVersionError: org/inventivetalent/packetlistener/PacketListenerPlugin has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
    24.02 16:27:00 [Server] INFO at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_265]
    24.02 16:27:00 [Server] INFO at java.lang.ClassLoader.defineClass(ClassLoader.java:756) ~[?:1.8.0_265]
    24.02 16:27:00 [Server] INFO at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[?:1.8.0_265]
    24.02 16:27:00 [Server] INFO at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:178) ~[patched_1.16.4.jar:git-Paper-416]
    24.02 16:27:00 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.getClassByName(JavaPluginLoader.java:216) ~[patched_1.16.4.jar:git-Paper-416]
    24.02 16:27:00 [Server] INFO at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:122) ~[patched_1.16.4.jar:git-Paper-416]
    24.02 16:27:00 [Server] INFO at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:111) ~[patched_1.16.4.jar:git-Paper-416]
    24.02 16:27:00 [Server] INFO at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[?:1.8.0_265]
    24.02 16:27:00 [Server] INFO at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_265]
    24.02 16:27:00 [Server] INFO at java.lang.Class.forName0(Native Method) ~[?:1.8.0_265]
    24.02 16:27:00 [Server] INFO at java.lang.Class.forName(Class.java:348) ~[?:1.8.0_265]
    24.02 16:27:00 [Server] INFO at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:79) ~[patched_1.16.4.jar:git-Paper-416]
    24.02 16:27:00 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:137) ~[patched_1.16.4.jar:git-Paper-416]
    24.02 16:27:00 [Server] INFO ... 7 more