public void showMBs(Player p)
        {
            p.showMBs = !p.showMBs;

            using (DataTable Messages = Server.useMySQL ? MySQL.fillData("SELECT * FROM `Messages" + p.level.name + "`") : SQLite.fillData("SELECT * FROM `Messages" + p.level.name + "`"))
            {
                int i;

                if (p.showMBs)
                {
                    for (i = 0; i < Messages.Rows.Count; i++)
                    {
                        p.SendBlockchange((ushort)Messages.Rows[i]["X"], (ushort)Messages.Rows[i]["Y"], (ushort)Messages.Rows[i]["Z"], Block.MsgWhite);
                    }
                    Player.SendMessage(p, "Now showing &a" + i.ToString() + Server.DefaultColor + " MBs.");
                }
                else
                {
                    for (i = 0; i < Messages.Rows.Count; i++)
                    {
                        p.SendBlockchange((ushort)Messages.Rows[i]["X"], (ushort)Messages.Rows[i]["Y"], (ushort)Messages.Rows[i]["Z"], p.level.GetTile((ushort)Messages.Rows[i]["X"], (ushort)Messages.Rows[i]["Y"], (ushort)Messages.Rows[i]["Z"]));
                    }
                    Player.SendMessage(p, "Now hiding MBs.");
                }
            }
        }
Exemple #2
0
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            cpos.message = cpos.message.Replace("'", "\\'");

            DataTable Messages = MySQL.fillData("SELECT * FROM `Messages" + p.level.name + "` WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z);

            Messages.Dispose();

            if (Messages.Rows.Count == 0)
            {
                MySQL.executeQuery("INSERT INTO `Messages" + p.level.name + "` (X, Y, Z, Message) VALUES (" + (int)x + ", " + (int)y + ", " + (int)z + ", '" + cpos.message + "')");
            }
            else
            {
                MySQL.executeQuery("UPDATE `Messages" + p.level.name + "` SET Message='" + cpos.message + "' WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z);
            }

            Player.SendMessage(p, "Message block placed.");
            p.level.Blockchange(p, x, y, z, cpos.type);
            p.SendBlockchange(x, y, z, cpos.type);

            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }
            if (message.IndexOf("'") != -1)
            {
                Player.SendMessage(p, "Cannot parse request."); return;
            }

            DataTable playerDb = Server.useMySQL ? MySQL.fillData("SELECT Name FROM Players WHERE IP='" + message + "'") : SQLite.fillData("SELECT Name FROM Players WHERE IP='" + message + "'");

            if (playerDb.Rows.Count == 0)
            {
                Player.SendMessage(p, "Could not find anyone with this IP"); return;
            }

            string playerNames = "Players with this IP: ";

            for (int i = 0; i < playerDb.Rows.Count; i++)
            {
                playerNames += playerDb.Rows[i]["Name"] + ", ";
            }
            playerNames = playerNames.Remove(playerNames.Length - 2);

            Player.SendMessage(p, playerNames);
            playerDb.Dispose();
        }
Exemple #4
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                message = p.name;
            }

            string originalName = message.ToLower();

            Player who = Player.Find(message);

            if (who == null)
            {
                Player.SendMessage(p, "Could not find player. Searching Player DB.");

                DataTable FindIP = Server.useMySQL ? MySQL.fillData("SELECT IP FROM Players WHERE Name='" + message + "'") : SQLite.fillData("SELECT IP FROM Players WHERE Name='" + message + "'");

                if (FindIP.Rows.Count == 0)
                {
                    Player.SendMessage(p, "Could not find any player by the name entered."); FindIP.Dispose(); return;
                }

                message = FindIP.Rows[0]["IP"].ToString();
                FindIP.Dispose();
            }
            else
            {
                message = who.ip;
            }

            DataTable Clones = Server.useMySQL ? MySQL.fillData("SELECT Name FROM Players WHERE IP='" + message + "'") : SQLite.fillData("SELECT Name FROM Players WHERE IP='" + message + "'");

            if (Clones.Rows.Count == 0)
            {
                Player.SendMessage(p, "Could not find any record of the player entered."); return;
            }

            List <string> foundPeople = new List <string>();

            for (int i = 0; i < Clones.Rows.Count; ++i)
            {
                if (!foundPeople.Contains(Clones.Rows[i]["Name"].ToString().ToLower()))
                {
                    foundPeople.Add(Clones.Rows[i]["Name"].ToString().ToLower());
                }
            }

            Clones.Dispose();
            if (foundPeople.Count <= 1)
            {
                Player.SendMessage(p, originalName + " has no clones."); return;
            }

            Player.SendMessage(p, "These people have the same IP address:");
            Player.SendMessage(p, string.Join(", ", foundPeople.ToArray()));
        }
        public void ExitChange(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);

            p.SendBlockchange(x, y, z, b);
            portalPos bp = (portalPos)p.blockchangeObject;

            foreach (portPos pos in bp.port)
            {
                DataTable Portals = Server.useMySQL ? MySQL.fillData("SELECT * FROM `Portals" + pos.portMapName + "` WHERE EntryX=" + (int)pos.x + " AND EntryY=" + (int)pos.y + " AND EntryZ=" + (int)pos.z) : SQLite.fillData("SELECT * FROM `Portals" + pos.portMapName + "` WHERE EntryX=" + (int)pos.x + " AND EntryY=" + (int)pos.y + " AND EntryZ=" + (int)pos.z);
                Portals.Dispose();

                if (Portals.Rows.Count == 0)
                {
                    if (Server.useMySQL)
                    {
                        MySQL.executeQuery("INSERT INTO `Portals" + pos.portMapName + "` (EntryX, EntryY, EntryZ, ExitMap, ExitX, ExitY, ExitZ) VALUES (" + (int)pos.x + ", " + (int)pos.y + ", " + (int)pos.z + ", '" + p.level.name + "', " + (int)x + ", " + (int)y + ", " + (int)z + ")");
                    }
                    else
                    {
                        SQLite.executeQuery("INSERT INTO `Portals" + pos.portMapName + "` (EntryX, EntryY, EntryZ, ExitMap, ExitX, ExitY, ExitZ) VALUES (" + (int)pos.x + ", " + (int)pos.y + ", " + (int)pos.z + ", '" + p.level.name + "', " + (int)x + ", " + (int)y + ", " + (int)z + ")");
                    }
                }
                else
                {
                    if (Server.useMySQL)
                    {
                        MySQL.executeQuery("UPDATE `Portals" + pos.portMapName + "` SET ExitMap='" + p.level.name + "', ExitX=" + (int)x + ", ExitY=" + (int)y + ", ExitZ=" + (int)z + " WHERE EntryX=" + (int)pos.x + " AND EntryY=" + (int)pos.y + " AND EntryZ=" + (int)pos.z);
                    }
                    else
                    {
                        SQLite.executeQuery("UPDATE `Portals" + pos.portMapName + "` SET ExitMap='" + p.level.name + "', ExitX=" + (int)x + ", ExitY=" + (int)y + ", ExitZ=" + (int)z + " WHERE EntryX=" + (int)pos.x + " AND EntryY=" + (int)pos.y + " AND EntryZ=" + (int)pos.z);
                    }
                }
                //DB

                if (pos.portMapName == p.level.name)
                {
                    p.SendBlockchange(pos.x, pos.y, pos.z, bp.type);
                }
            }

            Player.SendMessage(p, "&3Exit" + Server.DefaultColor + " block placed");

            if (p.staticCommands)
            {
                bp.port.Clear(); p.blockchangeObject = bp; p.Blockchange += new Player.BlockchangeEventHandler(EntryChange);
            }
        }
Exemple #6
0
        public override void Use(Player p, string message)
        {
            int bancount = Group.findPerm(LevelPermission.Banned).playerList.All().Count;

            DataTable count = MySQL.fillData("SELECT COUNT(id) FROM Players");

            Player.SendMessage(p, "A total of " + count.Rows[0]["COUNT(id)"] + " unique players have visited this server.");
            Player.SendMessage(p, "Of these players, " + bancount + " have been banned.");
            count.Dispose();

            int playerCount = 0;
            int hiddenCount = 0;

            foreach (Player pl in Player.players)
            {
                if (!pl.hidden || p.group.Permission > LevelPermission.AdvBuilder || Server.devs.Contains(p.name.ToLower()))
                {
                    playerCount++;
                    if (pl.hidden && (p.group.Permission > LevelPermission.AdvBuilder || Server.devs.Contains(p.name.ToLower())))
                    {
                        hiddenCount++;
                    }
                }
            }
            if (playerCount == 1)
            {
                if (hiddenCount == 0)
                {
                    Player.SendMessage(p, "There is 1 player currently online.");
                }
                else
                {
                    Player.SendMessage(p, "There is 1 player currently online (" + hiddenCount + " hidden).");
                }
            }
            else
            {
                if (hiddenCount == 0)
                {
                    Player.SendMessage(p, "There are " + playerCount + " players online.");
                }
                else
                {
                    Player.SendMessage(p, "There are " + playerCount + " players online (" + hiddenCount + " hidden).");
                }
            }
        }
Exemple #7
0
        public override void Use(Player p, string message)
        {
            Player pl = Player.Find(message);

            if (pl != null && !pl.hidden)
            {
                Player.SendMessage(p, pl.color + pl.name + Server.DefaultColor + " is currently online.");
                return;
            }

            DataTable playerDb = MySQL.fillData("SELECT * FROM Players WHERE Name='" + message + "'");

            if (playerDb.Rows != null && playerDb.Rows.Count > 0)
            {
                Player.SendMessage(p, message + " was last seen: " + playerDb.Rows[0]["LastLogin"]);
            }
            else
            {
                Player.SendMessage(p, "Unable to find player");
            }
        }
        public void showPortals(Player p)
        {
            p.showPortals = !p.showPortals;

            DataTable Portals = Server.useMySQL ? MySQL.fillData("SELECT * FROM `Portals" + p.level.name + "`") : SQLite.fillData("SELECT * FROM `Portals" + p.level.name + "`");

            int i;

            if (p.showPortals)
            {
                for (i = 0; i < Portals.Rows.Count; i++)
                {
                    if (Portals.Rows[i]["ExitMap"].ToString() == p.level.name)
                    {
                        p.SendBlockchange((ushort)Portals.Rows[i]["ExitX"], (ushort)Portals.Rows[i]["ExitY"], (ushort)Portals.Rows[i]["ExitZ"], Block.orange_portal);
                    }
                    p.SendBlockchange((ushort)Portals.Rows[i]["EntryX"], (ushort)Portals.Rows[i]["EntryY"], (ushort)Portals.Rows[i]["EntryZ"], Block.blue_portal);
                }

                Player.SendMessage(p, "Now showing &a" + i.ToString() + Server.DefaultColor + " portals.");
            }
            else
            {
                for (i = 0; i < Portals.Rows.Count; i++)
                {
                    if (Portals.Rows[i]["ExitMap"].ToString() == p.level.name)
                    {
                        p.SendBlockchange((ushort)Portals.Rows[i]["ExitX"], (ushort)Portals.Rows[i]["ExitY"], (ushort)Portals.Rows[i]["ExitZ"], Block.air);
                    }

                    p.SendBlockchange((ushort)Portals.Rows[i]["EntryX"], (ushort)Portals.Rows[i]["EntryY"], (ushort)Portals.Rows[i]["EntryZ"], p.level.GetTile((ushort)Portals.Rows[i]["EntryX"], (ushort)Portals.Rows[i]["EntryY"], (ushort)Portals.Rows[i]["EntryZ"]));
                }

                Player.SendMessage(p, "Now hiding portals.");
            }

            Portals.Dispose();
        }
Exemple #9
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }
            if (message[0] == '@')
            {
                message = message.Remove(0, 1).Trim();
                Player who = Player.Find(message);
                if (who == null)
                {
                    DataTable ip;
                    int       tryCounter = 0;
                    rerun : try
                    {
                        ip = Server.useMySQL ? MySQL.fillData("SELECT IP FROM Players WHERE Name = '" + message + "'") : SQLite.fillData("SELECT IP FROM Players WHERE Name = '" + message + "'");
                    }
                    catch (Exception e)
                    {
                        tryCounter++;
                        if (tryCounter < 10)
                        {
                            goto rerun;
                        }
                        else
                        {
                            Server.ErrorLog(e);
                            Player.SendMessage(p, "There was a database error fetching the IP address.  It has been logged.");
                            return;
                        }
                    }
                    if (ip.Rows.Count > 0)
                    {
                        message = ip.Rows[0]["IP"].ToString();
                    }
                    else
                    {
                        Player.SendMessage(p, "Unable to find an IP address for that user.");
                        return;
                    }
                    ip.Dispose();
                }
                else
                {
                    message = who.ip;
                }
            }

            if (message.IndexOf('.') == -1)
            {
                Player.SendMessage(p, "Not a valid ip!"); return;
            }
            if (p != null)
            {
                if (p.ip == message)
                {
                    Player.SendMessage(p, "You shouldn't be able to use this command..."); return;
                }
            }
            if (!Server.bannedIP.Contains(message))
            {
                Player.SendMessage(p, message + " doesn't seem to be banned..."); return;
            }
            Server.bannedIP.Remove(message); Server.bannedIP.Save("banned-ip.txt", false);

            if (p != null)
            {
                Server.IRC.Say(message.ToLower() + " was un-ip-banned by " + p.name + ".");
                Server.s.Log("IP-UNBANNED: " + message.ToLower() + " by " + p.name + ".");
                Player.GlobalMessage(message + " was &8un-ip-banned" + Server.DefaultColor + " by " + p.color + p.name + Server.DefaultColor + ".");
            }
            else
            {
                Server.IRC.Say(message.ToLower() + " was un-ip-banned by console.");
                Server.s.Log("IP-UNBANNED: " + message.ToLower() + " by console.");
                Player.GlobalMessage(message + " was &8un-ip-banned" + Server.DefaultColor + " by console.");
            }
        }
Exemple #10
0
        public override void Use(Player p, string message)
        {
            try
            {
                MySQL.executeQuery("CREATE TABLE if not exists `Inbox" + p.name + "` (PlayerFrom CHAR(20), TimeSent DATETIME, Contents VARCHAR(255));");
                if (message == "")
                {
                    DataTable Inbox = MySQL.fillData("SELECT * FROM `Inbox" + p.name + "` ORDER BY TimeSent");

                    if (Inbox.Rows.Count == 0)
                    {
                        Player.SendMessage(p, "No messages found."); Inbox.Dispose(); return;
                    }

                    for (int i = 0; i < Inbox.Rows.Count; ++i)
                    {
                        Player.SendMessage(p, i + ": From &5" + Inbox.Rows[i]["PlayerFrom"].ToString() + Server.DefaultColor + " at &a" + Inbox.Rows[i]["TimeSent"].ToString());
                    }
                    Inbox.Dispose();
                }
                else if (message.Split(' ')[0].ToLower() == "del" || message.Split(' ')[0].ToLower() == "delete")
                {
                    int FoundRecord = -1;

                    if (message.Split(' ')[1].ToLower() != "all")
                    {
                        try
                        {
                            FoundRecord = int.Parse(message.Split(' ')[1]);
                        }
                        catch { Player.SendMessage(p, "Incorrect number given."); return; }

                        if (FoundRecord < 0)
                        {
                            Player.SendMessage(p, "Cannot delete records below 0"); return;
                        }
                    }

                    DataTable Inbox = MySQL.fillData("SELECT * FROM `Inbox" + p.name + "` ORDER BY TimeSent");

                    if (Inbox.Rows.Count - 1 < FoundRecord || Inbox.Rows.Count == 0)
                    {
                        Player.SendMessage(p, "\"" + FoundRecord + "\" does not exist."); Inbox.Dispose(); return;
                    }

                    string queryString;
                    if (FoundRecord == -1)
                    {
                        queryString = "TRUNCATE TABLE `Inbox" + p.name + "`";
                    }
                    else
                    {
                        queryString = "DELETE FROM `Inbox" + p.name + "` WHERE PlayerFrom='" + Inbox.Rows[FoundRecord]["PlayerFrom"] + "' AND TimeSent='" + Convert.ToDateTime(Inbox.Rows[FoundRecord]["TimeSent"]).ToString("yyyy-MM-dd HH:mm:ss") + "'";
                    }

                    MySQL.executeQuery(queryString);

                    if (FoundRecord == -1)
                    {
                        Player.SendMessage(p, "Deleted all messages.");
                    }
                    else
                    {
                        Player.SendMessage(p, "Deleted message.");
                    }

                    Inbox.Dispose();
                }
                else
                {
                    int FoundRecord;

                    try
                    {
                        FoundRecord = int.Parse(message);
                    }
                    catch { Player.SendMessage(p, "Incorrect number given."); return; }

                    if (FoundRecord < 0)
                    {
                        Player.SendMessage(p, "Cannot read records below 0"); return;
                    }

                    DataTable Inbox = MySQL.fillData("SELECT * FROM `Inbox" + p.name + "` ORDER BY TimeSent");

                    if (Inbox.Rows.Count - 1 < FoundRecord || Inbox.Rows.Count == 0)
                    {
                        Player.SendMessage(p, "\"" + FoundRecord + "\" does not exist."); Inbox.Dispose(); return;
                    }

                    Player.SendMessage(p, "Message from &5" + Inbox.Rows[FoundRecord]["PlayerFrom"] + Server.DefaultColor + " sent at &a" + Inbox.Rows[FoundRecord]["TimeSent"] + ":");
                    Player.SendMessage(p, Inbox.Rows[FoundRecord]["Contents"].ToString());
                    Inbox.Dispose();
                }
            }
            catch
            {
                Player.SendMessage(p, "Error accessing inbox. You may have no mail, try again.");
            }
        }
Exemple #11
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }
            Player pl = Player.Find(message);

            if (pl != null && !pl.hidden)
            {
                Player.SendMessage(p, pl.color + pl.name + Server.DefaultColor + " is online, using /whois instead.");
                Command.all.Find("whois").Use(p, message);
                return;
            }

            if (message.IndexOf("'") != -1)
            {
                Player.SendMessage(p, "Cannot parse request."); return;
            }

            string FoundRank = Group.findPlayer(message.ToLower());

            DataTable playerDb = MySQL.fillData("SELECT * FROM Players WHERE Name='" + message + "'");

            if (playerDb.Rows.Count == 0)
            {
                Player.SendMessage(p, Group.Find(FoundRank).color + message + Server.DefaultColor + " has the rank of " + Group.Find(FoundRank).color + FoundRank); return;
            }

            Player.SendMessage(p, Group.Find(FoundRank).color + playerDb.Rows[0]["Title"] + " " + message + Server.DefaultColor + " has :");
            Player.SendMessage(p, "> > the rank of \"" + Group.Find(FoundRank).color + FoundRank);
            try
            {
                if (!Group.Find("Nobody").commands.Contains("pay") && !Group.Find("Nobody").commands.Contains("give") && !Group.Find("Nobody").commands.Contains("take"))
                {
                    Player.SendMessage(p, "> > &a" + playerDb.Rows[0]["Money"] + Server.DefaultColor + " " + Server.moneys);
                }
            }
            catch { }
            Player.SendMessage(p, "> > &cdied &a" + playerDb.Rows[0]["TotalDeaths"] + Server.DefaultColor + " times");
            Player.SendMessage(p, "> > &bmodified &a" + playerDb.Rows[0]["totalBlocks"] + Server.DefaultColor + " blocks.");
            Player.SendMessage(p, "> > was last seen on &a" + playerDb.Rows[0]["LastLogin"]);
            Player.SendMessage(p, "> > first logged into the server on &a" + playerDb.Rows[0]["FirstLogin"]);
            Player.SendMessage(p, "> > logged in &a" + playerDb.Rows[0]["totalLogin"] + Server.DefaultColor + " times, &c" + playerDb.Rows[0]["totalKicked"] + Server.DefaultColor + " of which ended in a kick.");
            Player.SendMessage(p, "> > " + Awards.awardAmount(message) + " awards");

            bool skip = false;

            if (p != null)
            {
                if (p.group.Permission <= LevelPermission.AdvBuilder)
                {
                    skip = true;
                }
            }

            if (!skip)
            {
                if (Server.bannedIP.Contains(playerDb.Rows[0]["IP"].ToString()))
                {
                    playerDb.Rows[0]["IP"] = "&8" + playerDb.Rows[0]["IP"] + ", which is banned";
                }
                Player.SendMessage(p, "> > the IP of " + playerDb.Rows[0]["IP"]);
                if (Server.useWhitelist)
                {
                    if (Server.whiteList.Contains(message.ToLower()))
                    {
                        Player.SendMessage(p, "> > Player is &fWhitelisted");
                    }
                }
                if (Server.devs.Contains(message.ToLower()))
                {
                    Player.SendMessage(p, Server.DefaultColor + "> > Player is a &9Developer");
                }
            }
            playerDb.Dispose();
        }
Exemple #12
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }
            if (message[0] == '@')
            {
                message = message.Remove(0, 1).Trim();
                Player who = Player.Find(message);
                if (Server.devs.Contains(message.ToLower()))
                {
                    Player.SendMessage(p, "You can't ban a MCForge Developer!");
                    if (p != null)
                    {
                        Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " attempted to ban a MCForge Developer!");
                    }
                    else
                    {
                        Player.GlobalMessage(Server.DefaultColor + "The Console attempted to ban a MCForge Developer!");
                    }
                    return;
                }
                if (who == null)
                {
                    DataTable ip;
                    int       tryCounter = 0;
                    rerun :  try
                    {
                        ip = Server.useMySQL ? MySQL.fillData("SELECT IP FROM Players WHERE Name = '" + message + "'") : SQLite.fillData("SELECT IP FROM Players WHERE Name = '" + message + "'");
                    }
                    catch (Exception e)
                    {
                        tryCounter++;
                        if (tryCounter < 10)
                        {
                            goto rerun;
                        }
                        else
                        {
                            Server.ErrorLog(e);
                            return;
                        }
                    }
                    if (ip.Rows.Count > 0)
                    {
                        message = ip.Rows[0]["IP"].ToString();
                    }
                    else
                    {
                        Player.SendMessage(p, "Unable to find an IP address for that user.");
                        return;
                    }
                    ip.Dispose();
                }
                else
                {
                    message = who.ip;
                }
            }
            else
            {
                Player who = Player.Find(message);
                if (who != null)
                {
                    message = who.ip;
                }
            }

            if (message.Equals("127.0.0.1"))
            {
                Player.SendMessage(p, "You can't ip-ban the server!"); return;
            }
            if (message.IndexOf('.') == -1)
            {
                Player.SendMessage(p, "Invalid IP!"); return;
            }
            if (message.Split('.').Length != 4)
            {
                Player.SendMessage(p, "Invalid IP!"); return;
            }
            if (p != null && p.ip == message)
            {
                Player.SendMessage(p, "You can't ip-ban yourself.!"); return;
            }
            if (Server.bannedIP.Contains(message))
            {
                Player.SendMessage(p, message + " is already ip-banned."); return;
            }

            // Check if IP belongs to an op+
            // First get names of active ops+ with that ip
            List <string> opNamesWithThatIP = (from pl in Player.players where (pl.ip == message && [email protected] >= LevelPermission.Operator) select pl.name).ToList();
            // Next, add names from the database
            DataTable dbnames = Server.useMySQL ? MySQL.fillData("SELECT Name FROM Players WHERE IP = '" + message + "'") : SQLite.fillData("SELECT Name FROM Players WHERE IP = '" + message + "'");

            foreach (DataRow row in dbnames.Rows)
            {
                opNamesWithThatIP.Add(row[0].ToString());
            }


            if (opNamesWithThatIP != null && opNamesWithThatIP.Count > 0)
            {
                // We have at least one op+ with a matching IP
                // Check permissions of everybody who matched that IP
                foreach (string opname in opNamesWithThatIP)
                {
                    // If one of these guys is a dev, don't allow the ipban to proceed!
                    if (Server.devs.Contains(opname.ToLower()))
                    {
                        Player.SendMessage(p, "You can't ban a MCForge Developer!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " attempted to ban a MCForge Developer!");
                        }
                        else
                        {
                            Player.GlobalMessage(Server.DefaultColor + "The Console attempted to ban a MCForge Developer!");
                        }
                        return;
                    }
                    // Console can ban anybody else, so skip this section
                    if (p != null)
                    {
                        // If one of these guys matches a player with a higher rank don't allow the ipban to proceed!
                        Group grp = Group.findPlayerGroup(opname);
                        if (grp != null)
                        {
                            if (grp.Permission >= p.group.Permission)
                            {
                                Player.SendMessage(p, "You can only ipban IPs used by players with a lower rank.");
                                Player.SendMessage(p, Server.DefaultColor + opname + "(" + grp.color + grp.name + Server.DefaultColor + ") uses that IP.");
                                Server.s.Log(p.name + "failed to ipban " + message + " - IP is also used by: " + opname + "(" + grp.name + ")");
                                return;
                            }
                        }
                    }
                }
            }



            if (p != null)
            {
                Server.IRC.Say(message.ToLower() + " was ip-banned by " + p.name + ".");
                Server.s.Log("IP-BANNED: " + message.ToLower() + " by " + p.name + ".");
                Player.GlobalMessage(message + " was &8ip-banned" + Server.DefaultColor + " by " + p.color + p.name + Server.DefaultColor + ".");
            }
            else
            {
                Server.IRC.Say(message.ToLower() + " was ip-banned by console.");
                Server.s.Log("IP-BANNED: " + message.ToLower() + " by console.");
                Player.GlobalMessage(message + " was &8ip-banned" + Server.DefaultColor + " by console.");
            }
            Server.bannedIP.Add(message);
            Server.bannedIP.Save("banned-ip.txt", false);

            /*
             * foreach (Player pl in Player.players) {
             *  if (message == pl.ip) { pl.Kick("Kicked by ipban"); }
             * }*/
        }
Exemple #13
0
        public void Start()
        {
            shuttingDown = false;
            Log("Starting Server");

            if (!Directory.Exists("properties"))
            {
                Directory.CreateDirectory("properties");
            }
            if (!Directory.Exists("bots"))
            {
                Directory.CreateDirectory("bots");
            }
            if (!Directory.Exists("text"))
            {
                Directory.CreateDirectory("text");
            }

            if (!Directory.Exists("extra"))
            {
                Directory.CreateDirectory("extra");
            }
            if (!Directory.Exists("extra/undo"))
            {
                Directory.CreateDirectory("extra/undo");
            }
            if (!Directory.Exists("extra/undoPrevious"))
            {
                Directory.CreateDirectory("extra/undoPrevious");
            }
            if (!Directory.Exists("extra/copy/"))
            {
                Directory.CreateDirectory("extra/copy/");
            }
            if (!Directory.Exists("extra/copyBackup/"))
            {
                Directory.CreateDirectory("extra/copyBackup/");
            }

            try
            {
                if (File.Exists("server.properties"))
                {
                    File.Move("server.properties", "properties/server.properties");
                }
                if (File.Exists("rules.txt"))
                {
                    File.Move("rules.txt", "text/rules.txt");
                }
                if (File.Exists("welcome.txt"))
                {
                    File.Move("welcome.txt", "text/welcome.txt");
                }
                if (File.Exists("messages.txt"))
                {
                    File.Move("messages.txt", "text/messages.txt");
                }
                if (File.Exists("externalurl.txt"))
                {
                    File.Move("externalurl.txt", "text/externalurl.txt");
                }
                if (File.Exists("autoload.txt"))
                {
                    File.Move("autoload.txt", "text/autoload.txt");
                }
                if (File.Exists("IRC_Controllers.txt"))
                {
                    File.Move("IRC_Controllers.txt", "ranks/IRC_Controllers.txt");
                }
                if (Server.useWhitelist)
                {
                    if (File.Exists("whitelist.txt"))
                    {
                        File.Move("whitelist.txt", "ranks/whitelist.txt");
                    }
                }
            } catch { }

            Properties.Load("properties/server.properties");
            Updater.Load("properties/update.properties");

            Group.InitAll();
            Command.InitAll();
            GrpCommands.fillRanks();
            Block.SetBlocks();
            Awards.Load();

            if (File.Exists("text/emotelist.txt"))
            {
                foreach (string s in File.ReadAllLines("text/emotelist.txt"))
                {
                    Player.emoteList.Add(s);
                }
            }
            else
            {
                File.Create("text/emotelist.txt");
            }

            ProfanityFilter.Init();

            timeOnline = DateTime.Now;

            try
            {
                MySQL.executeQuery("CREATE DATABASE if not exists `" + MySQLDatabaseName + "`", true);
            }
            catch (Exception e)
            {
                Server.s.Log("MySQL settings have not been set! Please reference the MySQL_Setup.txt file on setting up MySQL!");
                Server.ErrorLog(e);
                //process.Kill();
                return;
            }

            MySQL.executeQuery("CREATE TABLE if not exists Players (ID MEDIUMINT not null auto_increment, Name VARCHAR(20), IP CHAR(15), FirstLogin DATETIME, LastLogin DATETIME, totalLogin MEDIUMINT, Title CHAR(20), TotalDeaths SMALLINT, Money MEDIUMINT UNSIGNED, totalBlocks BIGINT, totalKicked MEDIUMINT, color VARCHAR(6), title_color VARCHAR(6), PRIMARY KEY (ID));");

            // Check if the color column exists.
            DataTable colorExists = MySQL.fillData("SHOW COLUMNS FROM Players WHERE `Field`='color'");

            if (colorExists.Rows.Count == 0)
            {
                MySQL.executeQuery("ALTER TABLE Players ADD COLUMN color VARCHAR(6) AFTER totalKicked");
            }
            colorExists.Dispose();

            // Check if the title color column exists.
            DataTable tcolorExists = MySQL.fillData("SHOW COLUMNS FROM Players WHERE `Field`='title_color'");

            if (tcolorExists.Rows.Count == 0)
            {
                MySQL.executeQuery("ALTER TABLE Players ADD COLUMN title_color VARCHAR(6) AFTER color");
            }
            tcolorExists.Dispose();

            if (levels != null)
            {
                foreach (Level l in levels)
                {
                    l.Unload();
                }
            }
            ml.Queue(delegate
            {
                try
                {
                    levels = new List <Level>(Server.maps);
                    MapGen = new MapGenerator();

                    Random random = new Random();

                    if (File.Exists("levels/" + Server.level + ".lvl"))
                    {
                        mainLevel        = Level.Load(Server.level);
                        mainLevel.unload = false;
                        if (mainLevel == null)
                        {
                            if (File.Exists("levels/" + Server.level + ".lvl.backup"))
                            {
                                Log("Attempting to load backup.");
                                File.Copy("levels/" + Server.level + ".lvl.backup", "levels/" + Server.level + ".lvl", true);
                                mainLevel = Level.Load(Server.level);
                                if (mainLevel == null)
                                {
                                    Log("BACKUP FAILED!");
                                    Console.ReadLine(); return;
                                }
                            }
                            else
                            {
                                Log("mainlevel not found");
                                mainLevel = new Level(Server.level, 128, 64, 128, "flat");

                                mainLevel.permissionvisit = LevelPermission.Guest;
                                mainLevel.permissionbuild = LevelPermission.Guest;
                                mainLevel.Save();
                            }
                        }
                    }
                    else
                    {
                        Log("mainlevel not found");
                        mainLevel = new Level(Server.level, 128, 64, 128, "flat");

                        mainLevel.permissionvisit = LevelPermission.Guest;
                        mainLevel.permissionbuild = LevelPermission.Guest;
                        mainLevel.Save();
                    }

                    addLevel(mainLevel);

                    // fenderrock - Make sure the level does have a physics thread
                    if (mainLevel.physThread == null)
                    {
                        mainLevel.physThread = new Thread(new ThreadStart(mainLevel.Physics));
                    }

                    mainLevel.physThread.Start();
                } catch (Exception e) { Server.ErrorLog(e); }
            });

            ml.Queue(delegate
            {
                bannedIP       = PlayerList.Load("banned-ip.txt", null);
                ircControllers = PlayerList.Load("IRC_Controllers.txt", null);

                foreach (Group grp in Group.GroupList)
                {
                    grp.playerList = PlayerList.Load(grp.fileName, grp);
                }
                if (Server.useWhitelist)
                {
                    whiteList = PlayerList.Load("whitelist.txt", null);
                }
            });

            ml.Queue(delegate
            {
                if (File.Exists("text/autoload.txt"))
                {
                    try
                    {
                        string[] lines = File.ReadAllLines("text/autoload.txt");
                        foreach (string line in lines)
                        {
                            //int temp = 0;
                            string _line = line.Trim();
                            try
                            {
                                if (_line == "")
                                {
                                    continue;
                                }
                                if (_line[0] == '#')
                                {
                                    continue;
                                }
                                int index = _line.IndexOf("=");

                                string key = _line.Split('=')[0].Trim();
                                string value;
                                try
                                {
                                    value = _line.Split('=')[1].Trim();
                                }
                                catch
                                {
                                    value = "0";
                                }

                                if (!key.Equals(mainLevel.name))
                                {
                                    Command.all.Find("load").Use(null, key + " " + value);
                                    Level l = Level.FindExact(key);
                                }
                                else
                                {
                                    try
                                    {
                                        int temp = int.Parse(value);
                                        if (temp >= 0 && temp <= 3)
                                        {
                                            mainLevel.setPhysics(temp);
                                        }
                                    }
                                    catch
                                    {
                                        Server.s.Log("Physics variable invalid");
                                    }
                                }
                            }
                            catch
                            {
                                Server.s.Log(_line + " failed.");
                            }
                        }
                    }
                    catch
                    {
                        Server.s.Log("autoload.txt error");
                    }
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                }
                else
                {
                    Log("autoload.txt does not exist");
                }
            });

            ml.Queue(delegate
            {
                Log("Creating listening socket on port " + Server.port + "... ");
                if (Setup())
                {
                    s.Log("Done.");
                }
                else
                {
                    s.Log("Could not create socket connection.  Shutting down.");
                    return;
                }
            });

            ml.Queue(delegate
            {
                updateTimer.Elapsed += delegate
                {
                    Player.GlobalUpdate();
                    PlayerBot.GlobalUpdatePosition();
                };

                updateTimer.Start();
            });


            // Heartbeat code here:

            ml.Queue(delegate
            {
                try
                {
                    Heart.Init();
                }
                catch (Exception e)
                {
                    Server.ErrorLog(e);
                }
            });

            // END Heartbeat code

            /*
             * Thread processThread = new Thread(new ThreadStart(delegate
             * {
             *  try
             *  {
             *      PCCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
             *      ProcessCounter = new PerformanceCounter("Process", "% Processor Time", Process.GetCurrentProcess().ProcessName);
             *      PCCounter.BeginInit();
             *      ProcessCounter.BeginInit();
             *      PCCounter.NextValue();
             *      ProcessCounter.NextValue();
             *  }
             *  catch { }
             * }));
             * processThread.Start();
             */

            ml.Queue(delegate
            {
                messageTimer.Elapsed += delegate
                {
                    RandomMessage();
                };
                messageTimer.Start();

                process = System.Diagnostics.Process.GetCurrentProcess();

                if (File.Exists("text/messages.txt"))
                {
                    StreamReader r = File.OpenText("text/messages.txt");
                    while (!r.EndOfStream)
                    {
                        messages.Add(r.ReadLine());
                    }
                    r.Dispose();
                }
                else
                {
                    File.Create("text/messages.txt").Close();
                }

                if (Server.irc)
                {
                    new IRCBot();
                }


                //      string CheckName = "FROSTEDBUTTS";

                //       if (Server.name.IndexOf(CheckName.ToLower())!= -1){ Server.s.Log("FROSTEDBUTTS DETECTED");}
                new AutoSaver(Server.backupInterval);     //2 and a half mins

                blockThread = new Thread(new ThreadStart(delegate
                {
                    while (true)
                    {
                        Thread.Sleep(blockInterval * 1000);
                        foreach (Level l in levels)
                        {
                            try
                            {
                                l.saveChanges();
                            }
                            catch (Exception e)
                            {
                                Server.ErrorLog(e);
                            }
                        }
                    }
                }));
                blockThread.Start();

                locationChecker = new Thread(new ThreadStart(delegate
                {
                    while (true)
                    {
                        Thread.Sleep(3);
                        for (int i = 0; i < Player.players.Count; i++)
                        {
                            try
                            {
                                Player p = Player.players[i];

                                if (p.frozen)
                                {
                                    unchecked { p.SendPos((byte)-1, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1]); } continue;
                                }
                                else if (p.following != "")
                                {
                                    Player who = Player.Find(p.following);
                                    if (who == null || who.level != p.level)
                                    {
                                        p.following = "";
                                        if (!p.canBuild)
                                        {
                                            p.canBuild = true;
                                        }
                                        if (who != null && who.possess == p.name)
                                        {
                                            who.possess = "";
                                        }
                                        continue;
                                    }
                                    if (p.canBuild)
                                    {
                                        unchecked { p.SendPos((byte)-1, who.pos[0], (ushort)(who.pos[1] - 16), who.pos[2], who.rot[0], who.rot[1]); }
                                    }
                                    else
                                    {
                                        unchecked { p.SendPos((byte)-1, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1]); }
                                    }
                                }
                                else if (p.possess != "")
                                {
                                    Player who = Player.Find(p.possess);
                                    if (who == null || who.level != p.level)
                                    {
                                        p.possess = "";
                                    }
                                }

                                ushort x = (ushort)(p.pos[0] / 32);
                                ushort y = (ushort)(p.pos[1] / 32);
                                ushort z = (ushort)(p.pos[2] / 32);

                                if (p.level.Death)
                                {
                                    p.RealDeath(x, y, z);
                                }
                                p.CheckBlock(x, y, z);

                                p.oldBlock = (ushort)(x + y + z);
                            } catch (Exception e) { Server.ErrorLog(e); }
                        }
                    }
                }));

                locationChecker.Start();

                Log("Finished setting up server");
            });
        }
        public override void Use(Player p, string message)
        {
            bool   debug        = false;
            Player who          = null;
            string timespanend  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string timespan     = "thismonth";
            string timespanname = "This Month";
            bool   tspanoption  = false;

            if (message == "" && p != null)
            {
                who = p;
            }
            else
            {
                who = (message.Split(' ').Length > 1 ? Player.Find(message.Split(' ')[0]) : Player.Find(message));
            }
            if (p != null && (message == "today" || message == "yesterday" || message == "thismonth" || message == "lastmonth" || message == "all"))
            {
                who = p;
            }
            if (p == null && message == "")
            {
                Help(p); return;
            }
            if (message.Split(' ').Length == 1 && (message == "today" || message == "yesterday" || message == "thismonth" || message == "lastmonth" || message == "all"))
            {
                timespan = message;
            }
            if (message.Split(' ').Length == 2 && (message.Split(' ')[1].ToLower() == "today" || message.Split(' ')[1].ToLower() == "yesterday" || message.Split(' ')[1].ToLower() == "thismonth" || message.Split(' ')[1].ToLower() == "lastmonth" || message.Split(' ')[1].ToLower() == "all"))
            {
                timespan = message.Split(' ')[1].ToLower();
            }
            if (debug)
            {
                Player.SendMessage(p, "Message = " + message);
            }
            if (timespan.ToLower() == "today")
            {
                timespan     = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
                timespanname = "Today";
                tspanoption  = true;
            }
            if (timespan.ToLower() == "yesterday")
            {
                timespan     = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00");
                timespanend  = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
                timespanname = "Yesterday";
                tspanoption  = true;
            }
            if (timespan.ToLower() == "thismonth")
            {
                timespan    = DateTime.Now.ToString("yyyy-MM-01 00:00:00");
                tspanoption = true;
            }
            if (timespan.ToLower() == "lastmonth")
            {
                timespan     = DateTime.Now.AddMonths(-1).ToString("yyyy-MM-01 00:00:00");
                timespanend  = DateTime.Now.ToString("yyyy-MM-01 00:00:00");
                timespanname = "Last Month";
                tspanoption  = true;
            }
            if (timespan.ToLower() == "all")
            {
                timespan     = "0000-00-00 00:00:00";
                timespanname = "ALL";
                tspanoption  = true;
            }
            if (!tspanoption)
            {
                Help(p); return;
            }
            if (debug)
            {
                Player.SendMessage(p, "Timespan = " + timespan);
            }
            if (debug)
            {
                Player.SendMessage(p, "TimespanName = " + timespanname);
            }
            if (who != null)
            {
                message = who.name;
            }                                        // Online full player name is converted to message
            else
            {
                using (DataTable playerDb = Database.fillData("SELECT * FROM Players WHERE Name='" + (message.Split(' ').Length > 1 ? message.Split(' ')[0] : message) + "'"))
                {
                    if (playerDb.Rows != null && playerDb.Rows.Count > 0) // Check if player exists in database since we couldn't find player online
                    {
                        message = playerDb.Rows[0]["Name"].ToString();    // Proper case of player name is pulled from database and converted to message
                        playerDb.Dispose();
                    }
                    else
                    {
                        Player.SendMessage(p, "Unable to find player"); // Player wasn't online and didn't exist in database
                        return;
                    }
                }
            }
            DataTable reviewcount  = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'review' AND Cmdmsg LIKE 'next'") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'review' AND Cmdmsg LIKE 'next'");
            DataTable promotecount = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'promote' AND Cmdmsg !=''") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'promote' AND Cmdmsg !=''");
            DataTable demotecount  = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'demote' AND Cmdmsg !=''") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'demote' AND Cmdmsg !=''");
            DataTable griefercount = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'griefer' AND Cmdmsg !=''") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'griefer' AND Cmdmsg !=''");
            DataTable undocount    = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'undo' AND Cmdmsg !=''") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'undo' AND Cmdmsg !=''");
            DataTable freezecount  = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'freeze' AND Cmdmsg !=''") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'freeze' AND Cmdmsg !=''");
            DataTable mutecount    = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'mute' AND Cmdmsg !=''") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'mute' AND Cmdmsg !=''");
            DataTable warncount    = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'warn' AND Cmdmsg !=''") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'warn' AND Cmdmsg !=''");
            DataTable kickcount    = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'kick' AND Cmdmsg !=''") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'kick' AND Cmdmsg !=''");
            DataTable tempbancount = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'tempban' AND Cmdmsg !=''") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'tempban' AND Cmdmsg !=''");
            DataTable bancount     = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'ban' AND Cmdmsg !=''") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'ban' AND Cmdmsg !=''");

            Player.SendMessage(p, (p == null ? "" : "&d") + "OpStats for " + (p == null ? "" : "&c") + message); // Use colorcodes if in game, don't use color if in console
            Player.SendMessage(p, (p == null ? "" : "&d") + "Showing " + timespanname + " Starting from " + timespan);
            Player.SendMessage(p, (p == null ? "" : "&0") + "----------------");
            Player.SendMessage(p, (p == null ? "" : "&a") + "Reviews - " + (p == null ? "" : "&5") + reviewcount.Rows[0]["COUNT(id)"]); // Count results within datatable
            Player.SendMessage(p, (p == null ? "" : "&a") + "Promotes - " + (p == null ? "" : "&5") + promotecount.Rows[0]["COUNT(id)"]);
            Player.SendMessage(p, (p == null ? "" : "&a") + "Demotes - " + (p == null ? "" : "&5") + demotecount.Rows[0]["COUNT(id)"]);
            Player.SendMessage(p, (p == null ? "" : "&a") + "Griefers - " + (p == null ? "" : "&5") + griefercount.Rows[0]["COUNT(id)"]);
            Player.SendMessage(p, (p == null ? "" : "&a") + "Undo - " + (p == null ? "" : "&5") + undocount.Rows[0]["COUNT(id)"]);
            Player.SendMessage(p, (p == null ? "" : "&a") + "Freezes - " + (p == null ? "" : "&5") + freezecount.Rows[0]["COUNT(id)"]);
            Player.SendMessage(p, (p == null ? "" : "&a") + "Mutes - " + (p == null ? "" : "&5") + mutecount.Rows[0]["COUNT(id)"]);
            Player.SendMessage(p, (p == null ? "" : "&a") + "Warns - " + (p == null ? "" : "&5") + warncount.Rows[0]["COUNT(id)"]);
            Player.SendMessage(p, (p == null ? "" : "&a") + "Kicks - " + (p == null ? "" : "&5") + kickcount.Rows[0]["COUNT(id)"]);
            Player.SendMessage(p, (p == null ? "" : "&a") + "Tempbans - " + (p == null ? "" : "&5") + tempbancount.Rows[0]["COUNT(id)"]);
            Player.SendMessage(p, (p == null ? "" : "&a") + "Bans - " + (p == null ? "" : "&5") + bancount.Rows[0]["COUNT(id)"]);
            reviewcount.Dispose();
            promotecount.Dispose();
            demotecount.Dispose();
            griefercount.Dispose();
            undocount.Dispose();
            freezecount.Dispose();
            mutecount.Dispose();
            warncount.Dispose();
            kickcount.Dispose();
            tempbancount.Dispose();
            bancount.Dispose();
        }
        public void AboutBlockchange(Player p, ushort x, ushort y, ushort z, byte type)
        {
            if (!p.staticCommands)
            {
                p.ClearBlockchange();
            }
            byte b = p.level.GetTile(x, y, z);

            if (b == Block.Zero)
            {
                Player.SendMessage(p, "Invalid Block(" + x + "," + y + "," + z + ")!"); return;
            }
            p.SendBlockchange(x, y, z, b);

            string message = "Block (" + x + "," + y + "," + z + "): ";

            message += "&f" + b + " = " + Block.Name(b);
            Player.SendMessage(p, message + Server.DefaultColor + ".");
            message = p.level.foundInfo(x, y, z);
            if (message != "")
            {
                Player.SendMessage(p, "Physics information: &a" + message);
            }

            DataTable Blocks = Server.useMySQL ? MySQL.fillData("SELECT * FROM `Block" + p.level.name + "` WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z) : SQLite.fillData("SELECT * FROM Block" + p.level.name + " WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z);

            string Username, TimePerformed, BlockUsed;
            bool   Deleted, foundOne = false;

            for (int i = 0; i < Blocks.Rows.Count; i++)
            {
                foundOne      = true;
                Username      = Blocks.Rows[i]["Username"].ToString();
                TimePerformed = DateTime.Parse(Blocks.Rows[i]["TimePerformed"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
                //Server.s.Log(Blocks.Rows[i]["Type"].ToString());
                BlockUsed = Block.Name(Convert.ToByte(Blocks.Rows[i]["Type"])).ToString();
                Deleted   = Convert.ToBoolean(Blocks.Rows[i]["Deleted"]);

                if (!Deleted)
                {
                    Player.SendMessage(p, "&3Created by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed);
                }
                else
                {
                    Player.SendMessage(p, "&4Destroyed by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed);
                }
                Player.SendMessage(p, "Date and time modified: &2" + TimePerformed);
            }

            List <Level.BlockPos> inCache = p.level.blockCache.FindAll(bP => bP.x == x && bP.y == y && bP.z == z);

            for (int i = 0; i < inCache.Count; i++)
            {
                foundOne      = true;
                Deleted       = inCache[i].deleted;
                Username      = inCache[i].name;
                TimePerformed = inCache[i].TimePerformed.ToString("yyyy-MM-dd HH:mm:ss");
                BlockUsed     = Block.Name(inCache[i].type);

                if (!Deleted)
                {
                    Player.SendMessage(p, "&3Created by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed);
                }
                else
                {
                    Player.SendMessage(p, "&4Destroyed by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed);
                }
                Player.SendMessage(p, "Date and time modified: &2" + TimePerformed);
            }

            if (!foundOne)
            {
                Player.SendMessage(p, "This block has not been modified since the map was cleared.");
            }

            Blocks.Dispose();

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }