fixed packet whitelist
This commit is contained in:
parent
687e22ac5e
commit
f70121f2c1
2 changed files with 4 additions and 2 deletions
|
@ -228,7 +228,8 @@ class Dispatcher:
|
|||
buffer = io.BytesIO(decompressed_data)
|
||||
|
||||
packet_id = VarInt.read(buffer)
|
||||
if self._packet_id_whitelist and packet_id in self._packet_id_whitelist:
|
||||
if self.state == ConnectionState.PLAY and self._packet_id_whitelist \
|
||||
and packet_id not in self._packet_id_whitelist:
|
||||
self._logger.debug("[<--] Received | Packet(0x%02x) (ignored)", packet_id)
|
||||
continue # ignore this packet, we rarely need them all, should improve performance
|
||||
cls = self._packet_type_from_registry(packet_id)
|
||||
|
|
|
@ -2,6 +2,7 @@ import asyncio
|
|||
import uuid
|
||||
import logging
|
||||
|
||||
from inspect import isclass
|
||||
from typing import Dict, List, Set, Any, Callable, Type
|
||||
|
||||
class CallbacksHolder:
|
||||
|
@ -17,7 +18,7 @@ class CallbacksHolder:
|
|||
self._tasks = {}
|
||||
|
||||
def callback_keys(self, filter:Type = None) -> Set[Any]:
|
||||
return set(x for x in self._callbacks.keys() if not filter or issubclass(x, filter))
|
||||
return set(x for x in self._callbacks.keys() if not filter or (isclass(x) and issubclass(x, filter)))
|
||||
|
||||
def register(self, key:Any, callback:Callable):
|
||||
if key not in self._callbacks:
|
||||
|
|
Loading…
Reference in a new issue