PacketInjectorAPI [1.8-1.21.3] - Manage packets easily icon

PacketInjectorAPI [1.8-1.21.3] - Manage packets easily -----

Simple API for managing packets. Powered by LightInjector!




  • Updated LightInjector to 1.0.4
  • Small fixes and improvements
----------, Oct 26, 2024

  • Added support for Minecraft 1.21.1
  • Updated LightInjector to 1.0.3
----------, Oct 6, 2024

Add support for 1.20.2
Updates LightInjector to 1.0.2
Now the packet logger will display the contents of bundle packets
----------, Sep 26, 2023

Updated LightInjector to 1.0.1.
This fixes a bug which caused some packets to be lost on Paper servers behind a BungeeCord instance.
----------, Nov 23, 2022

This release makes use of a brand new injector: LightInjector.
This change will reduce the burden of maintaining and updating the API to new mc versions.

The API itself has not changed, so updating to this version should be as easy as replacing the old jar with the new one.
Note, however, that some login packets will not be intercepted anymore starting from this version (game packets are not affected). See the LightInjector javadoc for more information.
----------, Sep 18, 2022

Add support for 1.19-1.19.2
----------, Aug 28, 2022

  • Perfect 1.18 support
  • Fix command filters not working properly
----------, Dec 4, 2021

The API has been completely rewritten. It is now more coincise and doesn't require fastutil.
Also, it now uses an updated version of TinyProtocol to inject into minecraft and listen to packets. This means that now it is possible to listen to handshake, login, and status packets like PacketLoginInStart.

This is how to create a PacketListener with the new API:
Code (Java):
PacketInjectorPlugin. getInstance ( ). getPacketInjectorAPI ( ). getEventManager ( ). registerPacketListener (plugin, new PacketListener ( ) {
    @Override
    public void onSend (PacketSendEvent event ) {
        // code
    }

    @Override
    public void onReceive (PacketReceiveEvent event ) {
        // code
    }
} ) ;
Please note that now event.getPlayer() can return null in case the player object is not available yet. For example, packet events fired when a player is joining but before PlayerJoinEvent does not provide a Player instance.
----------, Nov 26, 2021

Added new API:
Code (Java):
PacketEventManager. registerPacketListener (pluginInstance, new PacketListener ( ) {
   @Override
    public void onSend (PacketSendEvent e ) {
        // TODO
    }

   @Override
    public void onRetrive (PacketRetriveEvent e ) {
        // TODO
    }
} ) ;
Old API is removed. Add the PacketInjectorAPI-Compatibility plugin to the plugins folder for old api compatibility.
----------, Sep 8, 2020

Due to a Spigot change, in 1.14.x and later versions you have to use these methods instead of the classic ones:
Code (Java):
PacketEventManager. registerSendListener (event -> {
    Object packet = event. getPacket ( ) ;
    // The old packet class must remain the same as the new one
    event. setPacket (newPacket ) ;
    Player player = event. getPlayer ( ) ;
    String packetName = event. getPacketName ( ) ;
    Object value = event. getValue ( "fieldName" ) ;
    event. setValue ( "fieldName", value ) ;
    event. setCancelled ( true ) ;
} ) ;

PacketEventManager. registerRetriveListener (event -> {
    Object packet = event. getPacket ( ) ;
    // The old packet class must remain the same as the new one
    event. setPacket (newPacket ) ;
    Player player = event. getPlayer ( ) ;
    String packetName = event. getPacketName ( ) ;
    Object value = event. getValue ( "fieldName" ) ;
    event. setValue ( "fieldName", value ) ;
    event. setCancelled ( true ) ;
} ) ;
If you are supporting versions before and after 1.14, you have to
use both events (PacketSendEvent and PacketRetriveEvent) and PacketEventManager.
----------, Dec 20, 2019

Sorry for this update, just a small fix
----------, Dec 17, 2019

Added this methods:

Code (Java):

public void onPacketSend (PacketSendEvent event ) {

    // The old packet class must remain the same as the new one
    event. setPacket (newPacket ) ;

}
Code (Java):
@EventHandler
public void onPacketRetrive (PacketRetriveEvent event ) {

    // The old packet class must remain the same as the new one
    event. setPacket (newPacket ) ;

}
----------, Dec 17, 2019

Another update to try to fix completely the bug of the last update
----------, Dec 28, 2018

Fixed a huge bug that occours when players are kicked before this plugin was disabilited
----------, Dec 28, 2018

Fixed an error that occours enabling the plugin
----------, Nov 25, 2018

Fixed bug with sendPacketToClient and sendPacketToServer methods
----------, Sep 7, 2018

- Added method newInstance in the ReflectionUtil class to get a new Instance of a class using the proper constructor:
Code (Java):
public static Object newInstance (Class <?> clazz, Object... parameters ) ;

- Added method to packet's events:
Code (Java):
public void setValue ( String field, Object value ) ;

public Object getValue ( String field ) ;
These methods can be optimized in future

- Fixed some bugs
----------, Sep 7, 2018

With PacketInjectorAPI class you are enable to send packet not only to the client, but also to the server!

Code (Java):
public static void sendPacketToClient (Player player, Object packet )

public static void sendPacketToServer (Player player, Object packet )
----------, Aug 10, 2018

Added getPacketName method to send and retrive events

Code (Java):
public String getPacketName ( ) ;
----------, Aug 8, 2018

Added 1.13 compatibility
----------, Jul 23, 2018

Now you can use PacketRetriveEvent and PacketSendEvent in all the version.

Use PacketRetriveEvent_v1_7 and PacketSendEvent_v1_7 only if you want ChannelHandlerContext and ChannelPromise objects.

In 1.8 and later version you can get ChannelHandlerContext and ChannelPromise objects with these events: PacketRetriveEvent_v1_8 PacketSendEvent_v1_8
----------, Jul 2, 2018

Added Metrics using bStats
----------, Jun 22, 2018

Fixed Bugs - 1.7 support added

For 1.7 use these events:

PacketSendEvent_v1_7
PacketRetriveEvent_v1_7
----------, Jun 21, 2018

Resource Information
Author:
----------
Total Downloads: 4,538
First Release: Jun 20, 2018
Last Update: Oct 26, 2024
Category: ---------------
All-Time Rating:
2 ratings
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings