use of cn.nukkit.raknet.protocol.packet.PING_DataPacket in project Nukkit by Nukkit.
the class RakNetInterface method handleEncapsulated.
@Override
public void handleEncapsulated(String identifier, EncapsulatedPacket packet, int flags) {
if (this.players.containsKey(identifier)) {
DataPacket pk = null;
try {
if (packet.buffer.length > 0) {
if (packet.buffer[0] == PING_DataPacket.ID) {
PING_DataPacket pingPacket = new PING_DataPacket();
pingPacket.buffer = packet.buffer;
pingPacket.decode();
this.networkLatency.put(identifier, (int) pingPacket.pingID);
return;
}
pk = this.getPacket(packet.buffer);
if (pk != null) {
pk.decode();
this.players.get(identifier).handleDataPacket(pk);
}
}
} catch (Exception e) {
this.server.getLogger().logException(e);
if (Nukkit.DEBUG > 1 && pk != null) {
MainLogger logger = this.server.getLogger();
// if (logger != null) {
logger.debug("Packet " + pk.getClass().getName() + " 0x" + Binary.bytesToHexString(packet.buffer));
// logger.logException(e);
// }
}
if (this.players.containsKey(identifier)) {
this.handler.blockAddress(this.players.get(identifier).getAddress(), 5);
}
}
}
}
Aggregations