Add support for Minecraft pre-release 16w36a (protocol 305).

Add max_length property to ChatPacket.
This commit is contained in:
joo 2016-09-25 22:16:46 +02:00
parent 41394126ab
commit c4ed8e6d68
2 changed files with 17 additions and 3 deletions

View File

@ -26,6 +26,7 @@ SUPPORTED_MINECRAFT_VERSIONS = {
'16w33a': 303,
'16w35a': 304,
'16w36a': 305,
'16w38a': 306,
}
SUPPORTED_PROTOCOL_VERSIONS = sorted(SUPPORTED_MINECRAFT_VERSIONS.values())

View File

@ -86,9 +86,12 @@ class Packet(object):
@context.setter
def context(self, _context):
self._context = _context
if _context is not None:
self.id = self.get_id(_context)
self.definition = self.get_definition(_context)
self._context_changed()
def _context_changed(self):
if self._context is not None:
self.id = self.get_id(self._context)
self.definition = self.get_definition(self._context)
else:
self.id = None
self.definition = None
@ -700,6 +703,16 @@ class ChatPacket(Packet):
return 0x02 if context.protocol_version >= 107 else \
0x01
@staticmethod
def get_max_length(context):
return 256 if context.protocol_version >= 305 else \
100
@property
def max_length(self):
if self.context is not None:
return self.get_max_length(self.context)
packet_name = "chat"
definition = [
{'message': String}]