Exemplo n.º 1
0
        public override void Use(Player p, string message)
        {
            if (!Server.useMySQL)
            {
                Player.SendMessage(p, "MySQL has not been configured! Please configure MySQL to use /viewlikes!"); return;
            }
            if (!Server.enableMapLiking)
            {
                Player.SendMessage(p, "Map liking is disabled."); return;
            }
            if (p == null && String.IsNullOrEmpty(message))
            {
                Player.SendMessage(p, "Command not usable from Console."); return;
            }
            if (message.Split(' ').Length > 1)
            {
                Help(p); return;
            }
            Level l = (String.IsNullOrEmpty(message) ? p.level : Level.Find(message));

            if (l == null)
            {
                Player.SendMessage(p, "Level could not be found or is not loaded."); return;
            }
            DataTable likes = MySQL.fillData("SELECT * FROM `Likes" + l.name + "`");

            if (likes.Rows.Count == 0)
            {
                Player.SendMessage(p, "Nobody likes this level yet!");
            }
            else
            {
                string people   = "";
                int    maxcount = (likes.Rows.Count < 3 ? likes.Rows.Count : 3);
                for (int i = 0; i < maxcount; i++)
                {
                    people += Group.Find(Group.findPlayer(likes.Rows[i]["Username"].ToString().ToLower())).color + likes.Rows[i]["Username"].ToString() + "&g" + (maxcount >= 2 && i == maxcount - 2 && (likes.Rows.Count == maxcount) ? " and " : (i == maxcount - 1 ? "" : ",") + (i == maxcount - 1 && likes.Rows.Count != maxcount ? "" : " "));
                }
                if (maxcount != likes.Rows.Count)
                {
                    people += " and " + (likes.Rows.Count - maxcount) + (likes.Rows.Count - maxcount == 1 ? " other person " : " others ");
                }
                people += (likes.Rows.Count == 1 ? "likes" : "like") + " this level.";
                Player.SendMessage(p, people);
            }
        }
Exemplo n.º 2
0
        public override void Use(Player p, string message)
        {
            switch (message.Split(' ')[0].ToLower().Trim())
            {
            case "on":
                if (Server.useDiscourager)
                {
                    Player.SendMessage(p, "Discourager is already enabled."); return;
                }
                Server.useDiscourager = true;
                Properties.Save("properties/server.properties");
                Player.SendMessage(p, "Discourager enabled.");
                break;

            case "off":
                if (!Server.useDiscourager)
                {
                    Player.SendMessage(p, "Discourager is already disabled."); return;
                }
                Server.useDiscourager = false;
                Properties.Save("properties/server.properties");
                Player.SendMessage(p, "Discourager disabled.");
                break;

            case "add":
                if (!Server.useDiscourager)
                {
                    Player.SendMessage(p, "Discourager is currently disabled."); return;
                }
                Discourager.AddDiscouraged(message.Split(' ')[1]);
                Discourager.SaveDiscouraged();
                Discourager.LoadDiscouraged();
                if (Group.Find(Group.findPlayer(message.Split(' ')[1])).Permission > Server.opchatperm)
                {
                    Player.SendMessage(p, "Cannot discourage OP+."); return;
                }
                if (Group.Find(Group.findPlayer(message.Split(' ')[1])).Permission >= p.group.Permission && p != null)
                {
                    Player.SendMessage(p, "Cannot discourage player of equal or higher rank."); return;
                }
                if (Player.Find(message.Split(' ')[1]) != null)
                {
                    if (Server.hasProtection(Player.Find(message.Split(' ')[1]).name))
                    {
                        Player.SendMessage(p, "Cannot discourage player of equal or higher rank."); return;
                    }
                    message.Split(' ')[1] = Player.Find(message.Split(' ')[1]).name;
                }
                Player.SendMessage(p, message.Split(' ')[1] + " added to discouraged users list.");
                break;

            case "remove":
                if (!Server.useDiscourager)
                {
                    Player.SendMessage(p, "Discourager is currently disabled."); return;
                }
                Discourager.RemoveDiscouraged(message.Split(' ')[1]);
                Discourager.SaveDiscouraged();
                Discourager.LoadDiscouraged();
                if (Player.Find(message.Split(' ')[1]) != null)
                {
                    message.Split(' ')[1] = Player.Find(message.Split(' ')[1]).name;
                }
                Player.SendMessage(p, message.Split(' ')[1] + " removed from discouraged users list.");
                break;

            case "list":
                if (!Server.useDiscourager)
                {
                    Player.SendMessage(p, "Discourager is currently disabled."); return;
                }
                if (Discourager.discouraged.Count <= 0)
                {
                    Player.SendMessage(p, "Discouraged Users: None."); return;
                }
                else
                {
                    string list = String.Join(", ", Discourager.discouraged.ToArray());
                    Player.SendMessage(p, "Discouraged Users: " + list.Remove(list.Length - 2));
                }
                break;

            default: Help(p); return;
            }
        }
Exemplo n.º 3
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 + "&g 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 + "&g has the rank of " + Group.Find(FoundRank).color + FoundRank); return;
            }

            Player.SendMessage(p, Group.Find(FoundRank).color + playerDb.Rows[0]["Title"] + " " + message + "&g has :");
            Player.SendMessage(p, "> > the rank of \"" + Group.Find(FoundRank).color + FoundRank);
            Player.SendMessage(p, "> > the display name of " + playerDb.Rows[0]["displayName"]);
            Player.SendMessage(p, "> > &a" + playerDb.Rows[0]["Money"] + "&g " + Server.moneys);
            Player.SendMessage(p, "> > &cdied &a" + playerDb.Rows[0]["TotalDeaths"] + "&g times");
            Player.SendMessage(p, "> > &bmodified &a" + playerDb.Rows[0]["totalBlocks"] + "&g blocks.");
            //int ratio = (int)(Math.Round((decimal)(1 / (Math.Min(Convert.ToInt64(playerDb.Rows[0]["destroyedBlocks"].ToString()), (Convert.ToInt64(playerDb.Rows[0]["totalBlocks"].ToString()) - Convert.ToInt64(playerDb.Rows[0]["destroyedBlocks"].ToString()))) / Math.Max(Convert.ToInt64(playerDb.Rows[0]["destroyedBlocks"].ToString()), (Convert.ToInt64(playerDb.Rows[0]["totalBlocks"].ToString()) - Convert.ToInt64(playerDb.Rows[0]["destroyedBlocks"].ToString())))))));
            Int64 builtBlocks = 0;

            try { builtBlocks = Convert.ToInt64(playerDb.Rows[0]["totalBlocks"].ToString()) - Convert.ToInt64(playerDb.Rows[0]["destroyedBlocks"].ToString()); }
            catch { builtBlocks = 0; }
            if (builtBlocks < 0)
            {
                builtBlocks = 0;
            }
            try { Player.SendMessage(p, "> > destroyed &a" + playerDb.Rows[0]["destroyedBlocks"].ToString() + "&g blocks, and built &a" + builtBlocks + "&g."); }
            catch { }
            Player.SendMessage(p, "> > was last seen on &a" + playerDb.Rows[0]["LastLogin"]);
            try { if (Server.useMaxMind)
                  {
                      Player.SendMessage(p, "> > last logged in from country &a" + playerDb.Rows[0]["countryName"]);
                  }
            }
            catch { }
            Player.SendMessage(p, "> > " + TimeSpent(playerDb.Rows[0]["TimeSpent"].ToString()));
            Player.SendMessage(p, "> > first logged into the server on &a" + playerDb.Rows[0]["FirstLogin"]);
            Player.SendMessage(p, "> > logged in &a" + playerDb.Rows[0]["totalLogin"] + "&g times, &c" + playerDb.Rows[0]["totalKicked"] + "&g of which ended in a kick.");
            Player.SendMessage(p, "> > " + Awards.awardAmount(message) + " awards");
            if (playerDb.Rows[0]["HasWOM"].ToString().Trim() == "")
            {
                Player.SendMessage(p, "> > last logged in without &cWOM Game Client" + "&g.");
            }
            else
            {
                Player.SendMessage(p, "> > last logged in using &aWOM Game Client" + "&g, Version &a" + playerDb.Rows[0]["HasWOM"].ToString().Trim() + "&g.");
            }
            // Last ranked/banned reason:
            string lastRankReason = playerDb.Rows[0]["lastRankReason"].ToString();

            if (lastRankReason.ToLower() != "none" && !String.IsNullOrEmpty(lastRankReason))
            {
                if (Group.findPerm(LevelPermission.Banned).playerList.Contains(message))
                {
                    Player.SendMessage(p, "> > last &8banned&g at &a" + lastRankReason.Split(']')[0].Substring(1) + "&g; Reason: &a" + lastRankReason.Substring(lastRankReason.IndexOf("]") + 1).Trim());
                }
                else
                {
                    Player.SendMessage(p, "> > last &branked&g at &a" + lastRankReason.Split(']')[0].Substring(1) + "&g; Reason: &a" + lastRankReason.Substring(lastRankReason.IndexOf("]") + 1).Trim());
                }
            }
            bool skip = false;

            if (p != null)
            {
                if (p.group.Permission <= LevelPermission.Operator)
                {
                    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, "&g> > Player is a &9Developer");
            }
            if (Server.staff.Contains(message.ToLower()))
            {
                Player.SendMessage(p, "&g> > Player is a member of &4MCDawn Staff");
            }
            if (Server.administration.Contains(message.ToLower()))
            {
                Player.SendMessage(p, "&g> > Player is a &6MCDawn Administrator");
            }
            playerDb.Dispose();
        }