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 boolean
private static final int
private long
protected final Connection
protected ConnectionType
Holds the current connection type, based on the types of payloads that have been received so far.(package private) static final Component
private long
private boolean
private long
private int
static final int
private static final org.slf4j.Logger
protected final MinecraftServer
private boolean
private static final Component
private final boolean
-
Constructor Summary
ConstructorsConstructorDescriptionServerCommonPacketListenerImpl
(MinecraftServer p_295057_, Connection p_294822_, CommonListenerCookie p_301980_) -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
checkIfClosed
(long p_339648_) private void
close()
protected CommonListenerCookie
createCookie
(ClientInformation p_301973_) Deprecated.protected CommonListenerCookie
createCookie
(ClientInformation p_301973_, ConnectionType connectionType) Creates a new cookie for this connection.void
disconnect
(Component p_294116_) Triggers a disconnection with the given reason.void
disconnect
(DisconnectionDetails p_350316_) Returns the connection this listener is attached to.Returns the connection type of this packet listener.Returns the main thread event loop.com.mojang.authlib.GameProfile
getOwner()
void
void
void
handleKeepAlive
(ServerboundKeepAlivePacket p_294627_) void
handlePong
(ServerboundPongPacket p_295142_) void
protected boolean
protected void
int
latency()
void
onDisconnect
(DisconnectionDetails p_350605_) protected abstract com.mojang.authlib.GameProfile
void
void
Sends a packet to the target of this listener.void
send
(Packet<?> p_295099_, PacketSendListener p_296321_) Sends a packet to the client of this listener.void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.neoforged.neoforge.common.extensions.ICommonPacketListener
hasChannel, hasChannel, hasChannel
Methods inherited from interface net.neoforged.neoforge.common.extensions.IServerCommonPacketListenerExtension
send, send
Methods inherited from interface net.minecraft.network.PacketListener
createDisconnectionInfo, fillCrashReport, fillListenerSpecificCrashDetails, isAcceptingMessages, protocol, shouldHandleMessage
Methods inherited from interface net.minecraft.network.ServerboundPacketListener
flow
Methods inherited from interface net.minecraft.network.protocol.common.ServerCommonPacketListener
handleClientInformation
Methods inherited from interface net.minecraft.network.protocol.game.ServerPacketListener
onPacketError
-
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 p_295057_, Connection p_294822_, CommonListenerCookie p_301980_)
-
-
Method Details
-
close
private void close() -
onDisconnect
- Specified by:
onDisconnect
in interfacePacketListener
-
handleKeepAlive
- Specified by:
handleKeepAlive
in interfaceServerCommonPacketListener
-
handlePong
- Specified by:
handlePong
in interfaceServerCommonPacketListener
-
handleCustomPayload
- Specified by:
handleCustomPayload
in interfaceServerCommonPacketListener
-
handleResourcePackResponse
- Specified by:
handleResourcePackResponse
in interfaceServerCommonPacketListener
-
handleCookieResponse
- Specified by:
handleCookieResponse
in interfaceServerCookiePacketListener
-
keepConnectionAlive
protected void keepConnectionAlive() -
checkIfClosed
private boolean checkIfClosed(long p_339648_) -
suspendFlushing
public void suspendFlushing() -
resumeFlushing
public void resumeFlushing() -
send
Description copied from interface:ICommonPacketListener
Sends a packet to the target of this listener.- Specified by:
send
in interfaceICommonPacketListener
-
send
Description copied from interface:IServerCommonPacketListenerExtension
Sends a packet to the client of this listener.- Specified by:
send
in interfaceIServerCommonPacketListenerExtension
- Parameters:
p_296321_
- An optional callback for when the payload is sent
-
disconnect
Description copied from interface:ICommonPacketListener
Triggers a disconnection with the given reason.- Specified by:
disconnect
in interfaceICommonPacketListener
- Parameters:
p_294116_
- 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:
p_301973_
- The client information.- Returns:
- The cookie.
-
createCookie
protected CommonListenerCookie createCookie(ClientInformation p_301973_, ConnectionType connectionType) Creates a new cookie for this connection.- Parameters:
p_301973_
- The client information.connectionType
- Whether the connection is modded.- Returns:
- The cookie.
-
getConnection
Description copied from interface:ICommonPacketListener
Returns the connection this listener is attached to.- Specified by:
getConnection
in interfaceICommonPacketListener
- Returns:
- the connection this listener is attached to
-
getMainThreadEventLoop
Description copied from interface:ICommonPacketListener
Returns the main thread event loop.- Specified by:
getMainThreadEventLoop
in interfaceICommonPacketListener
- Returns:
- the main thread event loop
-
getConnectionType
Description copied from interface:ICommonPacketListener
Returns the connection type of this packet listener.- Specified by:
getConnectionType
in interfaceICommonPacketListener
- Returns:
- the connection type of this packet listener
-
createCookie(ClientInformation, net.neoforged.neoforge.network.connection.ConnectionType)
instead, keeping the connection type information available.