3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Update for master changes and comments

Dieser Commit ist enthalten in:
Daniel Naylor 2018-11-24 21:24:35 +00:00
Ursprung 3adf36f712
Commit 9bab6b8c8e
2 geänderte Dateien mit 23 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -50,6 +50,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
private BackendConnectionPhase connectionPhase = BackendConnectionPhases.UNKNOWN; private BackendConnectionPhase connectionPhase = BackendConnectionPhases.UNKNOWN;
private long lastPingId; private long lastPingId;
private long lastPingSent; private long lastPingSent;
private boolean hasCompletedJoin = false;
public VelocityServerConnection(VelocityRegisteredServer registeredServer, public VelocityServerConnection(VelocityRegisteredServer registeredServer,
ConnectedPlayer proxyPlayer, VelocityServer server) { ConnectedPlayer proxyPlayer, VelocityServer server) {
@ -204,11 +205,14 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
} }
public void completeJoin() { public void completeJoin() {
if (connectionPhase == BackendConnectionPhases.UNKNOWN) { if (!hasCompletedJoin) {
// Now we know hasCompletedJoin = true;
connectionPhase = BackendConnectionPhases.VANILLA; if (connectionPhase == BackendConnectionPhases.UNKNOWN) {
if (connection != null) { // Now we know
connection.setType(ConnectionTypes.VANILLA); connectionPhase = BackendConnectionPhases.VANILLA;
if (connection != null) {
connection.setType(ConnectionTypes.VANILLA);
}
} }
} }
} }
@ -264,4 +268,15 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
public void setConnectionPhase(BackendConnectionPhase connectionPhase) { public void setConnectionPhase(BackendConnectionPhase connectionPhase) {
this.connectionPhase = connectionPhase; this.connectionPhase = connectionPhase;
} }
/**
* Gets whether the {@link com.velocitypowered.proxy.protocol.packet.JoinGame}
* packet has been sent by this server.
*
* @return Whether the join has been completed.
*/
public boolean hasCompletedJoin() {
return hasCompletedJoin;
}
} }

Datei anzeigen

@ -46,10 +46,10 @@ import java.net.InetSocketAddress;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Random;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException; import java.util.concurrent.CompletionException;
import java.util.concurrent.ThreadLocalRandom;
import net.kyori.text.Component; import net.kyori.text.Component;
import net.kyori.text.TextComponent; import net.kyori.text.TextComponent;
import net.kyori.text.TranslatableComponent; import net.kyori.text.TranslatableComponent;
@ -67,7 +67,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
c -> "", TranslatableComponent::key); c -> "", TranslatableComponent::key);
static final PermissionProvider DEFAULT_PERMISSIONS = s -> PermissionFunction.ALWAYS_UNDEFINED; static final PermissionProvider DEFAULT_PERMISSIONS = s -> PermissionFunction.ALWAYS_UNDEFINED;
private static final ThreadLocal<Random> threadLocalRandom = ThreadLocal.withInitial(Random::new); private static final ThreadLocalRandom threadLocalRandom = ThreadLocalRandom.current();
private static final Logger logger = LogManager.getLogger(ConnectedPlayer.class); private static final Logger logger = LogManager.getLogger(ConnectedPlayer.class);
private final MinecraftConnection connection; private final MinecraftConnection connection;
@ -479,7 +479,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
public void sendKeepAlive() { public void sendKeepAlive() {
if (connection.getState() == StateRegistry.PLAY) { if (connection.getState() == StateRegistry.PLAY) {
KeepAlive keepAlive = new KeepAlive(); KeepAlive keepAlive = new KeepAlive();
keepAlive.setRandomId(threadLocalRandom.get().nextLong()); keepAlive.setRandomId(threadLocalRandom.nextLong());
connection.write(keepAlive); connection.write(keepAlive);
} }
} }