}
// Handle listeners
PacketType type = PacketType.getType(packet);
List<PacketListener> listenerList = listeners.get(type);
if (listenerList != null) {
CommonPacket cp = new CommonPacket(packet, type);
PacketReceiveEvent ev = new PacketReceiveEvent(player, cp);
ev.setCancelled(wasCancelled);
for (PacketListener listener : listenerList) {
listener.onPacketReceive(ev);
}
if (ev.isCancelled()) {
return false;
}
}
// Handle monitors
List<PacketMonitor> monitorList = monitors.get(type);
if (monitorList != null) {
CommonPacket cp = new CommonPacket(packet, type);
for (PacketMonitor monitor : monitorList) {
monitor.onMonitorPacketReceive(cp, player);
}
}
return true;