3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-12-24 15:20:35 +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 long lastPingId;
private long lastPingSent;
private boolean hasCompletedJoin = false;
public VelocityServerConnection(VelocityRegisteredServer registeredServer,
ConnectedPlayer proxyPlayer, VelocityServer server) {
@ -204,11 +205,14 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
}
public void completeJoin() {
if (connectionPhase == BackendConnectionPhases.UNKNOWN) {
// Now we know
connectionPhase = BackendConnectionPhases.VANILLA;
if (connection != null) {
connection.setType(ConnectionTypes.VANILLA);
if (!hasCompletedJoin) {
hasCompletedJoin = true;
if (connectionPhase == BackendConnectionPhases.UNKNOWN) {
// Now we know
connectionPhase = BackendConnectionPhases.VANILLA;
if (connection != null) {
connection.setType(ConnectionTypes.VANILLA);
}
}
}
}
@ -264,4 +268,15 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
public void setConnectionPhase(BackendConnectionPhase 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.List;
import java.util.Optional;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.ThreadLocalRandom;
import net.kyori.text.Component;
import net.kyori.text.TextComponent;
import net.kyori.text.TranslatableComponent;
@ -67,7 +67,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
c -> "", TranslatableComponent::key);
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 final MinecraftConnection connection;
@ -479,7 +479,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
public void sendKeepAlive() {
if (connection.getState() == StateRegistry.PLAY) {
KeepAlive keepAlive = new KeepAlive();
keepAlive.setRandomId(threadLocalRandom.get().nextLong());
keepAlive.setRandomId(threadLocalRandom.nextLong());
connection.write(keepAlive);
}
}