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.static PacketSelectordirection(PacketDirection direction) Selects every packet in one direction.static PacketSelectorexact(PacketType<?> type) Selects one exact semantic type.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.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.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
-
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
-