Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-25 15:50:12 +01:00
Check for client state in event loop in PlayerPacketsTickTask
Dieser Commit ist enthalten in:
Ursprung
5f0cb34e64
Commit
8ec7c27153
BIN
.DS_Store
vendored
Normale Datei
BIN
.DS_Store
vendored
Normale Datei
Binäre Datei nicht angezeigt.
@ -21,6 +21,7 @@ import com.viaversion.viabackwards.ViaBackwards;
|
|||||||
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.Protocol1_21_2To1_21;
|
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.Protocol1_21_2To1_21;
|
||||||
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.storage.PlayerStorage;
|
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.storage.PlayerStorage;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
|
import com.viaversion.viaversion.api.connection.ProtocolInfo;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
@ -34,13 +35,14 @@ public final class PlayerPacketsTickTask implements Runnable {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (final UserConnection user : Via.getManager().getConnectionManager().getConnections()) {
|
for (final UserConnection user : Via.getManager().getConnectionManager().getConnections()) {
|
||||||
if (user.getProtocolInfo().getClientState() != State.PLAY || !user.getProtocolInfo().getPipeline().contains(Protocol1_21_2To1_21.class)) {
|
final ProtocolInfo protocolInfo = user.getProtocolInfo();
|
||||||
|
if (protocolInfo.getClientState() != State.PLAY || protocolInfo.getServerState() != State.PLAY || !protocolInfo.getPipeline().contains(Protocol1_21_2To1_21.class)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Channel channel = user.getChannel();
|
final Channel channel = user.getChannel();
|
||||||
channel.eventLoop().submit(() -> {
|
channel.eventLoop().submit(() -> {
|
||||||
if (!channel.isActive()) {
|
if (!channel.isActive() || protocolInfo.getClientState() != State.PLAY || protocolInfo.getServerState() != State.PLAY) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -48,13 +50,13 @@ public final class PlayerPacketsTickTask implements Runnable {
|
|||||||
final PlayerStorage playerStorage = user.get(PlayerStorage.class);
|
final PlayerStorage playerStorage = user.get(PlayerStorage.class);
|
||||||
playerStorage.tick(user);
|
playerStorage.tick(user);
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (final Throwable t) {
|
||||||
ViaBackwards.getPlatform().getLogger().log(Level.SEVERE, "Error while sending player input packet.", t);
|
ViaBackwards.getPlatform().getLogger().log(Level.SEVERE, "Error while sending player input packet.", t);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final PacketWrapper clientTickEndPacket = PacketWrapper.create(ServerboundPackets1_21_2.CLIENT_TICK_END, user);
|
final PacketWrapper clientTickEndPacket = PacketWrapper.create(ServerboundPackets1_21_2.CLIENT_TICK_END, user);
|
||||||
clientTickEndPacket.sendToServer(Protocol1_21_2To1_21.class);
|
clientTickEndPacket.sendToServer(Protocol1_21_2To1_21.class);
|
||||||
} catch (Throwable t) {
|
} catch (final Throwable t) {
|
||||||
ViaBackwards.getPlatform().getLogger().log(Level.SEVERE, "Error while sending client tick end packet.", t);
|
ViaBackwards.getPlatform().getLogger().log(Level.SEVERE, "Error while sending client tick end packet.", t);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren