Package devs.beer.nativepackets.api
Class PacketSelector
java.lang.Object
devs.beer.nativepackets.api.PacketSelector
Immutable registration-time packet selector.
-
Method Summary
Modifier and TypeMethodDescriptionstatic PacketSelectorall()Selects every known packet.Returns the selected direction, ornullwhen all directions match.static PacketSelectordirection(PacketDirection direction) Selects every packet in one direction.static PacketSelectorexact(PacketType<?> type) Selects one exact semantic type.PacketType<?> Returns the exact semantic type, ornullfor a broad/native-class selector.booleanmatches(int candidateTypeIndex, PacketDirection candidateDirection, ProtocolPhase candidatePhase) Reports whether a precomputed slot matches this selector.booleanmatches(int candidateTypeIndex, PacketDirection candidateDirection, ProtocolPhase candidatePhase, Class<?> candidateNativeClass) Reports whether a classified native packet matches this selector.booleanmatchesAnyTypeExcept(int excludedTypeIndex, PacketDirection candidateDirection, ProtocolPhase candidatePhase) Reports whether this selector can match any semantic type except one excluded type.booleanmatchesDirection(PacketDirection candidateDirection) Reports whether this selector can match a direction before types are classified.static PacketSelectornativeClass(Class<?> nativePacketClass, PacketDirection direction, ProtocolPhase phase) Selects one exact native packet class without a broad direction listener.Returns the selected native class name without retaining the class, ornull.phase()Returns the selected phase, ornullwhen all phases match.static PacketSelectorphase(ProtocolPhase phase) Selects every packet in one protocol phase.booleanReports whether this selector requires an exact native-class chain.
-
Method Details
-
exact
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 classdirection- packet directionphase- protocol phase- Returns:
- exact native-class selector
-
direction
Selects every packet in one direction.- Parameters:
direction- packet direction- Returns:
- direction selector
-
phase
Selects every packet in one protocol phase.- Parameters:
phase- protocol phase- Returns:
- phase selector
-
all
Selects every known packet.- Returns:
- global selector
-
exactType
Returns the exact semantic type, ornullfor a broad/native-class selector. -
direction
Returns the selected direction, ornullwhen all directions match. -
phase
Returns the selected phase, ornullwhen all phases match. -
nativePacketClassName
Returns the selected native class name without retaining the class, ornull. -
matches
public boolean matches(int candidateTypeIndex, PacketDirection candidateDirection, ProtocolPhase candidatePhase) Reports whether a precomputed slot matches this selector.- Parameters:
candidateTypeIndex- compact packet type indexcandidateDirection- packet directioncandidatePhase- protocol phase- Returns:
truewhen 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 indexcandidateDirection- packet directioncandidatePhase- protocol phasecandidateNativeClass- exact native packet implementation class- Returns:
truewhen 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
Reports whether this selector can match a direction before types are classified.- Parameters:
candidateDirection- packet direction- Returns:
- whether the direction can match
-
matchesAnyTypeExcept
public boolean matchesAnyTypeExcept(int excludedTypeIndex, PacketDirection candidateDirection, ProtocolPhase candidatePhase) Reports whether this selector can match any semantic type except one excluded type. Native-class identity is intentionally ignored so registration-time interest checks remain conservative before a packet class is available.- Parameters:
excludedTypeIndex- semantic type that must not count as a possible matchcandidateDirection- packet directioncandidatePhase- protocol phase- Returns:
- whether another type in the supplied direction and phase can match
-