Class PacketSelector

java.lang.Object
devs.beer.nativepackets.api.PacketSelector

public final class PacketSelector extends Object
Immutable registration-time packet selector.
  • Method Details

    • exact

      public static PacketSelector exact(PacketType<?> type)
      Selects one exact semantic type.
      Parameters:
      type - packet type
      Returns:
      exact selector
    • nativeClass

      public static PacketSelector nativeClass(Class<?> nativePacketClass, PacketDirection direction, ProtocolPhase phase)
      Selects one exact native packet class without a broad direction listener.
      Parameters:
      nativePacketClass - exact native packet implementation class
      direction - packet direction
      phase - protocol phase
      Returns:
      exact native-class selector
    • direction

      public static PacketSelector direction(PacketDirection direction)
      Selects every packet in one direction.
      Parameters:
      direction - packet direction
      Returns:
      direction selector
    • phase

      public static PacketSelector phase(ProtocolPhase phase)
      Selects every packet in one protocol phase.
      Parameters:
      phase - protocol phase
      Returns:
      phase selector
    • all

      public static PacketSelector all()
      Selects every known packet.
      Returns:
      global selector
    • matches

      public boolean matches(int candidateTypeIndex, PacketDirection candidateDirection, ProtocolPhase candidatePhase)
      Reports whether a precomputed slot matches this selector.
      Parameters:
      candidateTypeIndex - compact packet type index
      candidateDirection - packet direction
      candidatePhase - protocol phase
      Returns:
      true when the slot matches
    • matches

      public boolean matches(int candidateTypeIndex, PacketDirection candidateDirection, ProtocolPhase candidatePhase, Class<?> candidateNativeClass)
      Reports whether a classified native packet matches this selector.
      Parameters:
      candidateTypeIndex - compact packet type index
      candidateDirection - packet direction
      candidatePhase - protocol phase
      candidateNativeClass - exact native packet implementation class
      Returns:
      true when the native packet matches
    • selectsNativeClass

      public boolean selectsNativeClass()
      Reports whether this selector requires an exact native-class chain.
      Returns:
      whether native packet class identity participates in matching
    • matchesDirection

      public boolean matchesDirection(PacketDirection candidateDirection)
      Reports whether this selector can match a direction before types are classified.
      Parameters:
      candidateDirection - packet direction
      Returns:
      whether the direction can match