A super lightweight Packet Listener for Bukkit/Spigot Servers with the ability to create and send packets with ease.
- Use a
PacketListener
paired with a@PacketHandler
to listener to packets. Usepacket = "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";
}
}
});
- Create packets with
Packeteer.createPacket(String)
Packet pong = Packeteer.createPacket("OutChat");
- 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);