mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-07 00:48:28 +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.OpenToLAN;
|
||||||
import net.minestom.server.extras.lan.OpenToLANConfig;
|
import net.minestom.server.extras.lan.OpenToLANConfig;
|
||||||
import net.minestom.server.extras.optifine.OptifineSupport;
|
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.instance.block.BlockManager;
|
||||||
import net.minestom.server.ping.ResponseData;
|
import net.minestom.server.ping.ResponseData;
|
||||||
import net.minestom.server.utils.identity.NamedAndIdentified;
|
import net.minestom.server.utils.identity.NamedAndIdentified;
|
||||||
@ -107,10 +108,10 @@ public class Main {
|
|||||||
|
|
||||||
OptifineSupport.enable();
|
OptifineSupport.enable();
|
||||||
|
|
||||||
//VelocityProxy.enable("rBeJJ79W4MVU");
|
VelocityProxy.enable("abc");
|
||||||
//BungeeCordProxy.enable();
|
//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
|
// 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)));
|
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.
|
// If the packet intends to switch state, do it now.
|
||||||
var nextState = packet.nextState();
|
var nextState = packet.nextState();
|
||||||
if (nextState != null && state != nextState) {
|
if (nextState != null && state != nextState) {
|
||||||
System.out.println("CHANGE CLIENT STATE TO " + nextState);
|
|
||||||
connection.setClientState(nextState);
|
connection.setClientState(nextState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package net.minestom.server.listener.preplay;
|
|||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
import net.minestom.server.network.ConnectionManager;
|
import net.minestom.server.network.ConnectionManager;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.packet.client.configuration.ClientFinishConfigurationPacket;
|
import net.minestom.server.network.packet.client.configuration.ClientFinishConfigurationPacket;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@ -54,10 +54,6 @@ public class PacketProcessor {
|
|||||||
|
|
||||||
public ClientPacket process(@NotNull PlayerConnection connection, int packetId, ByteBuffer body) {
|
public ClientPacket process(@NotNull PlayerConnection connection, int packetId, ByteBuffer body) {
|
||||||
final ClientPacket packet = create(connection.getClientState(), packetId, 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();
|
final ConnectionState state = connection.getClientState();
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case HANDSHAKE, STATUS, LOGIN, CONFIGURATION -> packetListenerManager.processClientPacket(connection.getClientState(), packet, connection);
|
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);
|
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() {
|
default @Nullable ConnectionState nextState() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -10,17 +10,28 @@ import static net.minestom.server.network.NetworkBuffer.INT;
|
|||||||
|
|
||||||
public record UnloadChunkPacket(int chunkX, int chunkZ) implements ServerPacket {
|
public record UnloadChunkPacket(int chunkX, int chunkZ) implements ServerPacket {
|
||||||
public UnloadChunkPacket(@NotNull NetworkBuffer reader) {
|
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
|
@Override
|
||||||
public void write(@NotNull NetworkBuffer writer) {
|
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, chunkZ);
|
||||||
|
writer.write(INT, chunkX);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int getId(@NotNull ConnectionState state) {
|
||||||
return ServerPacketIdentifier.UNLOAD_CHUNK;
|
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;
|
if (event.isCancelled()) return;
|
||||||
}
|
}
|
||||||
// Write packet
|
// 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) {
|
if (packet instanceof ServerPacket serverPacket) {
|
||||||
writeServerPacketSync(serverPacket, compressed);
|
writeServerPacketSync(serverPacket, compressed);
|
||||||
} else if (packet instanceof FramedPacket framedPacket) {
|
} else if (packet instanceof FramedPacket framedPacket) {
|
||||||
var buffer = framedPacket.body();
|
var buffer = framedPacket.body();
|
||||||
System.out.println("SEND " + getServerState() + " " + "UNKNOWN FRAMED");
|
|
||||||
writeBufferSync(buffer, 0, buffer.limit());
|
writeBufferSync(buffer, 0, buffer.limit());
|
||||||
} else if (packet instanceof CachedPacket cachedPacket) {
|
} else if (packet instanceof CachedPacket cachedPacket) {
|
||||||
var buffer = cachedPacket.body(getServerState());
|
var buffer = cachedPacket.body(getServerState());
|
||||||
if (buffer != null) {
|
if (buffer != null) writeBufferSync(buffer, buffer.position(), buffer.remaining());
|
||||||
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());
|
|
||||||
}
|
|
||||||
else writeServerPacketSync(cachedPacket.packet(getServerState()), compressed);
|
else writeServerPacketSync(cachedPacket.packet(getServerState()), compressed);
|
||||||
} else if (packet instanceof LazyPacket lazyPacket) {
|
} else if (packet instanceof LazyPacket lazyPacket) {
|
||||||
writeServerPacketSync(lazyPacket.packet(), compressed);
|
writeServerPacketSync(lazyPacket.packet(), compressed);
|
||||||
@ -381,12 +377,11 @@ public class PlayerSocketConnection extends PlayerConnection {
|
|||||||
try (var hold = ObjectPool.PACKET_POOL.hold()) {
|
try (var hold = ObjectPool.PACKET_POOL.hold()) {
|
||||||
var state = getServerState();
|
var state = getServerState();
|
||||||
var buffer = PacketUtils.createFramedPacket(state, hold.get(), serverPacket, compressed);
|
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());
|
writeBufferSync(buffer, 0, buffer.limit());
|
||||||
|
|
||||||
|
// If this packet has a state change, apply it.
|
||||||
var nextState = serverPacket.nextState();
|
var nextState = serverPacket.nextState();
|
||||||
if (nextState != null && state != nextState) {
|
if (nextState != null && state != nextState) {
|
||||||
System.out.println("CHANGE SERVER STATE TO " + nextState);
|
|
||||||
setServerState(nextState);
|
setServerState(nextState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user