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:
Ursprung
3adf36f712
Commit
9bab6b8c8e
@ -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,6 +205,8 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void completeJoin() {
|
public void completeJoin() {
|
||||||
|
if (!hasCompletedJoin) {
|
||||||
|
hasCompletedJoin = true;
|
||||||
if (connectionPhase == BackendConnectionPhases.UNKNOWN) {
|
if (connectionPhase == BackendConnectionPhases.UNKNOWN) {
|
||||||
// Now we know
|
// Now we know
|
||||||
connectionPhase = BackendConnectionPhases.VANILLA;
|
connectionPhase = BackendConnectionPhases.VANILLA;
|
||||||
@ -212,6 +215,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boolean isGracefulDisconnect() {
|
boolean isGracefulDisconnect() {
|
||||||
return gracefulDisconnect;
|
return gracefulDisconnect;
|
||||||
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren