Skip to content

A simple Packet Listener for Bukkit/Spigot Servers

Notifications You must be signed in to change notification settings

DolphlnDevelopment/Packeteer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Packeteer

A super lightweight Packet Listener for Bukkit/Spigot Servers with the ability to create and send packets with ease.

How to use

  1. Use a PacketListener paired with a @PacketHandler to listener to packets. Use packet = "ALL" to listen to EVERY packet.
Packeteer.registerListener(new PacketListener() {            
    @PacketHandler(type = PacketType.INCOMING, packet = "UpdateSign")
    public void onPlayInSignUpdate(PacketEvent event) {
        Packet packet = event.getPacket();
        FieldModifier<String[]> modify = packet.modify("b", String[].class);
        String[] lines = modify.read();
        for (int i = 0; i < lines.length; i++) {
            lines[i] = "nope";
        }
    }
});
  1. Create packets with Packeteer.createPacket(String)
Packet pong = Packeteer.createPacket("OutChat");
  1. Send packets with PacketPlayer#sendPacket
Class craftChatMessage = Reflection.getClass(Reflection.ClassType.OBC, "util.CraftChatMessage");
MethodInvoker wrapOrEmpty = new MethodInvoker(craftChatMessage, "wrapOrEmpty", String.class);
Object chatComponent = wrapOrEmpty.invoke("Pong!");
pong.write("a", chatComponent);
pong.write("b", Reflection.getClass(Reflection.ClassType.NMS, "ChatMessageType").getEnumConstants()[0]);
event.getPlayer().sendPacket(pong);

About

A simple Packet Listener for Bukkit/Spigot Servers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%