13
0
geforkt von Mirrors/Velocity

Merge pull request #243 from Leymooo/api-improvement

Add method to allow determine if player is in OnlineMode
Dieser Commit ist enthalten in:
Andrew Steinborn 2019-09-03 23:29:51 -04:00 committet von GitHub
Commit 09dc74ac9a
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
3 geänderte Dateien mit 17 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -65,6 +65,13 @@ public interface Player extends CommandSource, InboundConnection, ChannelMessage
*/ */
long getPing(); 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. * Sends a chat message to the player's client.
* *

Datei anzeigen

@ -90,6 +90,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
private PermissionFunction permissionFunction; private PermissionFunction permissionFunction;
private int tryIndex = 0; private int tryIndex = 0;
private long ping = -1; private long ping = -1;
private final boolean onlineMode;
private @Nullable VelocityServerConnection connectedServer; private @Nullable VelocityServerConnection connectedServer;
private @Nullable VelocityServerConnection connectionInFlight; private @Nullable VelocityServerConnection connectionInFlight;
private @Nullable PlayerSettings settings; private @Nullable PlayerSettings settings;
@ -102,8 +103,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
private @MonotonicNonNull List<String> serversToTry = null; private @MonotonicNonNull List<String> serversToTry = null;
ConnectedPlayer(VelocityServer server, GameProfile profile, ConnectedPlayer(VelocityServer server, GameProfile profile, MinecraftConnection connection,
MinecraftConnection connection, @Nullable InetSocketAddress virtualHost) { @Nullable InetSocketAddress virtualHost, boolean onlineMode) {
this.server = server; this.server = server;
if (connection.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) { if (connection.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
this.tabList = new VelocityTabList(connection); this.tabList = new VelocityTabList(connection);
@ -116,6 +117,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
this.permissionFunction = PermissionFunction.ALWAYS_UNDEFINED; this.permissionFunction = PermissionFunction.ALWAYS_UNDEFINED;
this.connectionPhase = connection.getType().getInitialClientPhase(); this.connectionPhase = connection.getType().getInitialClientPhase();
this.knownChannels = CappedSet.create(MAX_PLUGIN_CHANNELS); this.knownChannels = CappedSet.create(MAX_PLUGIN_CHANNELS);
this.onlineMode = onlineMode;
} }
@Override @Override
@ -151,6 +153,11 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
this.ping = ping; this.ping = ping;
} }
@Override
public boolean isOnlineMode() {
return onlineMode;
}
@Override @Override
public PlayerSettings getPlayerSettings() { public PlayerSettings getPlayerSettings() {
return settings == null ? ClientSettingsWrapper.DEFAULT : this.settings; return settings == null ? ClientSettingsWrapper.DEFAULT : this.settings;

Datei anzeigen

@ -232,7 +232,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
// Initiate a regular connection and move over to it. // Initiate a regular connection and move over to it.
ConnectedPlayer player = new ConnectedPlayer(server, profileEvent.getGameProfile(), ConnectedPlayer player = new ConnectedPlayer(server, profileEvent.getGameProfile(),
mcConnection, mcConnection,
inbound.getVirtualHost().orElse(null)); inbound.getVirtualHost().orElse(null), onlineMode);
this.connectedPlayer = player; this.connectedPlayer = player;
if (!server.canRegisterConnection(player)) { if (!server.canRegisterConnection(player)) {
player.disconnect(VelocityMessages.ALREADY_CONNECTED); player.disconnect(VelocityMessages.ALREADY_CONNECTED);