Home›Java›Mods›[API] BungeePacketListenerAPI
ModsJava

[API] BungeePacketListenerAPI

Minecraft Java mod. Download on the author's site.

⬇ Download on Spigot
This API provides an easy way to listen for when a Packet is sent or received through the BungeeCord server.



[​IMG]
I enjoy making all of my plugins for free, but I need your help to keep them for free.
​

Code (Java):
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 want to manipulate packets on Bukkit servers, have a look at this API.

Examples

This example creates a very basic animated MOTD
Code (Java):
public void onEnable ( ) {
        SimpleDateFormat dateFormat = new SimpleDateFormat ( "yyyy.MM.dd HH:mm:ss" ) ;
        PacketHandler. addHandler ( new PacketHandler ( this ) {

            @Override
            public void onSend (SentPacket packet ) {
            }

            @Override
            public void onReceive (ReceivedPacket packet ) {
                if (packet. getPacket ( ) instanceof StatusRequest ) { // Check if the packet is right
                    packet. setCancelled ( true ) ; // Cancel the packet so the connection isn't closed
                    ProxyServer. getInstance ( ). getScheduler ( ). schedule (AnimatedMOTD. this, new Runnable ( ) {
                        public void run ( ) {
                            Gson gson = BungeeCord. getInstance ( ). gsonLegacy ;
                            /* Build & send the new packet every second */
                            ServerPing ping = new ServerPing ( new Protocol ( "", packet. getConection ( ). getVersion ( ) ), new Players ( 100, 0, new ServerPing. PlayerInfo [ 0 ] ), dateFormat. format ( new Date ( System. currentTimeMillis ( ) ) ), (Favicon ) null ) ;
                            sendPacket (packet. getConection ( ), new StatusResponse (gson. toJson (ping ) ) ) ;
                        }
                    }, 1, 1, TimeUnit. SECONDS ) ;
                }
                if (packet. getPacket ( ) instanceof PingPacket ) {
                    packet. setCancelled ( true ) ; // Cancel this or it will throw an exception
                }
            }
        } ) ;
    }



Links


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

Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.

[API] BungeePacketListenerAPI is a free Minecraft Java mod. Downloaded 2,238 times (via Spigot). Download it and open it directly in the game.

Explore more