BungeePackets
An in depth packet library for BungeeCord. This library allows developers to create plugins that allow for inventories across server networks, play sounds, particle effects, and soon to be lots more!
I've seen a few packet libraries for BungeeCord on Spigot. But none that I found easy to use, or expandable.
This plugin does NOT provide extra features for your network. It is an API for developers to use to make it easier for them to create cross-network plugins.
Installation
Simply drop the BungeePackets.jar into your plugins directory of your BungeeCord server. Restart the Bungee and it will be loaded!
Version
As far as I am aware, this plugin works with all builds greater than minecraft version 1.6.4.
Usage
Source Code
You can find the source code, and in depth usage for the API on the GitHub.
https://github.com/Spawl/BungeePackets
Leave a Review
If you use the plugin, or find it useful in any way (or not useful
), please leave your feedback below.
An in depth packet library for BungeeCord. This library allows developers to create plugins that allow for inventories across server networks, play sounds, particle effects, and soon to be lots more!
I've seen a few packet libraries for BungeeCord on Spigot. But none that I found easy to use, or expandable.
This plugin does NOT provide extra features for your network. It is an API for developers to use to make it easier for them to create cross-network plugins.
Installation
Simply drop the BungeePackets.jar into your plugins directory of your BungeeCord server. Restart the Bungee and it will be loaded!
Version
As far as I am aware, this plugin works with all builds greater than minecraft version 1.6.4.
Usage
Spoiler: Listening for packets.
BungeePackets adds in one simple event to manage packets. PacketEvent. The packet event is used to manage all incoming and outgoing packets. With ever incoming and outgoing packet there is a player assigned with it somewhere in the pipe. Using this system we can differentiate whether a server is sending a packet to Bungee, or a player is, vice-versa.
In the example below, we are listening for an incoming packet coming from the client to the BungeeCord. We can check who is sending/receiving packets by checking if they are an instance of a commection. To check if the sender is a palyer, check if the sender is an instanceof a ProxiedPlayer. To check if the sender is Bungee, check if the sender is an instance of a BungeeConnection. To check if the sender is a server, check if the sender is an instanceof a ServerConnection.
In the example below, we are listening for an incoming packet coming from the client to the BungeeCord. We can check who is sending/receiving packets by checking if they are an instance of a commection. To check if the sender is a palyer, check if the sender is an instanceof a ProxiedPlayer. To check if the sender is Bungee, check if the sender is an instance of a BungeeConnection. To check if the sender is a server, check if the sender is an instanceof a ServerConnection.
Code (Text):
@EventHandler
public void onPacket(PacketEvent event) {
if(event.getSender() instanceof ProxiedPlayer && event.getReciever() instanceof BungeeConnection) {
if(event.getPacket() instanceof InFlying) {
InFlying packet = (InFlying) event.getPacket();
}
}
}
public void onPacket(PacketEvent event) {
if(event.getSender() instanceof ProxiedPlayer && event.getReciever() instanceof BungeeConnection) {
if(event.getPacket() instanceof InFlying) {
InFlying packet = (InFlying) event.getPacket();
}
}
}
Spoiler: Registering a packet.
Some packets are already implemented. But for the ones that are not, you will have to create a packet for it. To create a custom packet, simply extend the
org.spawl.bungeepackets.Packet class. This is an abstract class so you will get 3 methods. Read, write, and handle. Read is called when the BungeeCord recieves the packet. Write is called when the Bungee is writing the packet to a pipe, and handle is called after the packet is read.
Even if you register custom packets, they will still be called through the PacketEvent.
Code (Text):
BungeePackets.registerPacket(Protocol.DirectionData.TO_SERVER, <ID>, <CLASS EXTENDING PACKET>);
Spoiler: Creating an inventory.
Creating inventories are made easy with a custom ItemStack API along with a custom inventory API. If you need any features added, please feel free to message me!
Code (Text):
ProxiedPlayer p = null; /* Make this not null when you do it ;) */
Inventory inventory = new Inventory("Test!", 54);
inventory.setItem(0, new ItemStack(Material.APPLE));
inventory.open(p);
Inventory inventory = new Inventory("Test!", 54);
inventory.setItem(0, new ItemStack(Material.APPLE));
inventory.open(p);
Spoiler: Playing a sound effect.
Sound effects can be played to clients just as they normally are. The packet added is called
OutNamedSoundEffect. Below you can see how to play a sound effect to any player!
Code (Text):
ProxiedPlayer player = null; /* Make this not null when you do it ;)*/
String soundEffect = SoundEffect.<YOUR SOUND>;
float volume = 1F;
float pitch = 1F;
BungeePackets.playSound(player, soundEffect, volume, pitch);
String soundEffect = SoundEffect.<YOUR SOUND>;
float volume = 1F;
float pitch = 1F;
BungeePackets.playSound(player, soundEffect, volume, pitch);
Spoiler: Displaying a particle effect.
Particle effects can be displayed to clients just as they normally are. The packet added is called
OutWorldParticles. Below you can see how to display a particle effect for any player.
There are 2 methods do play particle effects. One uses the players base position. The other uses coordinates.
There are 2 methods do play particle effects. One uses the players base position. The other uses coordinates.
Code (Text):
ProxiedPlayer player = null; /* Make this not null when you do it ;)*/
ParticleEffect effect = ParticleEffect.CLOUD;
//The method playEffect has the following structure:
//playEffect(<player>, <particle effect>, <offsetX>, <offsetY>, <offsetZ>, <speed>, <amount>);
//playEffect(<player>, <particle effect>, <x>, <y>, <z>,<offsetX>, <offsetY>, <offsetZ>, <speed>, <amount>);
playEffect(player, effect, 0.1F, 0.1F, 0.1F, 1F, 10);
ParticleEffect effect = ParticleEffect.CLOUD;
//The method playEffect has the following structure:
//playEffect(<player>, <particle effect>, <offsetX>, <offsetY>, <offsetZ>, <speed>, <amount>);
//playEffect(<player>, <particle effect>, <x>, <y>, <z>,<offsetX>, <offsetY>, <offsetZ>, <speed>, <amount>);
playEffect(player, effect, 0.1F, 0.1F, 0.1F, 1F, 10);
Spoiler: Getting a players position.
Player positions are sent to the BungeeCord from the
InFlying packet. This means the client is broadcasting its own coordinates. This is possible to exploit if the client has a custom mod. This is the most reliable way to get the clients coordinates though. Using this method, even if the server dies (not the BungeeCord) particle effects and sounds will still play properly.
Code (Text):
ProxiedPlayer player = null; /* Make this not null when you do it ;)*/
Position position = BungeePackets.getPlayerPosition(player.getUniqueId());
double x = position.getX();
double y = position.getY();
double z = position.getZ();
Position position = BungeePackets.getPlayerPosition(player.getUniqueId());
double x = position.getX();
double y = position.getY();
double z = position.getZ();
Source Code
You can find the source code, and in depth usage for the API on the GitHub.
https://github.com/Spawl/BungeePackets
Leave a Review
If you use the plugin, or find it useful in any way (or not useful
), please leave your feedback below.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.
BungeePackets is a free Minecraft Java mod. Downloaded 3,386 times (via Spigot). Download it and open it directly in the game.