use of io.xol.chunkstories.api.net.PacketDefinition in project chunkstories by Hugobros3.
the class PacketsContextCommon method findIdForPacket.
private short findIdForPacket(Packet packet) throws UnknowPacketException {
WorldNetworked world = this.getWorld();
if (world == null) {
if ((packet instanceof PacketText))
return 0x00;
else if ((packet instanceof PacketSendFile))
return 0x01;
else
// Throw an error if sending a packet while not within a world
throw new UnknowPacketException(0xFF);
} else {
PacketDefinition def = world.getContent().packets().getPacketFromInstance(packet);
if (def == null)
logger.error("Could not find the definition of packet " + packet);
short id = (short) world.getContentTranslator().getIdForPacket(def);
if (id == -1) {
logger.error("Could not find the id of packet definition " + def.getName());
// ((AbstractContentTranslator)world.getContentTranslator()).test();
throw new UnknowPacketException(packet);
}
return id;
}
}
Aggregations