Esempio n. 1
0
 public static async Task HandleClientSettings(Client client, PacketReader reader)
 {
     //TODO: save these settings in Player
     string locale = await reader.ReadString();
     byte viewDistance = await reader.ReadByte();
     byte chatFlags = await reader.ReadByte();
     byte difficulty = await reader.ReadByte();
     bool cape = await reader.ReadBoolean();
 }
Esempio n. 2
0
        public static async Task HandleServerStats(Client client, PacketReader reader)
        {
            await reader.ReadByte();
            using (var packet = new PacketWriter(SendOpcode.Kick))
            {
                packet.WriteString("§1\0{0}\0{1}\0{2}\0{3}\0{4}", 
                    Server.Protocol, Server.Version, Server.Instance.GetMOTD(),
                    Server.Instance.PlayerCount, Server.Instance.Max);

                client.Send(packet);
            }
        }
Esempio n. 3
0
        public static async Task HandlePlayerAbility(Client client, PacketReader reader)
        {
            byte flags = await reader.ReadByte();
            byte flySpeed = await reader.ReadByte();
            byte walkSpeed = await reader.ReadByte();

            Player player = client.Player;
            player.GodMode = (flags & 8) != 0;
            player.FlyingAllowed = (flags & 4) != 0;
            player.IsFlying = (flags & 2) != 0;
            player.CreativeMode = (flags & 1) != 0;
            Console.WriteLine("Godmode is {0}, flymode is {1}, flying is {2}, creative is {3}", player.GodMode, player.FlyingAllowed, player.IsFlying, player.CreativeMode);
            player.FlySpeed = flySpeed;
            player.WalkSpeed = walkSpeed;

            using (var packet = new PacketWriter(SendOpcode.PlayerAbility))
            {
                packet.Write(flags);
                packet.Write(flySpeed);
                packet.Write(walkSpeed);
                client.Send(packet);
            }
        }
Esempio n. 4
0
        public static async Task HandleHandshake(Client client, PacketReader reader)
        {
            byte protocol = await reader.ReadByte();
            string username = await reader.ReadString();
            string host = await reader.ReadString();
            uint port = await reader.ReadUInt32();

            // TODO: This has to happen as a seperate task!! not on this thread
            LoginResult res = client.Authenticate(username, host, port);
            if (res != LoginResult.LoggedIn)
            {
                using (var packet = new PacketWriter(SendOpcode.Kick))
                {
                    packet.WriteString("DERP!!! Server disconnected, reason: {0}", res.ToString());
                    client.Send(packet);
                }
            }
            else
            {
                //TODO: chunks?
            }
        }