ModsJava
[API] BungeePacketListenerAPI
Minecraft Java mod. Download on the author's site.
⬇ Download on SpigotThis API provides an easy way to listen for when a
Packet is sent or received through the BungeeCord server.
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
Links
Code (Java):
PacketListenerAPI.
addPacketHandler
(
new PacketHandler
(
)
{
@Override
public void onSend (SentPacket packet ) {
}
@Override
public void onReceive (ReceivedPacket packet ) {
}
} ) ;
@Override
public void onSend (SentPacket packet ) {
}
@Override
public void onReceive (ReceivedPacket packet ) {
}
} ) ;
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
}
}
} ) ;
}
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.
Donations to support me or this resource are also very much appreciated.
Quick facts
- Edition: Minecraft Java
- File type: .jar
- How to install: Install the matching mod loader (Forge, Fabric or NeoForge) for your Minecraft version. → Download the .jar. → Put it in the .minecraft/mods folder and launch that loader profile.
- Where to get it: Opens on Spigot — not every file is mirrored on our own servers.
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.
![[IMG]](http://proxy.spigotmc.org/03b89c2282b33ef720a7e5ca8cfbbb31681bc8b8?url=https%3A%2F%2Fstatic.spigotmc.org%2Fimg%2Fbtn_donate.gif)