Class PacketHelper

java.lang.Object
me.tamkungz.nilkit.helper.PacketHelper

public final class PacketHelper extends Object
PacketHelper — utility for creating and sending Packet250CustomPayload without repeatedly hardcoding logic.
  • Method Details

    • buildPacket250

      public static Object buildPacket250(SimpleRemap remap, String channel, byte[] payload)
      Creates a Packet250CustomPayload instance. Tries (String, byte[]) constructor first, falls back to no-arg constructor + field assignment.
      Parameters:
      remap - SimpleRemap for the current version
      channel - channel name (e.g. "LYFE|Feed")
      payload - payload bytes
      Returns:
      packet instance, or null if class cannot be found
    • sendPacketBestEffort

      public static boolean sendPacketBestEffort(Object mc, Object clientPlayer, Object pkt, SimpleRemap remap)
      Sends a packet using best-effort strategy. Scans multiple possible paths (NetClientHandler, player fields, etc.).
      Returns:
      true if sending succeeds
    • getChannel

      public static String getChannel(Object pkt250, SimpleRemap remap)
      Extracts the channel name from a Packet250 instance.
    • getData

      public static byte[] getData(Object pkt250, SimpleRemap remap)
      Extracts payload bytes from a Packet250 instance.
    • isPacket250ForChannel

      public static boolean isPacket250ForChannel(Object obj, String channel, SimpleRemap remap)
      Checks whether the object is a Packet250 for the given channel.