Пример #1
0
        private static async Task Handshake(Client client, byte[] data)
        {
            MCSerializer serializer      = new MCSerializer(new MemoryStream(data));
            int          protocolVersion = serializer.ReadVarInt();

            String host         = serializer.ReadString(255);
            ushort port         = serializer.ReadUShort();
            int    nextStateInt = serializer.ReadVarInt();

            if (nextStateInt > 4)
            {
                client.State = ClientState.Closed;
                return;
            }

            ClientState nextState = (ClientState)nextStateInt;

            if (nextState != ClientState.Status && nextState != ClientState.Login)
            {
                client.State = ClientState.Closed;
                return;
            }

            client.State = nextState;
            Console.WriteLine("Protocol #" + protocolVersion + ", Host: " + host + ":" + port + ", Next State: " + nextState);
        }
Пример #2
0
        public static async Task ClientSettings(Client client, byte[] data)
        {
            MCSerializer serializer = new MCSerializer(new MemoryStream(data));

            client.Settings.Locale             = serializer.ReadString(16);
            client.Settings.ViewDistance       = serializer.ReadByte();
            client.Settings.ChatMode           = (ChatMode)serializer.ReadVarInt();
            client.Settings.ChatColors         = serializer.ReadBool();
            client.Settings.DisplayedSkinParts = serializer.ReadByte();
            client.Settings.MainHand           = (PlayerHand)serializer.ReadVarInt();
        }
Пример #3
0
        public static async Task PluginMessage(Client client, byte[] data)
        {
            MCSerializer serializer = new MCSerializer(new MemoryStream(data));
            String       channel    = serializer.ReadString(16);

            if (!channel.Contains(":"))
            {
                channel = "minecraft:" + channel;
            }
            String message = Encoding.ASCII.GetString(serializer.ReadBytes());

            Console.WriteLine("Recv Message: [" + channel + "] " + message);
        }