geforkt von Mirrors/Velocity
Update for master changes and comments
Dieser Commit ist enthalten in:
Ursprung
3adf36f712
Commit
9bab6b8c8e
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren