PluginMessageAPI+ 1.11

A plugin message wrapper which provides an object orientated packet api

  1. iKeirNez
    Backstory: I wrote this whilst working on a private project for a client. We had to do a lot of Bukkit -> BungeeCord communication and this became a real pain. Plugin Messages are long to write and you can often end up with issues using them. So I wrote this little API to ease the use of plugin messages.

    Before I begin explaining how it works, lets from now on, refer to plugin messages as Packets

    How Does It Work?: In short a Packet class is used to load and send data. You would have this api installed on whichever software you use it (Bukkit/BungeeCord etc). This api handles the sending and receiving of the packets. You use a Bukkit-like listener to receive these packets and a simple API to send it.

    Usage: The usage of this API is very similar on Bukkit as it is to BungeeCord or any other implementations I include in the future but I'll show an example of each anyway.

    Bukkit:
    Initializing Example:
    Code (Text):
    public PacketManager packetManager;

    public void onEnable(){
    packetManager = new BukkitPacketManager(this, "MyChannelName");
    packetManager.registerPacket(PacketPlayerUpdatePoints.class);
    packetManager.registerListener(new IncomingPacketHandler());
    }
    Sending Example:
    Code (Text):
    packetManager.sendPacket(new PacketPlayer(Bukkit.getPlayer("iKeirNez"), new PacketPlayerUpdatePoints(50)));
    Listener Example:
    Code (Text):
    public class IncomingPacketHandler implements PacketListener {
    @PacketHandler
    public void onPointsUpdate(PacketPlayerUpdatePoints packet){
    Player player = packet.getSender().getBukkitPlayer();
    int points = packet.points;

    // do something to update points
    }
    }

    BungeeCord:
    Initializing Example:
    Code (Text):
    public PacketManager packetManager;
    public void onEnable(){
    packetManager = new BungeeCordPacketManager(this, "MyChannelName");
    packetManager.registerPacket(PacketPlayerUpdatePoints.class);
    packetManager.registerListener(new IncomingPacketHandler());
    }
    Sending Example:
    Code (Text):
    packetManager.sendPacket(new PacketPlayer(ProxyServer.getInstance().getPlayer("iKeirNez"), new PacketPlayerUpdatePoints(50)));
    Listener Example:
    Code (Text):
    public class IncomingPacketHandler implements PacketListener {
    @PacketHandler
    public void onPointsUpdate(PacketPlayerUpdatePoints packet){
    ProxiedPlayer player = packet.getSender().getBungeePlayer();
    int points = packet.points;

    // do something to update points
    }
    }

    The Packet Class: This is probably the most important part of using this API, creating you're own Packet classes. For the above example I would use a Packet class that looks like this.

    Code (Text):
    public class PacketPlayerUpdatePoints extends StandardPacket {

    public int points;

    public PacketPlayerUpdatePoints(){}

    public PacketPlayerUpdatePoints(int point){
    this.change = change;
    }

    public void handle(DataInputStream dataInputStream) throws IOException {
    this.point = dataInputStream.readInt();
    }

    public PacketWriter write() throws IOException {
    PacketWriter packetWriter = new PacketWriter(this);
    packetWriter.writeInt(points);
    return packetWriter;
    }
    }
    Remember this packet class MUST be included in any module in which you send or receive otherwise this will not be able to function. A good way to do this would be with Maven by creating a Common module and then included that module in each other module jar.

    GitHub: https://github.com/iKeirNez/PluginMessageAPI-Plus

    Let me know if you use this API in any of you're Projects/Servers and I'll keep a list somewhere of projects/servers that use this. If you need any help or clarification on how to use this then feel free to post a reply or pm me.
    JBou, Quantum64 and regaw_leinad like this.

Recent Reviews

  1. SebliYT
    SebliYT
    5/5,
    Version: 1.11
    Nice Plugin, funktioniert echt super und bis jetzt ist noch kein fehler aufgetreten. Gute Arbeit !!!
  2. JBou
    JBou
    5/5,
    Version: 1.11
    Awesome Plugin! It's perfect for server networks and extremely powerful and easy to use. Thank you really much for this good job! :)
  3. Quantum64
    Quantum64
    5/5,
    Version: 1.0
    This is 100% exactly what I was looking for.... creepy
    1. iKeirNez
      Author's Response
      Glad you found this then :)
  4. regaw_leinad
    regaw_leinad
    5/5,
    Version: 1.0
    I highly recommend this API for anyone wanting to communicate Bungee <-> Server instance in a very simple and organized manner. Since plugin messages natively are limited to only being sent by a player, the author has implemented a queue for unsent packets, and are automatically sent as soon as possible! Awesome work, iKeirNez
    1. iKeirNez
      Author's Response
      Thanks, really appreciate it!