Esempio n. 1
0
 private void SendSettings()
 {
     if (File.Exists("properties/server.properties"))
     {
         Packet p = new Packet(Encoding.UTF8, false);
         p.addData((byte)PacketId.SSettings);
         p.addData(File.ReadAllText("properties/server.properties", Encoding.UTF8), false);
         packetQ.Enqueue(p);
     }
     else
     {
         Server.s.Log("Error No server properties found");
     }
 }
Esempio n. 2
0
 private void Step(byte e)
 {
     Packet p = new Packet(Encoding.UTF8, false);
     p.addData((byte)PacketId.SProgress);
     p.addData(e);
     packetQ.Enqueue(p);
 }
Esempio n. 3
0
 void PlayerConnect(Player p)
 {
     Thread.Sleep(500);                                           //Wait for stuff to finish
     Packet e = new Packet(Encoding.UTF8, false);
     e.addData((byte)PacketId.SPlayers);
     e.addData((byte)0);                                          //Player connect
     e.addData(p.title);
     e.addData(p.name);
     e.addData(p.group.name);
     packetQ.Enqueue(e);
 }
Esempio n. 4
0
 void PlayerDisconnect(Player p, string reason)
 {
     Packet e = new Packet(Encoding.UTF8, false);
     e.addData((byte)PacketId.SPlayers);
     e.addData((byte)1);                                          //Player disconnect
     e.addData(p.name);
     packetQ.Enqueue(e);
 }
Esempio n. 5
0
 void OnPlayerChat(Player p, string message)
 {
     message = "%f[" + p.color + p.name + "%f]" + message;
     Packet e = new Packet(Encoding.UTF8, false);
     e.addData((byte)PacketId.SChat);
     e.addData((byte)2); //Player chat
     e.addData(message);
     packetQ.Enqueue(e);
 }
Esempio n. 6
0
        private void Ping()
        {
            if (!recievedPing)
            {
                //Disconnect();
                //return;
            }
            recievedPing = false;
            short numb = (short)new Random().Next();
            pingNumb = numb;

            Packet o = new Packet(Encoding.UTF8, false);
            o.addData((byte)PacketId.SPing);
            o.addData(numb);

            Thread.Sleep(30000);
        }
Esempio n. 7
0
 void OnGroupChange(Group g)
 {
     Packet p = new Packet(Encoding.UTF8, false);
     p.addData((byte)PacketId.SGroups);
     if (g.color.Length >= 2)
         p.addData(g.color[1] + g.name);
     else
         p.addData('f' + g.name);
     p.addData((short)g.Permission);
     p.addData(g.maxUndo);
     p.addData(g.maxBlocks);
     packetQ.Enqueue(p);
 }
Esempio n. 8
0
 void OnLog(string mesg)
 {
     Packet p = new Packet(Encoding.UTF8, false);
     p.addData((byte)PacketId.SChat);
     p.addData((byte)4); //Logs
     p.addData(mesg);
     packetQ.Enqueue(p);
 }
Esempio n. 9
0
 void LevelUnload(string s)
 {
     Packet p = new Packet(Encoding.UTF8, false);
     p.addData((byte)PacketId.SMaps);
     p.addData((byte)1);
     p.addData(s);
     packetQ.Enqueue(p);
 }
Esempio n. 10
0
 void LevelLoad(Level l)
 {
     Packet p = new Packet(Encoding.UTF8, false);
     p.addData((byte)PacketId.SMaps);
     p.addData((byte)0);
     p.addData(l.name);
     packetQ.Enqueue(p);
 }
Esempio n. 11
0
        private void HandleLogin()
        {
            string msg = ReadString(reader.ReadInt16());
            Packet p;
            if (msg.StartsWith(this.version.ToString())) //TODO: make a better checker
                msg = msg.Replace(string.Format("{0}: ", this.version.ToString()), "");
            else
            {
                p = new Packet(Encoding.UTF8, false);
                p.addData((byte)PacketId.SLogin);
                p.addData((byte)3);
                packetQ.Enqueue(p);
                Server.s.Log("[Remote] A remote tried to connect with a different version.");
                Disconnect();
                return;
            }
            if (RemoteServer.tries >= 0x3)
            {
                p = new Packet(Encoding.UTF8, false);
                p.addData((byte)PacketId.SLogin);
                p.addData((byte)4);
                packetQ.Enqueue(p);
                Server.s.Log("[Remote] A remote tried to connect with exceeding incorrect credentials");
                Disconnect();
            }
            if (RemoteServer.tries == 0x6)
            {
                p = new Packet(Encoding.UTF8, false);
                p.addData((byte)PacketId.SLogin);
                p.addData((byte)5);
                packetQ.Enqueue(p);
                Server.s.Log("[Remote] Remote was locked from the console, type \"/remote tryreset\" to reset the try count");
                Disconnect();
            }

            if (msg.Split(':')[0] == RemoteServer.Username && msg.Split(':')[1] == RemoteServer.Password)
            {

                //if (OnRemoteLogin != null) OnRemoteLogin(this);
                p = new Packet(Encoding.UTF8, false);
                p.addData((byte)PacketId.SLogin);
                p.addData((byte)1);
                packetQ.Enqueue(p);
                //SendKey();
                Server.s.Log("[Remote] Remote Verified, passing controls to it!");
                isLoggedIn = true;
                Remote.remoteList.Add(this);
                LoadEvents();
                //StartUp();
                return;

            }
            else
            {
                p = new Packet(Encoding.UTF8, false);
                p.addData((byte)PacketId.SLogin);
                p.addData((byte)2);
                packetQ.Enqueue(p);
                Server.s.Log("[Remote] A Remote with incorrect information attempted to join.");
                Disconnect();
                RemoteServer.tries++;

            }
        }
Esempio n. 12
0
 void LevelLoad(Level l)
 {
     Packet p = new Packet(Encoding.UTF8, true);
     p.addData((byte)PacketId.SMaps);
     p.addData((byte)0);
     p.addData(l.name);
     p.addData((short)l.length);
     p.addData((short)l.height);
     p.addData((short)l.width);
     p.addData((short)l.permissionbuild);
     p.addData((short)l.permissionvisit);
     packetQ.Enqueue(p);
     p = new Packet(Encoding.UTF8, true);
     p.addData((byte)PacketId.SMaps);
     p.addData((byte)3);
     p.addData(l.name);
     packetQ.Enqueue(p);
 }
Esempio n. 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PacketReadEventArgs"/> class.
 /// </summary>
 /// <param name="p">The packet.</param>
 public PacketReadEventArgs(Packet p) {
     Packet = p;
 }