Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-12-24 15:20:35 +01:00
Add method to determine if player is in OnlineMode
Dieser Commit ist enthalten in:
Ursprung
e8d4db517d
Commit
fd367c6efd
@ -65,6 +65,13 @@ public interface Player extends CommandSource, InboundConnection, ChannelMessage
|
||||
*/
|
||||
long getPing();
|
||||
|
||||
/**
|
||||
* Returns the player's connection status.
|
||||
*
|
||||
* @return true if the player is authenticated with Mojang servers
|
||||
*/
|
||||
boolean isOnlineMode();
|
||||
|
||||
/**
|
||||
* Sends a chat message to the player's client.
|
||||
*
|
||||
|
@ -90,6 +90,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
private PermissionFunction permissionFunction;
|
||||
private int tryIndex = 0;
|
||||
private long ping = -1;
|
||||
private final boolean onlineMode;
|
||||
private @Nullable VelocityServerConnection connectedServer;
|
||||
private @Nullable VelocityServerConnection connectionInFlight;
|
||||
private @Nullable PlayerSettings settings;
|
||||
@ -102,8 +103,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
|
||||
private @MonotonicNonNull List<String> serversToTry = null;
|
||||
|
||||
ConnectedPlayer(VelocityServer server, GameProfile profile,
|
||||
MinecraftConnection connection, @Nullable InetSocketAddress virtualHost) {
|
||||
ConnectedPlayer(VelocityServer server, GameProfile profile, MinecraftConnection connection,
|
||||
@Nullable InetSocketAddress virtualHost, boolean onlineMode) {
|
||||
this.server = server;
|
||||
if (connection.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
|
||||
this.tabList = new VelocityTabList(connection);
|
||||
@ -116,6 +117,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
this.permissionFunction = PermissionFunction.ALWAYS_UNDEFINED;
|
||||
this.connectionPhase = connection.getType().getInitialClientPhase();
|
||||
this.knownChannels = CappedSet.create(MAX_PLUGIN_CHANNELS);
|
||||
this.onlineMode = onlineMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -151,6 +153,11 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
this.ping = ping;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlineMode() {
|
||||
return onlineMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerSettings getPlayerSettings() {
|
||||
return settings == null ? ClientSettingsWrapper.DEFAULT : this.settings;
|
||||
|
@ -232,7 +232,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
// Initiate a regular connection and move over to it.
|
||||
ConnectedPlayer player = new ConnectedPlayer(server, profileEvent.getGameProfile(),
|
||||
mcConnection,
|
||||
inbound.getVirtualHost().orElse(null));
|
||||
inbound.getVirtualHost().orElse(null), onlineMode);
|
||||
this.connectedPlayer = player;
|
||||
if (!server.canRegisterConnection(player)) {
|
||||
player.disconnect(VelocityMessages.ALREADY_CONNECTED);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren