[API] BungeePacketListenerAPI 1.3.0

Simple API to manipulate sent and received packets

  1. inventivetalent
    This API provides an easy way to listen for when a Packet is sent or received through the BungeeCord server.




    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.

Recent Updates

  1. Raw packet IDs
  2. Method updates

Recent Reviews

  1. Dzoko
    Dzoko
    1/5,
    Version: 1.3.0
    This plugin has a memory leak, don't use!!!! tuatahtiusahtuthaiushtiuashtiashtisuahtisuhtiahiutahsiuahtiahtiau
  2. enterih
    enterih
    1/5,
    Version: 1.3.0
    I have used this plugn and its work but, it's eating all of memory (MEMORY LEAK). After i uninstall this plugin, bungee it's work correctly and no out of memory. It's recommend to search an alternativ for this plugin
  3. leo
    leo
    5/5,
    Version: 1.3.0
    Very good plugin, but can you create wrappers for bungeecord if it's possible ? It will be so good !
  4. gyurix
    gyurix
    5/5,
    Version: 1.3.0
    My BungeeLib also contains this feature, but anyway your plugin in my eyes looks really great :)))))