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

Rename the two PlaySessionHandler classes to more clear names.

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-07-26 17:46:13 -04:00
Ursprung 41af775cc6
Commit ba5d6ad6e2
3 geänderte Dateien mit 12 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -1,5 +1,6 @@
package com.velocitypowered.proxy.connection.backend;
import com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler;
import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.packets.Disconnect;
import com.velocitypowered.proxy.protocol.packets.JoinGame;
@ -11,10 +12,10 @@ import net.kyori.text.TextComponent;
import net.kyori.text.format.TextColor;
import net.kyori.text.serializer.ComponentSerializers;
public class PlaySessionHandler implements MinecraftSessionHandler {
public class BackendPlaySessionHandler implements MinecraftSessionHandler {
private final ServerConnection connection;
public PlaySessionHandler(ServerConnection connection) {
public BackendPlaySessionHandler(ServerConnection connection) {
this.connection = connection;
}
@ -34,13 +35,13 @@ public class PlaySessionHandler implements MinecraftSessionHandler {
.build();
connection.getProxyPlayer().close(reason);
} else if (packet instanceof JoinGame) {
com.velocitypowered.proxy.connection.client.PlaySessionHandler playerHandler =
(com.velocitypowered.proxy.connection.client.PlaySessionHandler) connection.getProxyPlayer().getConnection().getSessionHandler();
ClientPlaySessionHandler playerHandler =
(ClientPlaySessionHandler) connection.getProxyPlayer().getConnection().getSessionHandler();
playerHandler.handleBackendJoinGame((JoinGame) packet);
} else if (packet instanceof Respawn) {
// Record the dimension switch, and then forward the packet on.
com.velocitypowered.proxy.connection.client.PlaySessionHandler playerHandler =
(com.velocitypowered.proxy.connection.client.PlaySessionHandler) connection.getProxyPlayer().getConnection().getSessionHandler();
ClientPlaySessionHandler playerHandler =
(ClientPlaySessionHandler) connection.getProxyPlayer().getConnection().getSessionHandler();
playerHandler.setCurrentDimension(((Respawn) packet).getDimension());
connection.getProxyPlayer().getConnection().write(packet);
} else {

Datei anzeigen

@ -1,5 +1,6 @@
package com.velocitypowered.proxy.connection.backend;
import com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler;
import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.StateRegistry;
import com.velocitypowered.proxy.protocol.packets.Disconnect;
@ -37,12 +38,12 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
connection.getChannel().setState(StateRegistry.PLAY);
if (connection.getProxyPlayer().getConnectedServer() == null) {
// Strap on the play session handler
connection.getProxyPlayer().getConnection().setSessionHandler(new com.velocitypowered.proxy.connection.client.PlaySessionHandler(connection.getProxyPlayer()));
connection.getProxyPlayer().getConnection().setSessionHandler(new ClientPlaySessionHandler(connection.getProxyPlayer()));
} else {
// The previous server connection should become obsolete.
connection.getProxyPlayer().getConnectedServer().disconnect();
}
connection.getChannel().setSessionHandler(new PlaySessionHandler(connection));
connection.getChannel().setSessionHandler(new BackendPlaySessionHandler(connection));
connection.getProxyPlayer().setConnectedServer(connection);
}
}

Datei anzeigen

@ -17,14 +17,14 @@ import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
public class PlaySessionHandler implements MinecraftSessionHandler {
public class ClientPlaySessionHandler implements MinecraftSessionHandler {
private final ConnectedPlayer player;
private ScheduledFuture<?> pingTask;
private long lastPing = -1;
private boolean spawned = false;
private int currentDimension;
public PlaySessionHandler(ConnectedPlayer player) {
public ClientPlaySessionHandler(ConnectedPlayer player) {
this.player = player;
}