Merge branch 'v1.16' into master

This commit is contained in:
joo committed 2020-08-19 20:27:11 +02:00
commit 3c84c2a429
33 files changed
+830 -330

No files matched your search

+13 -10
View File
@@ -1,5 +1,3 @@
from __future__ import print_function
from collections import deque
from threading import RLock
import zlib
@@ -11,8 +9,6 @@ import sys
import json
import re
from future.utils import raise_
from .types import VarInt
from .packets import clientbound, serverbound
from . import packets
@@ -495,7 +491,8 @@ class Connection(object):
# If allowed by the final exception handler, re-raise the exception.
if self.handle_exception is None and not caught:
raise_(*exc_info)
exc_value, exc_tb = exc_info[1:]
raise exc_value.with_traceback(exc_tb)
def _version_mismatch(self, server_protocol=None, server_version=None):
if server_protocol is None:
@@ -510,7 +507,10 @@ class Connection(object):
ss = 'supported, but not allowed for this connection' \
if server_protocol in SUPPORTED_PROTOCOL_VERSIONS \
else 'not supported'
raise VersionMismatch("Server's %s is %s." % (vs, ss))
err = VersionMismatch("Server's %s is %s." % (vs, ss))
err.server_protocol = server_protocol
err.server_version = server_version
raise err
def _handle_exit(self):
if not self.connected and self.handle_exit is not None:
@@ -593,7 +593,8 @@ class NetworkingThread(threading.Thread):
exc_info = None
if exc_info is not None:
raise_(*exc_info)
exc_value, exc_tb = exc_info[1:]
raise exc_value.with_traceback(exc_tb)
class PacketReactor(object):
@@ -644,14 +645,16 @@ class PacketReactor(object):
packet_id = VarInt.read(packet_data)
# If we know the structure of the packet, attempt to parse it
# otherwise just skip it
# otherwise, just return an instance of the base Packet class.
if packet_id in self.clientbound_packets:
packet = self.clientbound_packets[packet_id]()
packet.context = self.connection.context
packet.read(packet_data)
return packet
else:
return packets.Packet(context=self.connection.context)
packet = packets.Packet()
packet.context = self.connection.context
packet.id = packet_id
return packet
else:
return None