Skip to content

keir-nellyer/PluginMessageAPI-Plus-LEGACY

Repository files navigation

PluginMessageFramework

An extension of the Plugin Message API for Bukkit, BungeeCord

Links

Example Usage

Initializing Example (Bukkit)

public PacketManager packetManager;

public void onEnable(){
    packetManager = new BukkitPacketManager(this, "MyChannelName");
    packetManager.registerListener(new IncomingPacketHandler());
}

Initializing Example (BungeeCord)

public PacketManager packetManager;

public void onEnable(){
    packetManager = new BungeeCordPacketManager(this, "MyChannelName");
    packetManager.registerListener(new IncomingPacketHandler());
}

Packet Class Example

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;
    }
}

Sending Example (Bukkit, similar for BungeeCord)

packetManager.sendPacket(new PacketPlayer(Bukkit.getOnlinePlayers()[0], new PacketPlayerUpdatePoints(50)));

Listener Example (Bukkit, same for BungeeCord)

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
    }
}

Plugins/Mods/Addons/Servers using this API

About

An extension to the existing Plugin Message API on Bukkit and BungeeCord

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages