Package net.minecraft.server.network
Class ServerCommonPacketListenerImpl
java.lang.Object
net.minecraft.server.network.ServerCommonPacketListenerImpl
- All Implemented Interfaces:
PacketListener,ServerCommonPacketListener,ServerCookiePacketListener,ServerPacketListener,ServerboundPacketListener,ICommonPacketListener,IServerCommonPacketListenerExtension
- Direct Known Subclasses:
ServerConfigurationPacketListenerImpl,ServerGamePacketListenerImpl
public abstract class ServerCommonPacketListenerImpl
extends Object
implements ServerCommonPacketListener
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate static final intprivate longprotected final Connectionprotected ConnectionTypeHolds the current connection type, based on the types of payloads that have been received so far.(package private) static final Componentprivate longprivate booleanprivate longprivate intstatic final intprivate static final org.slf4j.Loggerprotected final MinecraftServerprivate booleanprivate static final Componentprivate final boolean -
Constructor Summary
ConstructorsConstructorDescriptionServerCommonPacketListenerImpl(MinecraftServer pServer, Connection pConnection, CommonListenerCookie pCookie) -
Method Summary
Modifier and TypeMethodDescriptionprivate booleancheckIfClosed(long pTime) private voidclose()protected CommonListenerCookiecreateCookie(ClientInformation pClientInformation) Deprecated.protected CommonListenerCookiecreateCookie(ClientInformation pClientInformation, ConnectionType connectionType) Creates a new cookie for this connection.voiddisconnect(Component pReason) Triggers a disconnection with the given reason.voiddisconnect(DisconnectionDetails pDisconnectionDetails) Returns the connection this listener is attached to.Returns the connection type of this packet listener.com.mojang.authlib.GameProfilegetOwner()Returns the main thread packet processor.voidvoidvoidvoidhandleKeepAlive(ServerboundKeepAlivePacket p_294627_) voidhandlePong(ServerboundPongPacket p_295142_) voidprotected booleanprotected voidintlatency()voidonDisconnect(DisconnectionDetails p_350605_) voidonPacketError(Packet p_365354_, Exception p_363385_) protected abstract com.mojang.authlib.GameProfilevoidvoidSends a packet to the target of this listener.voidSends a packet to the client of this listener.voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.neoforged.neoforge.common.extensions.ICommonPacketListener
hasChannel, hasChannel, hasChannelMethods inherited from interface net.neoforged.neoforge.common.extensions.IServerCommonPacketListenerExtension
send, sendMethods inherited from interface net.minecraft.network.PacketListener
createDisconnectionInfo, fillCrashReport, fillListenerSpecificCrashDetails, isAcceptingMessages, protocol, shouldHandleMessageMethods inherited from interface net.minecraft.network.ServerboundPacketListener
flowMethods inherited from interface net.minecraft.network.protocol.common.ServerCommonPacketListener
handleClientInformation
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
LATENCY_CHECK_INTERVAL
public static final int LATENCY_CHECK_INTERVAL- See Also:
-
CLOSED_LISTENER_TIMEOUT
private static final int CLOSED_LISTENER_TIMEOUT- See Also:
-
TIMEOUT_DISCONNECTION_MESSAGE
-
DISCONNECT_UNEXPECTED_QUERY
-
server
-
connection
-
transferred
private final boolean transferred -
keepAliveTime
private long keepAliveTime -
keepAlivePending
private boolean keepAlivePending -
keepAliveChallenge
private long keepAliveChallenge -
closedListenerTime
private long closedListenerTime -
closed
private boolean closed -
latency
private int latency -
suspendFlushingOnServerThread
private volatile boolean suspendFlushingOnServerThread -
connectionType
Holds the current connection type, based on the types of payloads that have been received so far.
-
-
Constructor Details
-
ServerCommonPacketListenerImpl
public ServerCommonPacketListenerImpl(MinecraftServer pServer, Connection pConnection, CommonListenerCookie pCookie)
-
-
Method Details
-
close
private void close() -
onDisconnect
- Specified by:
onDisconnectin interfacePacketListener
-
onPacketError
- Specified by:
onPacketErrorin interfacePacketListener- Specified by:
onPacketErrorin interfaceServerPacketListener- Throws:
ReportedException
-
handleKeepAlive
- Specified by:
handleKeepAlivein interfaceServerCommonPacketListener
-
handlePong
- Specified by:
handlePongin interfaceServerCommonPacketListener
-
handleCustomPayload
- Specified by:
handleCustomPayloadin interfaceServerCommonPacketListener
-
handleCustomClickAction
- Specified by:
handleCustomClickActionin interfaceServerCommonPacketListener
-
handleResourcePackResponse
- Specified by:
handleResourcePackResponsein interfaceServerCommonPacketListener
-
handleCookieResponse
- Specified by:
handleCookieResponsein interfaceServerCookiePacketListener
-
keepConnectionAlive
protected void keepConnectionAlive() -
checkIfClosed
private boolean checkIfClosed(long pTime) -
suspendFlushing
public void suspendFlushing() -
resumeFlushing
public void resumeFlushing() -
send
Description copied from interface:ICommonPacketListenerSends a packet to the target of this listener.- Specified by:
sendin interfaceICommonPacketListener
-
send
Description copied from interface:IServerCommonPacketListenerExtensionSends a packet to the client of this listener.- Specified by:
sendin interfaceIServerCommonPacketListenerExtension- Parameters:
pSendListener- An optional callback for when the payload is sent
-
disconnect
Description copied from interface:ICommonPacketListenerTriggers a disconnection with the given reason.- Specified by:
disconnectin interfaceICommonPacketListener- Parameters:
pReason- The reason for the disconnection
-
disconnect
-
isSingleplayerOwner
protected boolean isSingleplayerOwner() -
playerProfile
protected abstract com.mojang.authlib.GameProfile playerProfile() -
getOwner
public com.mojang.authlib.GameProfile getOwner() -
latency
public int latency() -
createCookie
Deprecated.UsecreateCookie(ClientInformation, net.neoforged.neoforge.network.connection.ConnectionType)instead, keeping the connection type information available.Creates a new cookie for this connection.- Parameters:
pClientInformation- The client information.- Returns:
- The cookie.
-
createCookie
protected CommonListenerCookie createCookie(ClientInformation pClientInformation, ConnectionType connectionType) Creates a new cookie for this connection.- Parameters:
pClientInformation- The client information.connectionType- Whether the connection is modded.- Returns:
- The cookie.
-
getConnection
Description copied from interface:ICommonPacketListenerReturns the connection this listener is attached to.- Specified by:
getConnectionin interfaceICommonPacketListener- Returns:
- the connection this listener is attached to
-
getPacketProcessor
Description copied from interface:ICommonPacketListenerReturns the main thread packet processor.- Specified by:
getPacketProcessorin interfaceICommonPacketListener- Returns:
- the main thread packet processor
-
getConnectionType
Description copied from interface:ICommonPacketListenerReturns the connection type of this packet listener.- Specified by:
getConnectionTypein interfaceICommonPacketListener- Returns:
- the connection type of this packet listener
-
createCookie(ClientInformation, net.neoforged.neoforge.network.connection.ConnectionType)instead, keeping the connection type information available.