# Path: twistedbot/packets.py
# def ucs2(name):
#     def ucs2_encode(data, errors="replace"):
#         def encode(self, input, final=False):
#     def _encode(self, obj, context):
# def AlphaString(name):
# def Bool(*args, **kwargs):
# def ByteString(name, size_name, encoding=None):
#     def _decode(self, obj, context):
# def NBTdata(name, size_name):
# def itemstack_as_slotdata(itemstack):
#     def _decode(self, obj, context):
#     def _encode(self, obj, context):
# def packet_stream_print_header(context):
# def print_and_return(pv, rv):
# def parse_packets(bytestream):
# def parse_packets_incrementally(bytestream):
# def make_packet(packet, payload, template=None):
# def make_error_packet(message):
#     class UCS2IncrementalEncoder(IncrementalEncoder):
#     class UCS2IncrementalDecoder(BufferedIncrementalDecoder):
#     class UCS2StreamWriter(StreamWriter):
#     class UCS2StreamReader(StreamReader):
# class DoubleAdapter(LengthValueAdapter):
# class NBTAdapter(Adapter):
# class MetadataAdapter(Adapter):
# 
# Path: twistedbot/packets.py
# def ucs2(name):
#     def ucs2_encode(data, errors="replace"):
#         def encode(self, input, final=False):
#     def _encode(self, obj, context):
# def AlphaString(name):
# def Bool(*args, **kwargs):
# def ByteString(name, size_name, encoding=None):
#     def _decode(self, obj, context):
# def NBTdata(name, size_name):
# def itemstack_as_slotdata(itemstack):
#     def _decode(self, obj, context):
#     def _encode(self, obj, context):
# def packet_stream_print_header(context):
# def print_and_return(pv, rv):
# def parse_packets(bytestream):
# def parse_packets_incrementally(bytestream):
# def make_packet(packet, payload, template=None):
# def make_error_packet(message):
#     class UCS2IncrementalEncoder(IncrementalEncoder):
#     class UCS2IncrementalDecoder(BufferedIncrementalDecoder):
#     class UCS2StreamWriter(StreamWriter):
#     class UCS2StreamReader(StreamReader):
# class DoubleAdapter(LengthValueAdapter):
# class NBTAdapter(Adapter):
# class MetadataAdapter(Adapter):


import operator
import types
import twistedbot.logbot as logbot
from collections import defaultdict
from twistedbot.packets import packets
from twistedbot.packets import Container, Metadata
from pynbt import NBTFile
# 62 named sound effect
#########################################################################################################

ignore_packets = []
filter_packets = []

statistics = defaultdict(lambda: defaultdict(int))


def format_packet(data, prefix="  ", depth=1):
    """ return formated string of the packet """
    prefixstr = prefix * depth
    if isinstance(data, NBTFile):
        return data.pretty(indent=depth, indent_str=prefix)
    if isinstance(data, Container) or isinstance(data, types.DictType):
        out = []
        for k, v in data.iteritems():
            if isinstance(v, Metadata):
                pr = str(v.value)
            elif isinstance(v, types.StringType):
                if len(v) < 20:
                    pr = v
                else:
                    pr = v[:20], "... string is %d bytes long" % len(v)
            elif isinstance(v, types.BooleanType) or isinstance(v, types.IntType):
                pr = str(v)
            elif isinstance(v, types.LongType) or isinstance(v, types.FloatType):
                pr = str(v)
            elif isinstance(v, types.UnicodeType):
                pr = v.encode('utf8')

# Path: twistedbot/packets.py
# def ucs2(name):
#     def ucs2_encode(data, errors="replace"):
#         def encode(self, input, final=False):
#     def _encode(self, obj, context):
# def AlphaString(name):
# def Bool(*args, **kwargs):
# def ByteString(name, size_name, encoding=None):
#     def _decode(self, obj, context):
# def NBTdata(name, size_name):
# def itemstack_as_slotdata(itemstack):
#     def _decode(self, obj, context):
#     def _encode(self, obj, context):
# def packet_stream_print_header(context):
# def print_and_return(pv, rv):
# def parse_packets(bytestream):
# def parse_packets_incrementally(bytestream):
# def make_packet(packet, payload, template=None):
# def make_error_packet(message):
#     class UCS2IncrementalEncoder(IncrementalEncoder):
#     class UCS2IncrementalDecoder(BufferedIncrementalDecoder):
#     class UCS2StreamWriter(StreamWriter):
#     class UCS2StreamReader(StreamReader):
# class DoubleAdapter(LengthValueAdapter):
# class NBTAdapter(Adapter):
# class MetadataAdapter(Adapter):
# 
# Path: twistedbot/packets.py
# def ucs2(name):
#     def ucs2_encode(data, errors="replace"):
#         def encode(self, input, final=False):
#     def _encode(self, obj, context):
# def AlphaString(name):
# def Bool(*args, **kwargs):
# def ByteString(name, size_name, encoding=None):
#     def _decode(self, obj, context):
# def NBTdata(name, size_name):
# def itemstack_as_slotdata(itemstack):
#     def _decode(self, obj, context):
#     def _encode(self, obj, context):
# def packet_stream_print_header(context):
# def print_and_return(pv, rv):
# def parse_packets(bytestream):
# def parse_packets_incrementally(bytestream):
# def make_packet(packet, payload, template=None):
# def make_error_packet(message):
#     class UCS2IncrementalEncoder(IncrementalEncoder):
#     class UCS2IncrementalDecoder(BufferedIncrementalDecoder):
#     class UCS2StreamWriter(StreamWriter):
#     class UCS2StreamReader(StreamReader):
# class DoubleAdapter(LengthValueAdapter):
# class NBTAdapter(Adapter):
# class MetadataAdapter(Adapter):


# Path: twistedbot/proxy_processors/default.py
import operator
import types
import twistedbot.logbot as logbot
from collections import defaultdict
from twistedbot.packets import packets
from twistedbot.packets import Container, Metadata
from pynbt import NBTFile

# 62 named sound effect
#########################################################################################################

ignore_packets = []
filter_packets = []

statistics = defaultdict(lambda: defaultdict(int))


def format_packet(data, prefix="  ", depth=1):
    """ return formated string of the packet """
    prefixstr = prefix * depth
    if isinstance(data, NBTFile):
        return data.pretty(indent=depth, indent_str=prefix)
    if isinstance(data, Container) or isinstance(data, types.DictType):
        out = []
        for k, v in data.iteritems():
            if isinstance(v, Metadata):
                pr = str(v.value)
            elif isinstance(v, types.StringType):
                if len(v) < 20:
                    pr = v
                else:
                    pr = v[:20], "... string is %d bytes long" % len(v)
            elif isinstance(v, types.BooleanType) or isinstance(v, types.IntType):
                pr = str(v)
            elif isinstance(v, types.LongType) or isinstance(v, types.FloatType):
                pr = str(v)
            elif isinstance(v, types.UnicodeType):
                pr = v.encode('utf8')

            elif isinstance(v, Container):