Ejemplo n.º 1
0
    def message(self, message="", position=0):
        """
        Sends a message to the player.

        :Args:
            :message: Can be text, colorcoded text, or chat dictionary of json.
            :position:  an integer 0-2.  2 will place it above XP bar.
             1 or 0 will place it in the chat. Using position 2 will
             only display any text component (or can be used to display
             standard minecraft translates, such as
             "{'translate': 'commands.generic.notFound', 'color': 'red'}" and
             "{'translate': 'tile.bed.noSleep'}")


        :returns: Nothing


        """

        if self.wrapper.proxy:
            if isinstance(message, dict):
                sentitem = message
            else:
                sentitem = processoldcolorcodes(message)

            self.client.chat_to_client(sentitem, position)
        else:
            self.javaserver.broadcast(message, who=self.username)
Ejemplo n.º 2
0
    def actionMessage(self, message=""):
        if self.getClient().version < PROTOCOL_1_8START:
            parsing = [_STRING, _NULL]
            data = [message]
        else:
            parsing = [_STRING, _BYTE]
            data = (json.dumps({"text": processoldcolorcodes(message)}), 2)

        self.getClient().packet.sendpkt(
            self.clientboundPackets.CHAT_MESSAGE,
            parsing,  # "string|byte"
            data)
Ejemplo n.º 3
0
    def actionMessage(self, message=""):
        try:
            version = self.wrapper.proxy.srv_data.protocolVersion
        except AttributeError:
            # Non proxy mode
            return False

        if version < PROTOCOL_1_8START:
            parsing = [_STRING, _NULL]
            data = [message]
        else:
            parsing = [_STRING, _BYTE]
            data = (json.dumps({"text": processoldcolorcodes(message)}), 2)

        self.client.packet.sendpkt(
            self.clientboundPackets.CHAT_MESSAGE,
            parsing,  # "string|byte"
            data)