Configuration API (#12301)
This implements a solution that preemptively exits the tick loop if we have already marked the connection as disconnecting. This avoids changing the result of Connection#isConnected in order to avoid other possibly unintentional changes. Fundamentally it should be investigated if closing the connection async is really still needed. This also additionally removes the login disconnecting logic for server stopping, as this was also a possible issue in the config stage but also shouldn't be an issue as connections are closed on server stop very early. Additionally, do not check for isConnecting() on VERIFYING, as that seemed to be an old diff originally trying to resolve this code, however isConnected is not updated at this point so it pretty much was useless.
This commit is contained in:
@@ -10,6 +10,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import io.papermc.paper.connection.PlayerGameConnection;
|
||||
import io.papermc.paper.entity.LookAnchor;
|
||||
import io.papermc.paper.entity.PlayerGiveResult;
|
||||
import io.papermc.paper.math.Position;
|
||||
@@ -3925,4 +3926,12 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
* @param score New death screen score of player
|
||||
*/
|
||||
void setDeathScreenScore(int score);
|
||||
|
||||
/**
|
||||
* Gets the game connection for this player.
|
||||
*
|
||||
* @return the game connection
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
PlayerGameConnection getConnection();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.UUID;
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import io.papermc.paper.connection.PlayerLoginConnection;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -33,6 +34,7 @@ public class AsyncPlayerPreLoginEvent extends Event {
|
||||
private Result result;
|
||||
private Component message;
|
||||
private PlayerProfile profile;
|
||||
private final PlayerLoginConnection playerLoginConnection;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@Deprecated(since = "1.7.5", forRemoval = true)
|
||||
@@ -60,11 +62,11 @@ public class AsyncPlayerPreLoginEvent extends Event {
|
||||
@ApiStatus.Internal
|
||||
@Deprecated(forRemoval = true)
|
||||
public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress, @NotNull final InetAddress rawAddress, @NotNull final UUID uniqueId, boolean transferred, @NotNull com.destroystokyo.paper.profile.PlayerProfile profile) {
|
||||
this(name, ipAddress, rawAddress, uniqueId, transferred, profile, "");
|
||||
this(name, ipAddress, rawAddress, uniqueId, transferred, profile, "", null);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress, @NotNull final InetAddress rawAddress, @NotNull final UUID uniqueId, boolean transferred, @NotNull com.destroystokyo.paper.profile.PlayerProfile profile, @NotNull String hostname) {
|
||||
public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress, @NotNull final InetAddress rawAddress, @NotNull final UUID uniqueId, boolean transferred, @NotNull com.destroystokyo.paper.profile.PlayerProfile profile, @NotNull String hostname, final PlayerLoginConnection playerLoginConnection) {
|
||||
super(true);
|
||||
this.result = Result.ALLOWED;
|
||||
this.message = Component.empty();
|
||||
@@ -73,6 +75,7 @@ public class AsyncPlayerPreLoginEvent extends Event {
|
||||
this.rawAddress = rawAddress;
|
||||
this.hostname = hostname;
|
||||
this.transferred = transferred;
|
||||
this.playerLoginConnection = playerLoginConnection;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,6 +304,16 @@ public class AsyncPlayerPreLoginEvent extends Event {
|
||||
return this.transferred;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the connection for the player logging in.
|
||||
* @return connection
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
@NotNull
|
||||
public PlayerLoginConnection getConnection() {
|
||||
return playerLoginConnection;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package org.bukkit.event.player;
|
||||
|
||||
import io.papermc.paper.connection.PlayerCommonConnection;
|
||||
import io.papermc.paper.connection.PlayerConfigurationConnection;
|
||||
import org.bukkit.ServerLinks;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -10,18 +12,28 @@ import org.jetbrains.annotations.NotNull;
|
||||
* This event is called when the list of links is sent to the player.
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
public class PlayerLinksSendEvent extends PlayerEvent {
|
||||
public class PlayerLinksSendEvent extends Event {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final ServerLinks links;
|
||||
private final PlayerCommonConnection connection;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayerLinksSendEvent(@NotNull final Player player, @NotNull final ServerLinks links) {
|
||||
super(player);
|
||||
public PlayerLinksSendEvent(@NotNull final PlayerConfigurationConnection connection, @NotNull final ServerLinks links) {
|
||||
this.connection = connection;
|
||||
this.links = links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the connection that received the links.
|
||||
* @return connection
|
||||
*/
|
||||
@NotNull
|
||||
public PlayerCommonConnection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the links to be sent, for modification.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.bukkit.event.player;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import io.papermc.paper.event.connection.PlayerConnectionValidateLoginEvent;
|
||||
import org.bukkit.Warning;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -14,7 +16,15 @@ import org.jetbrains.annotations.NotNull;
|
||||
* Note that this event is called <i>early</i> in the player initialization
|
||||
* process. It is recommended that most options involving the Player
|
||||
* <i>entity</i> be postponed to the {@link PlayerJoinEvent} instead.
|
||||
* @deprecated Use {@link PlayerConnectionValidateLoginEvent} to handle pre-login logic
|
||||
* (e.g. authentication or ban checks), or {@link io.papermc.paper.event.player.PlayerServerFullCheckEvent} to allow
|
||||
* players to bypass the server's maximum player limit.
|
||||
* Minecraft triggers this twice internally, using this event skips one of the validation checks done by the server.
|
||||
* Additionally, this event causes the full player entity to be created much earlier than it would be in Vanilla,
|
||||
* leaving it with mostly disfunctional methods and state.
|
||||
*/
|
||||
@Warning(reason = "Listening to this event causes the player to be created early.")
|
||||
@Deprecated(since = "1.21.6")
|
||||
public class PlayerLoginEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.plugin.messaging;
|
||||
|
||||
import io.papermc.paper.connection.PlayerCommonConnection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -18,4 +19,16 @@ public interface PluginMessageListener {
|
||||
* @param message The raw message that was sent.
|
||||
*/
|
||||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, byte @NotNull [] message);
|
||||
|
||||
/**
|
||||
* A method that will be invoked when a PluginMessageSource sends a plugin
|
||||
* message on a registered channel.
|
||||
*
|
||||
* @param channel Channel that the message was sent through.
|
||||
* @param connection Source of the message.
|
||||
* @param message The raw message that was sent.
|
||||
*/
|
||||
default void onPluginMessageReceived(@NotNull String channel, @NotNull PlayerCommonConnection connection, byte @NotNull [] message) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user