コード例 #1
0
 def send_chat(self, message, sender=UUID(int=0)):
     for player in self.players:
         data = player.buff_type.pack_chat(message) + player.buff_type.pack(
             "B", 0)
         if player.protocol_version > 578:
             data += player.buff_type.pack_uuid(sender)
         player.send_packet("chat_message", data)
コード例 #2
0
ファイル: server.py プロジェクト: vcokltfre/quarry
    def packet_login_start(self, buff):
        if self.login_expecting != 0:
            raise ProtocolError("Out-of-order login")

        self.display_name = buff.unpack_string()

        if self.factory.online_mode:
            self.login_expecting = 1

            # send encryption request

            # 1.7.x
            if self.protocol_version <= 5:
                pack_array = lambda a: self.buff_type.pack('h', len(a)) + a

            # 1.8.x
            else:
                pack_array = lambda a: self.buff_type.pack_varint(
                    len(a), max_bits=16) + a

            self.send_packet("login_encryption_request",
                             self.buff_type.pack_string(self.server_id),
                             pack_array(self.factory.public_key),
                             pack_array(self.verify_token))

        else:
            self.login_expecting = None
            self.display_name_confirmed = True
            self.uuid = UUID.from_offline_player(self.display_name)

            self.player_joined()
コード例 #3
0
ファイル: server.py プロジェクト: barneygale/quarry
    def packet_login_start(self, buff):
        if self.login_expecting != 0:
            raise ProtocolError("Out-of-order login")

        self.display_name = buff.unpack_string()

        if self.factory.online_mode:
            self.login_expecting = 1

            # send encryption request

            # 1.7.x
            if self.protocol_version <= 5:
                pack_array = lambda a: self.buff_type.pack('h', len(a)) + a

            # 1.8.x
            else:
                pack_array = lambda a: self.buff_type.pack_varint(
                    len(a), max_bits=16) + a

            self.send_packet(
                "login_encryption_request",
                self.buff_type.pack_string(self.server_id),
                pack_array(self.factory.public_key),
                pack_array(self.verify_token))

        else:
            self.login_expecting = None
            self.display_name_confirmed = True
            self.uuid = UUID.from_offline_player(self.display_name)

            self.player_joined()
コード例 #4
0
ファイル: __main__.py プロジェクト: FranchuFranchu/purecraft
 def send_mob(self,eid,type_,pos=(0,0,0),yaw=0,pitch=0,headpitch=0,uuid=UUID.random()):
     if self.protocol_version < 400:
         self.send_packet('spawn_mob', 
               self.bt.pack_varint(eid)
             + self.bt.pack_uuid(uuid)
             + self.bt.pack_varint(type_)
             + self.bt.pack('dddfffhhh',*pos,yaw,pitch,headpitch,0,0,0)
             + self.bt.pack_entity_metadata({}))
コード例 #5
0
	def buildProtocol(self, addr):
		# Build protocol with an unassigned uuid
		try:
			k = [*self.uuid_dict.keys()][[*self.uuid_dict.values()].index(None)]
			pc = InternalProxyExternalProtocol(self, self.buff_class, self.handle_direction, self.other_factory, self.config)
			pc.uuid = UUID(hex=k)
			return pc
		except ValueError:
			pass
コード例 #6
0
    def send_chat(self, message, sender=None):
        if sender is None:
            sender = UUID(int=0)

        for player in self.players:
            player.send_packet("chat_message",
                               player.buff_type.pack_chat(message),
                               player.buff_type.pack('B', 0),
                               player.buff_type.pack_uuid(sender))
コード例 #7
0
ファイル: mclink.py プロジェクト: gudchalmers/chs-mclink
    def send_chat(self, message, sender=None):
        if sender is None:
            sender = UUID(int=0)

        self.send_packet(
            "chat_message",
            self.buff_type.pack_chat(message),
            self.buff_type.pack('b', 1),
            self.buff_type.pack_uuid(sender)
        )
コード例 #8
0
ファイル: voting.py プロジェクト: JLyne/QueueServer
def entry_navigation_json(uuid: UUID, secret):
    token = hmac.new(key=str.encode(secret),
                     msg=uuid.to_bytes(),
                     digestmod="sha256")
    url = 'https://minecraft.rtgame.co.uk/detailing/?uuid={}&token={}'.format(
        uuid.to_hex(False), token.hexdigest())

    return json.dumps({
        "text":
        "\n",
        "color":
        "gold",
        "extra": [{
            "text": "[Prev Entry]",
            "bold": True,
            "clickEvent": {
                "action": "run_command",
                "value": "/prev"
            },
        }, {
            "text": " ",
        }, {
            "text": "[Next Entry]",
            "bold": True,
            "clickEvent": {
                "action": "run_command",
                "value": "/next"
            }
        }, {
            "text": "\n\n"
        }, {
            "text": "[Cast your Votes]",
            "bold": True,
            "color": "aqua",
            "clickEvent": {
                "action": "open_url",
                "value": url
            }
        }, {
            "text": "\n\n"
        }]
    })
コード例 #9
0
 def buildProtocol(self, addr):
     # Build protocol with an unassigned uuid
     try:
         k = [*self.uuid_dict.keys()][[*self.uuid_dict.values()
                                       ].index(None)]
         return InternalProxyMCClientProtocol(self,
                                              self.buff_class,
                                              self.handle_direction,
                                              self.other_factory,
                                              self.protocol_version,
                                              uuid=UUID(hex=k))
     except ValueError:
         pass
コード例 #10
0
    def write_chat(self, text, direction):
        if direction == "upstream":
            return self.buff_type.pack_string(text)
        elif direction == "downstream":
            data = self.buff_type.pack_chat(text)

            # 1.8.x+
            if self.downstream.protocol_version >= 47:
                data += self.buff_type.pack('B', 0)

            # 1.16.x+
            if self.downstream.protocol_version >= 736:
                data += self.buff_type.pack_uuid(UUID(int=0))

            return data
コード例 #11
0
    def __init__(self, factory, remote_addr):
        from versions import Version_1_15, Version_1_16, Version_1_16_2
        self.uuid = UUID.from_offline_player('NotKatuen')

        self.forwarded_uuid = None
        self.forwarded_host = None
        self.is_bedrock = False
        self.version = None
        self.versions = {
            578: Version_1_15,
            736: Version_1_16,
            751: Version_1_16_2
        }

        super(Protocol, self).__init__(factory, remote_addr)
コード例 #12
0
ファイル: version.py プロジェクト: JLyne/QueueServer
    def __init__(self, protocol: Protocol, bedrock: False):
        self.protocol = protocol
        self.viewpoint_id = 999
        self.viewpoint_uuid = UUID.random()

        self.current_chunk = None
        self.current_viewpoint = None
        self.raining = False

        self.player_spawned = False
        self.viewpoint_spawned = False
        self.viewpoint_used = False

        self.last_click = time.time()

        self.version_name = None
        self.is_bedrock = bedrock
コード例 #13
0
ファイル: mc_protocol.py プロジェクト: ClayCore/Eastwood
    def __init__(self,
                 factory,
                 buff_class,
                 handle_direction,
                 other_factory,
                 protocol_version,
                 uuid=None):
        """
		Protocol args:
			factory: factory that made this protocol (subclass of BaseFactory)
			buff_class: buffer class that this protocol will use
			handle_direction: direction packets being handled by this protocol are going (can be "downstream" or "upstream")
			other_factory: the other factory that communicates with this protocol (in this case an instance of EWProtocol)
			protocol_version: protocol specification to use
			uuid: uuid of client, don't set to autogen
		"""
        super().__init__(factory, buff_class, handle_direction, other_factory)
        self.protocol_version = protocol_version
        self.protocol_mode = "init"
        self.uuid = uuid or UUID.random()
コード例 #14
0
    def __init__(self, factory, remote_addr):
        from queueserver.versions import Version_1_15, Version_1_16, Version_1_16_2, Version_1_17, Version_1_17_1
        self.uuid = UUID.random()

        self.forwarded_uuid = None
        self.forwarded_host = None
        self.is_bedrock = False
        self.version = None
        self.versions = {
            578: Version_1_15,
            736: Version_1_16,
            751: Version_1_16_2,
            755: Version_1_17,
            756: Version_1_17_1
        }

        super(Protocol, self).__init__(factory, remote_addr)

        self.logger.addHandler(console_handler)
        self.logger.addHandler(file_handler)
コード例 #15
0
    def packet_handshake(self, buff):
        buff2 = deepcopy(buff)
        super().packet_handshake(buff)

        p_protocol_version = buff2.unpack_varint()
        p_connect_host = buff2.unpack_string()

        # Bungeecord ip forwarding, ip/uuid is included in host string separated by \00s
        split_host = str.split(p_connect_host, "\00")

        if len(split_host) >= 3:
            # TODO: Should probably verify the encrypted data in some way.
            # Not important until something on this server uses uuids
            if split_host[1] == 'Geyser-Floodgate':
                self.is_bedrock = True

                host = split_host[4]
                online_uuid = split_host[5]
            elif split_host[1].startswith('^Floodgate^'):
                self.is_bedrock = True

                host = split_host[2]
                online_uuid = split_host[3]
            else:
                host = split_host[1]
                online_uuid = split_host[2]

            self.forwarded_host = host
            self.forwarded_uuid = UUID.from_hex(online_uuid)

        version = None

        for pv, v in self.versions.items():
            if p_protocol_version >= pv:
                version = v

        if version is not None:
            self.version = version(self, self.is_bedrock)
        else:
            self.close("Unsupported Minecraft Version")
コード例 #16
0
ファイル: test_types.py プロジェクト: vcokltfre/quarry
def test_uuid_from_bytes_to_hex():
    uuid = UUID.from_bytes(bytes_vector)
    assert isinstance(uuid, UUID)
    assert uuid.to_hex() == hex_vector
    assert uuid.to_hex(False) == hex_vector.replace("-", "")
コード例 #17
0
    def unpack_uuid(self):
        """
        Unpacks a UUID.
        """

        return UUID.from_bytes(self.read(16))
コード例 #18
0
ファイル: auth.py プロジェクト: barneygale/quarry
 def _from_response(cls, response):
     return cls(
         response['clientToken'],
         response['accessToken'],
         response['selectedProfile']['name'],
         UUID.from_hex(response['selectedProfile']['id']))
コード例 #19
0
ファイル: server.py プロジェクト: barneygale/quarry
    def auth_ok(self, data):
        """Called when auth with mojang succeeded (online mode only)"""
        self.display_name_confirmed = True
        self.uuid = UUID.from_hex(data['id'])

        self.player_joined()
コード例 #20
0
ファイル: __init__.py プロジェクト: PhiPhi1/queue-plus
 def packet_mirror_login_success(self, buff):
     self.player_uuid = UUID.from_hex(buff.unpack_string())
     self.player_username = buff.unpack_string()
     return
コード例 #21
0
ファイル: auth.py プロジェクト: barneygale/quarry
 def from_token(cls, client_token, access_token, display_name, uuid):
     obj = cls(client_token, access_token,
               display_name, UUID.from_hex(uuid))
     return obj.validate()
コード例 #22
0
ファイル: server.py プロジェクト: vcokltfre/quarry
    def auth_ok(self, data):
        """Called when auth with mojang succeeded (online mode only)"""
        self.display_name_confirmed = True
        self.uuid = UUID.from_hex(data['id'])

        self.player_joined()
コード例 #23
0
    def update_music(self, create=False):
        if not self.song_start:
            self.song_start = datetime.now()

        percent = (datetime.now() - self.song_start).seconds / ((2 * 60) + 32)

        if create:
            self.music_bar_uuid = UUID.random()
            self.send_packet(
                "boss_bar",
                self.buff_type.pack_uuid(self.music_bar_uuid),
                self.buff_type.pack_varint(0),
                self.buff_type.pack_chat(
                    Message({
                        "text": "Server is loading -- Playing Stal by C418",
                        "color": "bold",
                    })),
                self.buff_type.pack("f", percent),
                self.buff_type.pack_varint(1),
                self.buff_type.pack_varint(0),
                self.buff_type.pack("B", 0b00000),
            )

            # Play "Stal" by C418
            self.send_packet(
                "sound_effect",
                self.buff_type.pack_varint(474),
                self.buff_type.pack_varint(2),
                self.buff_type.pack(
                    "iiiff",
                    int(default_pos[0] * 8),
                    int(default_pos[1] * 8),
                    int(default_pos[2] * 8),
                    1,
                    1,
                ),
            )  # teleport id
        elif self.playing_music:
            if percent > 1:
                self.send_packet(
                    "boss_bar",
                    self.buff_type.pack_uuid(self.music_bar_uuid),
                    self.buff_type.pack_varint(2),
                    self.buff_type.pack("f", 1),
                )
                self.send_packet(
                    "boss_bar",
                    self.buff_type.pack_uuid(self.music_bar_uuid),
                    self.buff_type.pack_varint(3),
                    self.buff_type.pack_chat(
                        Message({
                            "text": "Server is still loading -- hang tight!",
                            "color": "bold",
                        })),
                )

                self.playing_music = False
                return
            self.send_packet(
                "boss_bar",
                self.buff_type.pack_uuid(self.music_bar_uuid),
                self.buff_type.pack_varint(2),
                self.buff_type.pack("f", percent),
            )
コード例 #24
0
ファイル: __init__.py プロジェクト: PhiPhi1/queue-plus
	def __init__(self, *args, **kwargs):
		self.core = CoreProtocol(self)
		self._uuid = UUID.random()
		self.real_uuid = None
		
		super(DownstreamProtocol, self).__init__(*args, **kwargs)
コード例 #25
0
def test_pack_uuid():
    assert Buffer.pack_uuid(UUID.from_bytes(uuid_vector)) == uuid_vector
コード例 #26
0
ファイル: test_types.py プロジェクト: vcokltfre/quarry
def test_uuid_from_offline_player():
    uuid = UUID.from_offline_player("Notch")
    assert isinstance(uuid, UUID)
    assert uuid.to_bytes() == bytes_vector
コード例 #27
0
 def from_token(cls, client_token, access_token, display_name, uuid):
     obj = cls(client_token, access_token, display_name,
               UUID.from_hex(uuid))
     return obj.validate()
コード例 #28
0
ファイル: test_types.py プロジェクト: vcokltfre/quarry
def test_uuid_from_hex_to_byte():
    uuid = UUID.from_hex(hex_vector)
    assert isinstance(uuid, UUID)
    assert uuid.to_bytes() == bytes_vector
コード例 #29
0
 def _from_response(cls, response):
     return cls(response['clientToken'], response['accessToken'],
                response['selectedProfile']['name'],
                UUID.from_hex(response['selectedProfile']['id']))
コード例 #30
0
entity_metadata_vectors = [
    (OrderedDict(
        (((0, 0), 0), ((1, 1), 1), ((2, 2), 2.0), ((3, 3), u'three'),
         ((4, 4), Message({'text':
                           u'four'})), ((5, 5), Message({'text':
                                                         u'five'})), ((6, 6), {
                                                             'count':
                                                             1,
                                                             'item':
                                                             267,
                                                             'tag':
                                                             TagRoot({})
                                                         }), ((7, 7), True),
         ((8, 8), (7.699999809265137, 7.699999809265137, 7.699999809265137)),
         ((9, 9), (8, 8, 8)), ((10, 10), (9, 9, 9)), ((11, 11), 10),
         ((12, 12), UUID.from_bytes(uuid_vector)), ((13, 13), 12),
         ((14, 14), TagRoot({u'foo': TagString(u'bar')})))), b'\x00\x00\x00'
     b'\x01\x01\x01'
     b'\x02\x02\x40\x00\x00\x00'
     b'\x03\x03\x05three'
     b'\x04\x04\x10{"text": "four"}'
     b'\x05\x05\x01\x10{"text": "five"}'
     b'\x06\x06\x01\x0b\x01\x00'
     b'\x07\x07\x01'
     b'\x08\x08\x40\xf6\x66\x66\x40\xf6\x66\x66\x40\xf6\x66\x66'
     b'\x09\x09\x00\x00\x02\x00\x20\x00\x00\x08'
     b'\x0a\x0a\x01\x00\x00\x02\x40\x24\x00\x00\x09'
     b'\x0b\x0b\x0a'
     b'\x0c\x0c\x01' + uuid_vector + b'\x0d\x0d\x0c'
     b'\x0e\x0e\x08\x00\x03foo\x00\x03bar'
     b'\xff')
コード例 #31
0
 def send_chat_message(self, message):
     self.protocol.send_packet(
         'chat_message', self.protocol.buff_type.pack_string(message),
         self.protocol.buff_type.pack("b", 1),
         self.protocol.buff_type.pack_uuid(UUID(int=0)))
コード例 #32
0
 def generate_uuid(self):
     return QuarryUUID.from_hex(py_uuid.uuid4().hex)
コード例 #33
0
 def create(self):
     self.protocol_version = self.config["global"]["protocol_version"]
     self.protocol_mode = "init"
     self.uuid = UUID.random()  # UUID can be overriden