Beispiel #1
0
 void Say(string text)
 {
     string[] args = text.Split(new char[1] {
         ' '
     }, 3);
     Packets.chatMessage Message = new Packets.chatMessage(Socket, Mainform, args[2], true);
 }
Beispiel #2
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            if (chat.Text.StartsWith("+"))
            {
                commandHandler ch = new commandHandler(nh.socket, this, "Minebot: " + chat.Text);
                chat.Clear();
                return;
            }

            Packets.chatMessage chatmess = new Packets.chatMessage(nh.socket, this, chat.Text, true);
            chat.Clear();
        }
Beispiel #3
0
 void Mute()
 {
     if (Mainform.muted)
     {
         Mainform.muted = false;
         Packets.chatMessage chat = new Packets.chatMessage(Socket, Mainform, "Unmuted.", true);
     }
     else
     {
         Mainform.muted = true;
         Packets.chatMessage chat = new Packets.chatMessage(Socket, Mainform, "Muted.", true);
     }
 }
Beispiel #4
0
        void findBlock(string[] args)
        {
            // Attempt on an alternitive block lookup method, for speed's sake..
            functions lookup = new functions();

            if (!lookup.isNumeric(args[2]))
            {
                return;
            }
            if (!lookup.isNumeric(args[3]))
            {
                return;
            }
            if (!lookup.isNumeric(args[4]))
            {
                return;
            }

            int blockX = int.Parse(args[2]);
            int blockY = int.Parse(args[3]);
            int blockZ = int.Parse(args[4]);

            decimal ChunkX = decimal.Divide(blockX, 16);
            decimal ChunkZ = decimal.Divide(blockZ, 16);

            ChunkX = Math.Floor(ChunkX);
            ChunkZ = Math.Floor(ChunkZ);

            Classes.Chunk    thisChunk = null;
            Classes.MapBlock thisblock = null;

            foreach (Classes.Chunk b in Mainform.Chunks)
            {
                if (b.x == ChunkX & b.z == ChunkZ)
                {
                    thisChunk = b;
                    break;
                }
            }

            thisblock = thisChunk.getBlock(blockX, blockY, blockZ);

            if (thisblock != null)
            {
                Packets.chatMessage cm = new Packets.chatMessage(Socket, Mainform, "FOUND IT. " + thisblock.Name, true);
            }
            else
            {
                Packets.chatMessage cm = new Packets.chatMessage(Socket, Mainform, "Fail :(", true);
            }
        }
Beispiel #5
0
        void findEnt(Form1 mainform)
        {
            int count = 0;

            foreach (Classes.Entity b in mainform.Entitys)
            {
                if (b.name == "Slime")
                {
                    count++;
                }
            }

            Packets.chatMessage chat = new Packets.chatMessage(Socket, mainform, "There are " + count.ToString() + " Slimes near you.", true);
        }
Beispiel #6
0
 void follow(string[] args)
 {
     if (Mainform.following == false)
     {
         Mainform.following = true;
         Mainform.fname     = args[2];
         Packets.chatMessage chat = new Packets.chatMessage(Socket, Mainform, "Following " + args[2], true);
     }
     else
     {
         Mainform.following = false;
         Mainform.fname     = "";
         Packets.chatMessage chat = new Packets.chatMessage(Socket, Mainform, "No longer following.", true);
     }
 }
Beispiel #7
0
        void placeBlock(string[] args)
        {
            functions lookup = new functions();

            if (!lookup.isNumeric(args[2]))
            {
                return;
            }
            if (!lookup.isNumeric(args[3]))
            {
                return;
            }
            if (!lookup.isNumeric(args[4]))
            {
                return;
            }

            int blockX = int.Parse(args[2]);
            int blockY = int.Parse(args[3]);
            int blockZ = int.Parse(args[4]) - 1; // - 1 corrects some error in sending this packet that results in the Z coord being off.

            int heldSlot = Mainform.selectedSlot + 36;

            Classes.Item heldItem = null;

            foreach (Classes.Item b in Mainform.inventory)
            {
                if (b.slot == heldSlot)
                {
                    heldItem = b;
                    break;
                }
            }

            if (heldItem != null)
            {
                Packets.placeBlock myblock = new Packets.placeBlock(blockX, (byte)blockY, blockZ, 3, heldItem, Socket);
            }
            else
            {
                Packets.chatMessage chat = new Packets.chatMessage(Socket, Mainform, "Not holding anything.", true);
            }
        }
Beispiel #8
0
 public void handlePackets()
 {
     try {
         int id = 9999;
         while ((id = (int)socket.readByte()) != 9999)
         {
             if (chatq == true)
             {
                 Packets.chatMessage chatmess = new Packets.chatMessage(socket, myform, chatqueue, true);
                 chatq     = false;
                 chatqueue = "";
             }
             if (baseSock.Connected == true)
             {
                 if (id == 2 || id == 3 || id == 13 || id == 16 || id == 18 || id == 101 || id == 107 || id == 252 || id == 253 || id == 255)
                 {
                     var packet = Activator.CreateInstance(Type.GetType(packetTypes[id].ToString()), new Object[] { socket, myform, false }); // Tried a few ways around having to do this if-statement. No go on any of them.
                 }
                 else
                 {
                     var packet = Activator.CreateInstance(Type.GetType(packetTypes[id].ToString()), new Object[] { socket, myform }); // New and improved handling.
                 }
                 last = id;
             }
             else
             {
                 baseSock.Close();
                 myform.puts("Disconnected from server");
                 handler.Abort();
             }
         }
     }
     catch {
         baseSock.Close();
         myform.puts("Disconnected from server.");
         handler.Abort();
     }
 }
Beispiel #9
0
        public void IRCSock_DataArrival(object sender, WinsockDataArrivalEventArgs e)
        {
            string incoming = Encoding.UTF8.GetString((byte[])IRCSock.Get());
            string host     = "";
            string dat      = "";
            string message  = "";

            string[] splits;
            int      index = 0;

            splits = incoming.Split('\r', '\n');

            for (int b = 0; (splits.Length - 1) >= b; b++)
            {
                splits[b] = splits[b].Replace("\r\n", "");
                splits[b] = splits[b].Replace("\n", "");
                splits[b] = splits[b].Replace("\r", "");
            }

            do
            {
                incoming = splits[index];

                if (incoming.Contains(" "))
                {
                    if (incoming.Contains("/NAMES list"))
                    {
                        canTalk = true;
                    }

                    if (incoming.Substring(0, 1) == ":")
                    {
                        host = incoming.Substring(1, incoming.IndexOf(" ") - 1);
                    }
                    else
                    {
                        host = incoming.Substring(0, incoming.IndexOf(" "));
                    }

                    dat = incoming.Substring(incoming.IndexOf(" ") + 1, incoming.Length - (incoming.IndexOf(" ") + 1));

                    if (dat.Contains(":"))
                    {
                        message = dat.Substring(dat.IndexOf(":") + 1, dat.Length - (dat.IndexOf(":") + 1));
                    }

                    if (host == "PING")
                    {
                        send("PONG " + dat);
                        return;
                    }

                    string   second   = dat.Substring(0, dat.IndexOf(" "));
                    string[] mysplits = dat.Split(new string[] { " " }, 4, StringSplitOptions.None);

                    message = message.Replace("\r\n", "");

                    switch (second)
                    {
                    case "PRIVMSG":
                        if (ircmode == 1 || ircmode == 3 && message.StartsWith("+") == false)
                        {
                            nh.socket.writeByte(3);
                            nh.socket.writeString("IRC: <" + host.Substring(0, host.IndexOf("!")) + "> " + message);
                        }
                        if (message.StartsWith("="))
                        {
                            string cmd = mysplits[2].Substring(1, mysplits[2].Length - 1);

                            switch (cmd.ToLower())
                            {
                            case "=say":
                                if (mysplits.Length > 3)
                                {
                                    ircmessage(mysplits[3]);
                                }
                                break;

                            case "=ssay":
                                Packets.chatMessage mypacket;
                                if (mysplits.Length > 3)
                                {
                                    mypacket = new Packets.chatMessage(nh.socket, this, mysplits[3], true);
                                }
                                break;

                            case "=help":
                                ircmessage("C# Minebot IRC Client, Version 1.1");
                                ircmessage("Only functional to relay messages between IRC channels and minecraft servers.");
                                ircmessage("Commands are =say, =ssay, and =help.");
                                break;
                            }
                        }

                        break;

                    case "376":
                        send("JOIN " + channel);
                        ircmessage("Current mode: " + ircmode);
                        break;
                    }
                }
                index++;
            } while (index == splits.Length - 1);

            incoming = "";
        }
Beispiel #10
0
 void import(string[] args)
 {
     Mainform.importing  = true;
     Mainform.importName = args[2];
     Packets.chatMessage chat = new Packets.chatMessage(Socket, Mainform, "Place an Iron Ore marker to import.", true);
 }
Beispiel #11
0
 void pos()
 {
     Packets.chatMessage chat = new Packets.chatMessage(Socket, Mainform, "X: " + Mainform.location[0].ToString() + " Y: " + Mainform.location[1].ToString() + " Z: " + Mainform.location[2].ToString(), true);
 }