Package devs.beer.nativepackets.api
Interface PacketEvent
- All Known Subinterfaces:
PacketReceiveEvent,PacketSendEvent
Dispatch-scoped generic native packet event.
All access throws
IllegalStateException after listener dispatch ends.-
Method Summary
Modifier and TypeMethodDescriptiondefault voidcancel()Cancels the packet.Returns the connection handle.Returns the packet direction.booleanReports whether dispatch currently cancels the packet.booleanReports whether a typed view was created.Returns the current logical native packet.phase()Returns the protocol phase.voidreplaceNativePacket(Object nativePacket) Replaces the current logical native packet after adapter validation.voidsetCancelled(boolean cancelled) Changes cancellation state visible to later listeners.voidsync(SynchronizedPacketListener listener) Suspends this packet and continues the current listener on the connection player's entity scheduler.voidsyncAt(Object platformLocation, SynchronizedPacketListener listener) Suspends this packet and continues the current listener on the supplied Bukkit location's region.PacketType<?> type()Returns the stable semantic packet type.<V extends PacketView>
VCreates or returns the dispatch-local typed view.
-
Method Details
-
connection
ConnectionHandle connection()Returns the connection handle.- Returns:
- connection handle
-
direction
PacketDirection direction()Returns the packet direction.- Returns:
- packet direction
-
phase
ProtocolPhase phase()Returns the protocol phase.- Returns:
- protocol phase
-
type
PacketType<?> type()Returns the stable semantic packet type.- Returns:
- stable semantic packet type
-
nativePacket
Object nativePacket()Returns the current logical native packet.- Returns:
- current logical native packet
-
view
Creates or returns the dispatch-local typed view.- Type Parameters:
V- requested view type- Parameters:
viewType- requested view class- Returns:
- compatible cached view
-
isViewCreated
boolean isViewCreated()Reports whether a typed view was created.- Returns:
- whether a typed view was created
-
isCancelled
boolean isCancelled()Reports whether dispatch currently cancels the packet.- Returns:
- whether dispatch currently cancels the packet
-
setCancelled
void setCancelled(boolean cancelled) Changes cancellation state visible to later listeners.- Parameters:
cancelled- new cancellation state
-
cancel
default void cancel()Cancels the packet. -
replaceNativePacket
Replaces the current logical native packet after adapter validation.- Parameters:
nativePacket- replacement packet
-
sync
Suspends this packet and continues the current listener on the connection player's entity scheduler. The callback may inspect Bukkit state and edit this packet before dispatch resumes on Netty.- Parameters:
listener- synchronized continuation
-
syncAt
Suspends this packet and continues the current listener on the supplied Bukkit location's region.- Parameters:
platformLocation- BukkitLocationlistener- synchronized continuation
-