Sueta
PA

PacketAPI

1.0

Api that allows you to intercept packets between client and server

·Plugin

PacketApi

Packet-API is a simple API that allows you to intercept packets that are being constantly exchanged between the client and the server. Packet-API should be packed with your plugin source when exporting your plugin

Versions below 1.8.8 are currently not supported but in future I will add 1.7.10 support.

Usage

Using the API is really simple. To start you will have to create a new instance of the API and start it.

public class SamplePlugin extends JavaPlugin {

    @Override
    public void onEnable() {
        new PacketApi(this).start();
    }
   
}

Intercepting Packets

1) Intercepting all packets that are in connection with a player by passing in the player in the PlayerPacketListener as shown below

PacketApi.getPacketApi().register(new PlayerPacketListener(player) {
            @Override
            public boolean onPacket(Player player, Packet packet) {
                return false;
            }
        });

2) Second way of doing it is by registering a PacketListener and passing all the packet names in the constructor that you want to intercept.

PacketApi.getPacketApi().register(new PacketListener("PacketPlayInPosition") {
            @Override
            public boolean onPacket(Player player, Packet packet) {
                return false;
            }
        });

3) The last way of doing it is intercepting all packets that are going between the clients and the server.

PacketApi.getPacketApi().register(new PacketHandler() {
            @Override
            public boolean onPacketSend(Player player, Packet packet) {
                return false;
            }

            @Override
            public boolean onPacketReceive(Player player, Packet packet) {
                return false;
            }
        });

Download

Maven

<repository>
    <id>ihaq-maven</id>
    <url>http://maven.ihaq.me/libs-maven/</url>
</repository>

<dependency>
    <groupId>me.mat1337</groupId>
    <artifactId>packet-api</artifactId>
    <version>1.0</version>
</dependency>

Gradle

repositories {
    maven {
        url "http://maven.ihaq.me/libs-maven/"
    }
}

dependencies {
    compile 'me.mat1337:packet-api:1.0'
}

Similar projects

Plugin →