mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
chore: remove some unnecessary logging
This commit is contained in:
parent
1161fbf1b1
commit
b04fca8e7f
@ -14,6 +14,7 @@ import net.minestom.server.event.server.ServerListPingEvent;
|
||||
import net.minestom.server.extras.lan.OpenToLAN;
|
||||
import net.minestom.server.extras.lan.OpenToLANConfig;
|
||||
import net.minestom.server.extras.optifine.OptifineSupport;
|
||||
import net.minestom.server.extras.velocity.VelocityProxy;
|
||||
import net.minestom.server.instance.block.BlockManager;
|
||||
import net.minestom.server.ping.ResponseData;
|
||||
import net.minestom.server.utils.identity.NamedAndIdentified;
|
||||
@ -107,10 +108,10 @@ public class Main {
|
||||
|
||||
OptifineSupport.enable();
|
||||
|
||||
//VelocityProxy.enable("rBeJJ79W4MVU");
|
||||
VelocityProxy.enable("abc");
|
||||
//BungeeCordProxy.enable();
|
||||
|
||||
//MojangAuth.init();
|
||||
//MojangAuth.init();c
|
||||
|
||||
// useful for testing - we don't need to worry about event calls so just set this to a long time
|
||||
OpenToLAN.open(new OpenToLANConfig().eventCallDelay(Duration.of(1, TimeUnit.DAY)));
|
||||
|
@ -132,7 +132,6 @@ public final class PacketListenerManager {
|
||||
// If the packet intends to switch state, do it now.
|
||||
var nextState = packet.nextState();
|
||||
if (nextState != null && state != nextState) {
|
||||
System.out.println("CHANGE CLIENT STATE TO " + nextState);
|
||||
connection.setClientState(nextState);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package net.minestom.server.listener.preplay;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.network.ConnectionManager;
|
||||
import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.packet.client.configuration.ClientFinishConfigurationPacket;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -54,10 +54,6 @@ public class PacketProcessor {
|
||||
|
||||
public ClientPacket process(@NotNull PlayerConnection connection, int packetId, ByteBuffer body) {
|
||||
final ClientPacket packet = create(connection.getClientState(), packetId, body);
|
||||
var packetClass = packet.getClass();
|
||||
if (packetClass != ClientPlayerPositionPacket.class && packetClass != ClientPlayerPositionAndRotationPacket.class && packetClass != ClientPlayerRotationPacket.class)
|
||||
System.out.println("PROCESS " + connection.getClientState() + " " + packet.getClass().getSimpleName());
|
||||
|
||||
final ConnectionState state = connection.getClientState();
|
||||
switch (state) {
|
||||
case HANDSHAKE, STATUS, LOGIN, CONFIGURATION -> packetListenerManager.processClientPacket(connection.getClientState(), packet, connection);
|
||||
|
@ -22,7 +22,13 @@ public non-sealed interface ServerPacket extends NetworkBuffer.Writer, SendableP
|
||||
*/
|
||||
int getId(@NotNull ConnectionState state);
|
||||
|
||||
// If not null, the server will switch state immediately after sending this packet
|
||||
/**
|
||||
* If not null, the server will switch state immediately after sending this packet
|
||||
*
|
||||
* <p>WARNING: A cached or framed packet will currently never go through writeServerPacketSync,
|
||||
* so a state change inside one of them will never actually be triggered. Currently, cached
|
||||
* packets are never used for packets that change state, so this is not a problem.</p>
|
||||
*/
|
||||
default @Nullable ConnectionState nextState() {
|
||||
return null;
|
||||
}
|
||||
|
@ -10,17 +10,28 @@ import static net.minestom.server.network.NetworkBuffer.INT;
|
||||
|
||||
public record UnloadChunkPacket(int chunkX, int chunkZ) implements ServerPacket {
|
||||
public UnloadChunkPacket(@NotNull NetworkBuffer reader) {
|
||||
this(reader.read(INT), reader.read(INT));
|
||||
this(read(reader));
|
||||
}
|
||||
|
||||
private UnloadChunkPacket(@NotNull UnloadChunkPacket other) {
|
||||
this(other.chunkX(), other.chunkZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(@NotNull NetworkBuffer writer) {
|
||||
writer.write(INT, chunkX);
|
||||
// Client reads this as a single long in big endian, so we have to write it backwards
|
||||
writer.write(INT, chunkZ);
|
||||
writer.write(INT, chunkX);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.UNLOAD_CHUNK;
|
||||
}
|
||||
|
||||
private static UnloadChunkPacket read(@NotNull NetworkBuffer reader) {
|
||||
int z = reader.read(INT);
|
||||
int x = reader.read(INT);
|
||||
return new UnloadChunkPacket(x, z);
|
||||
}
|
||||
}
|
||||
|
@ -347,21 +347,17 @@ public class PlayerSocketConnection extends PlayerConnection {
|
||||
if (event.isCancelled()) return;
|
||||
}
|
||||
// Write packet
|
||||
// WARNING: A cached or framed packet will currently never go through writeServerPacketSync,
|
||||
// so a state change inside one of them will never actually be triggered. Currently, cached
|
||||
// packets are never used for packets that change state, so this is not a problem.
|
||||
if (packet instanceof ServerPacket serverPacket) {
|
||||
writeServerPacketSync(serverPacket, compressed);
|
||||
} else if (packet instanceof FramedPacket framedPacket) {
|
||||
var buffer = framedPacket.body();
|
||||
System.out.println("SEND " + getServerState() + " " + "UNKNOWN FRAMED");
|
||||
writeBufferSync(buffer, 0, buffer.limit());
|
||||
} else if (packet instanceof CachedPacket cachedPacket) {
|
||||
var buffer = cachedPacket.body(getServerState());
|
||||
if (buffer != null) {
|
||||
var packetClass = cachedPacket.packet(getServerState()).getClass();
|
||||
if (packetClass != TimeUpdatePacket.class && packetClass != UpdateLightPacket.class && packetClass != ChunkDataPacket.class) {
|
||||
System.out.println("SEND " + getServerState() + " " + cachedPacket.packet(getServerState()).getClass().getSimpleName());
|
||||
}
|
||||
writeBufferSync(buffer, buffer.position(), buffer.remaining());
|
||||
}
|
||||
if (buffer != null) writeBufferSync(buffer, buffer.position(), buffer.remaining());
|
||||
else writeServerPacketSync(cachedPacket.packet(getServerState()), compressed);
|
||||
} else if (packet instanceof LazyPacket lazyPacket) {
|
||||
writeServerPacketSync(lazyPacket.packet(), compressed);
|
||||
@ -381,12 +377,11 @@ public class PlayerSocketConnection extends PlayerConnection {
|
||||
try (var hold = ObjectPool.PACKET_POOL.hold()) {
|
||||
var state = getServerState();
|
||||
var buffer = PacketUtils.createFramedPacket(state, hold.get(), serverPacket, compressed);
|
||||
System.out.println("SEND " + getServerState() + " cls=" + serverPacket.getClass().getSimpleName() + " id=" + serverPacket.getId(getServerState()));
|
||||
writeBufferSync(buffer, 0, buffer.limit());
|
||||
|
||||
// If this packet has a state change, apply it.
|
||||
var nextState = serverPacket.nextState();
|
||||
if (nextState != null && state != nextState) {
|
||||
System.out.println("CHANGE SERVER STATE TO " + nextState);
|
||||
setServerState(nextState);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user