Package yapion.packet
Class YAPIONPacketReceiver
- java.lang.Object
-
- yapion.packet.YAPIONPacketReceiver
-
public class YAPIONPacketReceiver extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
YAPIONPacketReceiver.Handler
-
Constructor Summary
Constructors Constructor Description YAPIONPacketReceiver()
Creates an YAPIONPacketReceiver
-
Method Summary
Modifier and Type Method Description YAPIONPacketReceiver
add(@NonNull java.lang.Class<? extends YAPIONPacket> packetType, @NonNull YAPIONPacketHandler yapionPacketHandler)
Add an YAPIONPacketHandler for a specified packetType to handle.YAPIONPacketReceiver
add(@NonNull YAPIONPacketHandler yapionPacketHandler, @NonNull java.lang.Class<? extends YAPIONPacket> packetType)
A wrapper function toadd(Class, YAPIONPacketHandler)
YAPIONPacketReceiver
add(java.lang.Class<? extends YAPIONPacket>[] packetTypes, YAPIONPacketHandler yapionPacketHandler)
Deprecated.since 0.25.0YAPIONPacketReceiver
add(YAPIONPacketHandler yapionPacketHandler, java.lang.Class<? extends YAPIONPacket>... packetTypes)
Deprecated.since 0.25.0void
handle(@NonNull YAPIONPacket yapionPacket)
Handles an YAPIONPacket by calling the specified yapionPacketHandler for the type of the packet.YAPIONPacketReceiver
setHandler(@NonNull YAPIONPacketReceiver.Handler handler, @NonNull YAPIONPacketHandler yapionPacketHandler)
Set the SpecialHandlerYAPIONPacketHandler
to do something.
-
-
-
Method Detail
-
add
public YAPIONPacketReceiver add(@NonNull @NonNull java.lang.Class<? extends YAPIONPacket> packetType, @NonNull @NonNull YAPIONPacketHandler yapionPacketHandler)
Add an YAPIONPacketHandler for a specified packetType to handle. If either the packetType or yapionPacketHandler isnull
this method throws an YAPIONPacketException.- Parameters:
packetType
- the packet to handleyapionPacketHandler
- the handler which handles the specified packet
-
add
@Deprecated public YAPIONPacketReceiver add(java.lang.Class<? extends YAPIONPacket>[] packetTypes, YAPIONPacketHandler yapionPacketHandler)
Deprecated.since 0.25.0Add an YAPIONPacketHandler for the specified packetTypes to handle. If either the yapionPacketHandler or the packetTypes itself isnull
this method throws an YAPIONPacketException. If any value in the packetTypes array isnull
it will just be skipped over.- Parameters:
packetTypes
- the packets to handleyapionPacketHandler
- the handler which handles the specified packets
-
add
public YAPIONPacketReceiver add(@NonNull @NonNull YAPIONPacketHandler yapionPacketHandler, @NonNull @NonNull java.lang.Class<? extends YAPIONPacket> packetType)
A wrapper function toadd(Class, YAPIONPacketHandler)
-
add
@Deprecated public YAPIONPacketReceiver add(YAPIONPacketHandler yapionPacketHandler, java.lang.Class<? extends YAPIONPacket>... packetTypes)
Deprecated.since 0.25.0A wrapper function toadd(Class[], YAPIONPacketHandler)
-
setHandler
public YAPIONPacketReceiver setHandler(@NonNull @NonNull YAPIONPacketReceiver.Handler handler, @NonNull @NonNull YAPIONPacketHandler yapionPacketHandler)
Set the SpecialHandlerYAPIONPacketHandler
to do something.- Parameters:
yapionPacketHandler
- theYAPIONPacketHandler
to set
-
handle
public void handle(@NonNull @NonNull YAPIONPacket yapionPacket)
Handles an YAPIONPacket by calling the specified yapionPacketHandler for the type of the packet. If the packet type is not found the "@error" handler gets called. If any exception gets thrown the special "@exception" handler is called. If this also throws an exception this method will log the exception as a warning.- Parameters:
yapionPacket
- to handle
-
-