예제 #1
0
        public override void Use(Player p, string message)
        {
            if (message.Split(' ').Length < 2)
            {
                Help(p); return;
            }
            Player who     = Player.Find(message.Split(' ')[0]);
            Group  newRank = Group.Find(message.Split(' ')[1]);
            string msgGave;

            if (message.Split(' ').Length > 2)
            {
                msgGave = message.Substring(message.IndexOf(' ', message.IndexOf(' ') + 1));
            }
            else
            {
                msgGave = "Congratulations!";
            }
            if (newRank == null)
            {
                Player.SendMessage(p, "Could not find specified rank."); return;
            }

            Group bannedGroup = Group.findPerm(LevelPermission.Banned);

            if (who == null)
            {
                Player.SendMessage(p, "Player could not be found."); return;
            }
            else
            {
                //if (!Server.devs.Contains(p.name) && Server.devs.Contains(who.name)) { p.SendMessage("Can't let you do that, Starfox."); return; }
                if (p != null)
                {
                    if (who.group == bannedGroup || newRank == bannedGroup)
                    {
                        Player.SendMessage(p, "Cannot change the rank to or from \"" + bannedGroup.name + "\".");
                        return;
                    }

                    if (who.group.Permission >= p.group.Permission || newRank.Permission >= p.group.Permission)
                    {
                        Player.SendMessage(p, "Cannot change the rank of someone equal or higher to yourself."); return;
                    }
                }
                Player.GlobalChat(who, who.color + who.name + "&g's rank was temporarily set to " + newRank.color + newRank.name, false);
                Player.GlobalChat(null, "&6" + msgGave, false);
                who.group = newRank;
                who.color = who.group.color;
                Player.GlobalDie(who, false);
                who.SendMessage("You are now tempranked " + newRank.color + newRank.name + "&g, type /help for your new set of commands.");
                Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
                MCDawn.Gui.Window.thisWindow.UpdateClientList(Player.players);
            }
        }
예제 #2
0
파일: CmdPCount.cs 프로젝트: blha303/MCDawn
        public override void Use(Player p, string message)
        {
            int bancount = Group.findPerm(LevelPermission.Banned).playerList.All().Count;

            try
            {
                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();
            }
            catch
            {
                Player.SendMessage(p, "A total of " + (int)(Player.players.Count + Player.left.Count) + " unique players have visited this server.");
                Player.SendMessage(p, "Of these players, " + bancount + " have been banned.");
            }

            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).");
                }
            }
        }
예제 #3
0
        private string getColor(string commName)
        {
            foreach (GrpCommands.rankAllowance aV in GrpCommands.allowedCommands)
            {
                if (aV.commandName == commName)
                {
                    if (Group.findPerm(aV.lowestRank) != null)
                    {
                        return(Group.findPerm(aV.lowestRank).color);
                    }
                }
            }

            return("&f");
        }
예제 #4
0
파일: CmdHome.cs 프로젝트: blha303/MCDawn
        public override void Use(Player p, string message)
        {
            Group rank = Group.findPerm(Server.HomeRank);

            if (p.group.Permission < Server.HomeRank)
            {
                p.SendMessage("You must be at least " + rank.name + " to use this command!"); return;
            }
            string prefix = Server.HomePrefix.ToLower();
            string x      = Server.HomeX.ToString();
            string y      = Server.HomeY.ToString();
            string z      = Server.HomeZ.ToString();

            if (p.level.name == prefix + p.name.ToLower())
            {
                p.SendMessage("You are already in your home!"); return;
            }
            bool doesntExist = false;

            if (!File.Exists("levels/" + prefix + p.name.ToLower() + ".lvl"))
            {
                doesntExist = true;
            }
            if (doesntExist)
            {
                p.SendMessage("Creating your home...");
                Command.all.Find("newlvl").Use(null, prefix + p.name.ToLower() + " " + x + " " + y + " " + z + " flat");
            }
            if (!Server.AutoLoad)
            {
                Command.all.Find("load").Use(p, prefix + p.name);
            }
            Command.all.Find("goto").Use(p, prefix + p.name);
            if (doesntExist)
            {
                while (p.Loading)
                {
                }                     // Wait for player to load
                Command.all.Find("zoneall").Use(p, p.name);
                Command.all.Find("save").Use(p, prefix + p.name + " wipe");
            }
        }
예제 #5
0
        public override void Use(Player p, string message)
        {
            if (!Server.useMySQL)
            {
                p.SendMessage("MySQL has not been configured! Please configure MySQL to use Zones!"); return;
            }
            CatchPos cpos;

            if (message == "")
            {
                p.ZoneCheck = true;
                Player.SendMessage(p, "Place a block where you would like to check for zones.");
                return;
            }
            else if (p.group.Permission < LevelPermission.Operator && p.level.name != Server.HomePrefix.ToLower() + p.name.ToLower())
            {
                Player.SendMessage(p, "Reserved for OP+");
                return;
            }

            if (message.IndexOf(' ') == -1)
            {
                if (p.canBuild == true)
                {
                    switch (message.ToLower())
                    {
                    case "del":
                        p.zoneDel = true;
                        Player.SendMessage(p, "Place a block where you would like to delete a zone.");
                        return;

                    default:
                        Help(p);
                        return;
                    }
                }
                else
                {
                    Player.SendMessage(p, "Cannot delete zone of higher rank.");
                    return;
                }
            }


            if (message.ToLower() == "del all")
            {
                if (p.group.Permission < LevelPermission.Admin)
                {
                    Player.SendMessage(p, "Only a " + Group.findPerm(LevelPermission.Admin).name + " may delete all zones at once");
                    return;
                }
                else
                {
                    for (int i = 0; i < p.level.ZoneList.Count; i++)
                    {
                        Level.Zone Zn = p.level.ZoneList[i];
                        MySQL.executeQuery("DELETE FROM `Zone" + p.level.name + "` WHERE Owner='" + Zn.Owner + "' AND SmallX='" + Zn.smallX + "' AND SMALLY='" + Zn.smallY + "' AND SMALLZ='" + Zn.smallZ + "' AND BIGX='" + Zn.bigX + "' AND BIGY='" + Zn.bigY + "' AND BIGZ='" + Zn.bigZ + "'");

                        Player.SendMessage(p, "Zone deleted for &b" + Zn.Owner);
                        p.level.ZoneList.Remove(p.level.ZoneList[i]);
                        if (i == p.level.ZoneList.Count)
                        {
                            Player.SendMessage(p, "Finished removing all zones"); return;
                        }
                        i--;
                    }
                }
            }

            if (p.group.Permission < LevelPermission.Operator && p.level.name != Server.HomePrefix + p.name.ToLower())
            {
                Player.SendMessage(p, "Setting zones is reserved for OP+"); return;
            }

            if (Group.Find(message.Split(' ')[1]) != null)
            {
                message = message.Split(' ')[0] + " grp" + Group.Find(message.Split(' ')[1]).name;
            }

            if (message.Split(' ')[0].ToLower() == "add")
            {
                Player foundPlayer = Player.Find(message.Split(' ')[1]);
                if (foundPlayer == null)
                {
                    cpos.Owner = message.Split(' ')[1].ToString();
                }
                else
                {
                    cpos.Owner = foundPlayer.name;
                }
            }
            else
            {
                Help(p); return;
            }

            if (!Player.ValidName(cpos.Owner))
            {
                Player.SendMessage(p, "INVALID NAME."); return;
            }

            cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;

            Player.SendMessage(p, "Place two blocks to determine the edges.");
            Player.SendMessage(p, "Zone for: &b" + cpos.Owner + ".");
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
예제 #6
0
        public override void Use(Player p, string message)
        {
            try
            {
                if (message == "")
                {
                    Help(p); return;
                }
                bool stealth = false; bool totalBan = false;
                if (message[0] == '#')
                {
                    message = message.Remove(0, 1).Trim();
                    stealth = true;
                    Server.s.Log("Stealth Ban Attempted");
                }
                else if (message[0] == '@')
                {
                    totalBan = true;
                    message  = message.Remove(0, 1).Trim();
                }

                Player who = Player.Find(message.Split(' ')[0]);

                if (who == null)
                {
                    /*if (!Player.ValidName(message))
                     * {
                     *  Player.SendMessage(p, "Invalid name \"" + message + "\".");
                     *  return;
                     * }*/

                    if (Server.devs.Contains(message.Split(' ')[0].ToLower()))
                    {
                        Player.SendMessage(p, "Woah!! You can't ban a MCDawn Developer!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Developer!");
                        }
                        else
                        {
                            Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Developer!");
                        }
                        return;
                    }
                    if (Server.staff.Contains(message.Split(' ')[0].ToLower()))
                    {
                        Player.SendMessage(p, "Woah!! You can't ban a MCDawn Staff Member!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Staff Member!");
                        }
                        else
                        {
                            Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Staff Member!");
                        }
                        return;
                    }
                    if (Server.administration.Contains(message.Split(' ')[0].ToLower()))
                    {
                        Player.SendMessage(p, "Woah!! You can't ban a MCDawn Administrator!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Administrator!");
                        }
                        else
                        {
                            Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Administrator!");
                        }
                        return;
                    }

                    Group foundGroup = Group.findPlayerGroup(message.Split(' ')[0]);

                    if (foundGroup.Permission >= LevelPermission.Operator)
                    {
                        Player.SendMessage(p, "You can't ban a " + foundGroup.name + "!");
                        return;
                    }
                    if (foundGroup.Permission == LevelPermission.Banned)
                    {
                        Player.SendMessage(p, message.Split(' ')[0] + " is already banned.");
                        return;
                    }
                    if (p != null && foundGroup.Permission >= p.group.Permission)
                    {
                        Player.SendMessage(p, "You cannot ban a person ranked equal or higher than you.");
                        return;
                    }

                    foundGroup.playerList.Remove(message.Split(' ')[0]);
                    foundGroup.playerList.Save();

                    if (p != null)
                    {
                        Player.GlobalMessage(message.Split(' ')[0] + " &f(offline)" + Server.DefaultColor + " is now &8banned" + Server.DefaultColor + " by " + p.color + p.name + Server.DefaultColor + ".");
                    }
                    else
                    {
                        Player.GlobalMessage(message.Split(' ')[0] + " &f(offline)" + Server.DefaultColor + " is now &8banned" + Server.DefaultColor + " by Console.");
                    }
                    Group.findPerm(LevelPermission.Banned).playerList.Add(message.Split(' ')[0]);
                    if (message.Trim().Split(' ').Length == 1)
                    {
                        message += " No reason given.";
                    }
                    if (p != null)
                    {
                        if (!message.Substring(message.IndexOf(" ") + 1).ToLower().Contains(p.name.ToLower()))
                        {
                            message += " (" + p.name + ")";
                        }
                    }
                    else
                    {
                        if (!message.Substring(message.IndexOf(" ") + 1).ToLower().Contains("console"))
                        {
                            message += " (Console)";
                        }
                    }
                    MySQL.executeQuery("UPDATE Players SET lastRankReason = '[" + DateTime.Now.ToString() + "] " + message.Substring(message.IndexOf(" ") + 1).Replace("'", "\\'").Trim() + "' WHERE Name = '" + message.Split(' ')[0] + "'");
                    Player.GlobalChat(null, "&6Reason: &f" + message.Substring(message.IndexOf(" ") + 1).Trim(), false);
                }
                else
                {
                    if (!Player.ValidName(who.name))
                    {
                        Player.SendMessage(p, "Invalid name \"" + who.name + "\".");
                        return;
                    }
                    if (Server.devs.Contains(who.originalName.ToLower()))
                    {
                        Player.SendMessage(p, "Woah!! You can't ban a MCDawn Developer!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban an MCDawn Developer!");
                        }
                        else
                        {
                            Player.GlobalMessage("The Console is crazy! Trying to ban an MCDawn Developer!");
                        }
                        return;
                    }
                    if (Server.staff.Contains(who.originalName.ToLower()))
                    {
                        Player.SendMessage(p, "Woah!! You can't ban a MCDawn Staff Member!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Staff Member!");
                        }
                        else
                        {
                            Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Staff Member!");
                        }
                        return;
                    }
                    if (Server.administration.Contains(who.originalName.ToLower()))
                    {
                        Player.SendMessage(p, "Woah!! You can't ban a MCDawn Administrator!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Administrator!");
                        }
                        else
                        {
                            Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Administrator!");
                        }
                        return;
                    }

                    if (who.group.Permission >= LevelPermission.Operator)
                    {
                        Player.SendMessage(p, "You can't ban a " + who.group.name + "!");
                        return;
                    }
                    if (who.group.Permission == LevelPermission.Banned)
                    {
                        Player.SendMessage(p, who.name + " is already banned.");
                        return;
                    }

                    who.group.playerList.Remove(message.Split(' ')[0]);
                    who.group.playerList.Save();

                    if (p != null)
                    {
                        if (stealth)
                        {
                            Player.GlobalMessageOps(who.color + who.name + Server.DefaultColor + " is now STEALTH &8banned" + Server.DefaultColor + " by " + p.color + p.name + Server.DefaultColor + ".");
                        }
                        else
                        {
                            Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " is now &8banned" + Server.DefaultColor + " by " + p.color + p.name + Server.DefaultColor + ".", false);
                        }
                    }
                    else
                    {
                        if (stealth)
                        {
                            Player.GlobalMessageOps(who.color + who.name + Server.DefaultColor + " is now STEALTH &8banned" + Server.DefaultColor + " by Console.");
                        }
                        else
                        {
                            Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " is now &8banned" + Server.DefaultColor + " by Console.", false);
                        }
                    }

                    if (message.Trim().Split(' ').Length == 1)
                    {
                        message += " No reason given.";
                    }
                    if (p != null)
                    {
                        if (!message.Substring(message.IndexOf(" ") + 1).ToLower().Contains(p.name.ToLower()))
                        {
                            message += " (" + p.name + ")";
                        }
                    }
                    else
                    {
                        if (!message.Substring(message.IndexOf(" ") + 1).ToLower().Contains("console"))
                        {
                            message += " (Console)";
                        }
                    }
                    MySQL.executeQuery("UPDATE Players SET lastRankReason = '[" + DateTime.Now.ToString() + "] " + message.Substring(message.IndexOf(" ") + 1).Replace("'", "\\'").Trim() + "' WHERE Name = '" + who.name + "'");
                    who.lastRankReason = "[" + DateTime.Now.ToString() + "] " + message.Substring(message.IndexOf(" ") + 1).Trim();

                    who.group = Group.findPerm(LevelPermission.Banned);
                    who.color = who.group.color;
                    Player.GlobalDie(who, false);
                    Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
                    Group.findPerm(LevelPermission.Banned).playerList.Add(who.name);
                    Player.GlobalChat(null, "&6Reason: &f" + message.Substring(message.IndexOf(" ") + 1).Trim(), false);
                }
                Group.findPerm(LevelPermission.Banned).playerList.Save();

                if (p != null)
                {
                    IRCBot.Say(message.Split(' ')[0] + " is now banned by " + p.name + ".");
                    Server.s.Log("BANNED: " + message.Split(' ')[0].ToLower() + " by " + p.name + ".");
                }
                else
                {
                    IRCBot.Say(message.Split(' ')[0] + " is now banned by Console.");
                    Server.s.Log("BANNED: " + message.Split(' ')[0].ToLower() + " by Console.");
                }

                if (totalBan == true)
                {
                    Command.all.Find("undo").Use(p, message.Split(' ')[0] + " 0");
                    Command.all.Find("banip").Use(p, "@ " + message.Split(' ')[0]);
                }
            }
            catch (Exception e) { Server.ErrorLog(e); }
        }
예제 #7
0
        public override void Use(Player p, string message)
        {
            if (message.Split(' ').Length < 2)
            {
                Help(p); return;
            }
            Player who     = Player.Find(message.Split(' ')[0]);
            Group  newRank = Group.Find(message.Split(' ')[1]);
            string msgGave;

            if (p != null)
            {
                if (message.Split(' ').Length > 2)
                {
                    msgGave = message.Substring(message.IndexOf(' ', message.IndexOf(' ') + 1)) + " (" + p.name + ")";
                }
                else
                {
                    msgGave = "No reason given. (" + p.name + ").";
                }
            }
            else
            if (message.Split(' ').Length > 2)
            {
                msgGave = message.Substring(message.IndexOf(' ', message.IndexOf(' ') + 1)) + " (Console)";
            }
            else
            {
                msgGave = "No reason given. (Console).";
            }
            if (newRank == null)
            {
                Player.SendMessage(p, "Could not find specified rank."); return;
            }

            Group bannedGroup = Group.findPerm(LevelPermission.Banned);

            if (who == null)
            {
                string foundName = message.Split(' ')[0];
                if (newRank == bannedGroup)
                {
                    if (p != null)
                    {
                        Player.GlobalMessage(foundName + " &f(offline)" + "&g is now &8banned" + "&g by " + p.color + p.name + "&g.");
                    }
                    else
                    {
                        Player.GlobalMessage(foundName + " &f(offline)" + "&g is now &8banned" + "&g by Console.");
                    }
                    return;
                }

                Group oldGroup = Group.findPlayerGroup(foundName);

                Player.GlobalMessage(foundName + " &f(offline)" + "&g's rank was set to " + newRank.color + newRank.name);
                Player.GlobalChat(null, "&6Reason: &f" + msgGave, false);
            }
            else
            {
                if (newRank == bannedGroup)
                {
                    if (p != null)
                    {
                        Player.GlobalChat(who, who.color + who.name + "&g is now &8banned" + "&g by " + p.color + p.name + "&g.", false);
                    }
                    else
                    {
                        Player.GlobalChat(who, who.color + who.name + "&g is now &8banned" + "&g by Console.", false);
                    }
                    Player.GlobalChat(null, "&6Reason: &f" + msgGave, false);
                    return;
                }
                Player.GlobalChat(who, who.color + who.name + "&g's rank was set to " + newRank.color + newRank.name, false);
                Player.GlobalChat(null, "&6Reason: &f" + msgGave, false);
                who.color = who.group.color;
                Player.GlobalDie(who, false);
                who.SendMessage("You are now ranked " + newRank.color + newRank.name + "&g, type /help for your new set of commands.");
                Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
            }
        }
예제 #8
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }
            bool totalUnban = false;

            if (message[0] == '@')
            {
                totalUnban = true;
                message    = message.Remove(0, 1).Trim();
            }

            Player who = Player.Find(message);

            if (who == null)
            {
                if (Group.findPlayerGroup(message) != Group.findPerm(LevelPermission.Banned))
                {
                    foreach (Server.TempBan tban in Server.tempBans)
                    {
                        if (tban.name.ToLower() == message.ToLower())
                        {
                            Server.tempBans.Remove(tban);
                            Player.GlobalMessage(message + " has had their temporary ban lifted.");
                            return;
                        }
                    }
                    Player.SendMessage(p, "Player is not banned.");
                    return;
                }
                Player.GlobalMessage(message + " &8(banned)" + Server.DefaultColor + " is now " + Group.standard.color + Group.standard.name + Server.DefaultColor + "!");
                Group.findPerm(LevelPermission.Banned).playerList.Remove(message);
            }
            else
            {
                if (Group.findPlayerGroup(message) != Group.findPerm(LevelPermission.Banned))
                {
                    foreach (Server.TempBan tban in Server.tempBans)
                    {
                        if (tban.name == who.name)
                        {
                            Server.tempBans.Remove(tban);
                            Player.GlobalMessage(who.color + who.prefix + who.name + Server.DefaultColor + "has had their temporary ban lifted.");
                            return;
                        }
                    }
                    Player.SendMessage(p, "Player is not banned.");
                    return;
                }
                Player.GlobalChat(who, who.color + who.prefix + who.name + Server.DefaultColor + " is now " + Group.standard.color + Group.standard.name + Server.DefaultColor + "!", false);
                who.group = Group.standard; who.color = who.group.color; Player.GlobalDie(who, false);
                Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
                Group.findPerm(LevelPermission.Banned).playerList.Remove(message);
            }

            Group.findPerm(LevelPermission.Banned).playerList.Save();
            if (totalUnban)
            {
                Command.all.Find("unbanip").Use(p, "@" + message);
            }
        }
예제 #9
0
        public override void Use(Player p, string message)
        {
            if (message.ToLower().Trim() == "hours")
            {
                foreach (Group g in Group.GroupList)
                {
                    if (g != Group.findPerm(LevelPermission.Nobody))
                    {
                        if (g.reqHours > 0)
                        {
                            Player.SendMessage(p, g.color + g.trueName + ": " + g.reqHours + " hours are needed for promotion.");
                        }
                        else
                        {
                            Player.SendMessage(p, g.color + g.trueName + ": Cannot time rank.");
                        }
                    }
                }
                return;
            }
            if (p == null)
            {
                Player.SendMessage(p, "Command not usable in Console."); return;
            }
            int days  = Convert.ToInt32(p.timeSpent.Split(' ')[0]);
            int hours = Convert.ToInt32(p.timeSpent.Split(' ')[1]);

            if (days >= 1)
            {
                hours += days * 24;
            }

            if (p.group.reqHours <= 0)
            {
                p.SendMessage("Your current rank is not allowed to time rank."); return;
            }

            Group nextGroup = null; bool nextOne = false;

            for (int i = 0; i < Group.GroupList.Count; i++)
            {
                Group grp = Group.GroupList[i];
                if (nextOne)
                {
                    if (grp.Permission >= LevelPermission.Nobody)
                    {
                        break;
                    }
                    nextGroup = grp;
                    break;
                }
                if (grp == p.group)
                {
                    nextOne = true;
                }
            }

            if (hours >= p.group.reqHours)
            {
                if (nextGroup != null)
                {
                    Command.all.Find("promote").Use(null, p.name + " Timerank requirement reached.");
                }
                else
                {
                    p.SendMessage("There are no higher ranks.");
                }
            }
            else
            {
                p.SendMessage("The next rank requires &b" + p.group.reqHours + "&g hours.");
                p.SendMessage("You currently have &b" + hours + "&g hours.");
                p.SendMessage("Type &b/timerank hours" + "&g for the required hours for every rank.");
            }
        }
예제 #10
0
        public override void Use(Player p, string message)
        {
            if (!Directory.Exists("extra/text/"))
            {
                Directory.CreateDirectory("extra/text");
            }
            if (message.IndexOf(' ') == -1)
            {
                Help(p); return;
            }

            try
            {
                if (message.Split(' ')[0].ToLower() == "delete")
                {
                    if (!IsValid(message.Split(' ')[0]))
                    {
                        Player.SendMessage(p, "File name is invalid. The file name can only contain the following characters:");
                        Player.SendMessage(p, this.toLowerDictionary);
                        return;
                    }

                    if (File.Exists("extra/text/" + message.Split(' ')[1] + ".txt"))
                    {
                        File.Delete("extra/text/" + message.Split(' ')[1] + ".txt");
                        Player.SendMessage(p, "Deleted file");
                    }
                    else
                    {
                        Player.SendMessage(p, "Could not find file specified");
                    }
                }
                else
                {
                    if (!IsValid(message.Split(' ')[0]))
                    {
                        Player.SendMessage(p, "File name is invalid. Please only use the following characters in your file name:");
                        Player.SendMessage(p, this.toLowerDictionary);
                        return;
                    }

                    bool   again    = false;
                    string fileName = "extra/text/" + message.Split(' ')[0] + ".txt";
                    string group    = Group.findPerm(LevelPermission.Guest).name;
                    if (Group.Find(message.Split(' ')[1]) != null)
                    {
                        group = Group.Find(message.Split(' ')[1]).name;
                        again = true;
                    }
                    message = message.Substring(message.IndexOf(' ') + 1);
                    if (again)
                    {
                        message = message.Substring(message.IndexOf(' ') + 1);
                    }
                    string contents = message;
                    if (contents == "")
                    {
                        Help(p); return;
                    }
                    if (!File.Exists(fileName))
                    {
                        contents = "#" + group + System.Environment.NewLine + contents;
                    }
                    else
                    {
                        contents = " " + contents;
                    }
                    File.AppendAllText(fileName, contents);
                    Player.SendMessage(p, "Added text");
                }
            } catch { Help(p); }
        }
예제 #11
0
        public override void Use(Player p, string message)
        {
            byte b; Int64 seconds; Player who; Player.UndoPos Pos; int CurrentPos = 0;

            if (p != null)
            {
                p.RedoBuffer.Clear();
            }

            if (message == "")
            {
                message = p.name + " 30";
            }

            if (message.Split(' ').Length == 2)
            {
                if (message.Split(' ')[1].ToLower() == "all")
                {
                    seconds = 30;
                    if (p != null)
                    {
                        if (p.group.Permission >= LevelPermission.Operator)
                        {
                            seconds = 500000;
                        }
                    }
                    else
                    {
                        seconds = 500000;
                    }
                }
                else
                {
                    try { seconds = Int64.Parse(message.Split(' ')[1]); }
                    catch { Player.SendMessage(p, "Invalid seconds."); return; }
                }
            }
            else
            {
                try
                {
                    seconds = int.Parse(message);
                    if (p != null)
                    {
                        message = p.name + " " + message;
                    }
                }
                catch
                {
                    seconds = 30;
                    message = message + " 30";
                }
            }

            //if (message.Split(' ').Length == 1) if (char.IsDigit(message, 0)) { message = p.name + " " + message; } else { message = message + " 30"; }

            //try { seconds = Convert.ToInt16(message.Split(' ')[1]); } catch { seconds = 2; }
            if (seconds == 0)
            {
                seconds = 5400;
            }

            who = Player.Find(message.Split(' ')[0]);
            if (who != null)
            {
                if (p != null)
                {
                    if (who.group.Permission > p.group.Permission && who != p)
                    {
                        Player.SendMessage(p, "Cannot undo a user of higher or equal rank"); return;
                    }
                    if (who != p && p.group.Permission < LevelPermission.Operator)
                    {
                        Player.SendMessage(p, "Only an OP+ may undo other people's actions"); return;
                    }

                    if (p.group.Permission < LevelPermission.Builder && seconds > 120)
                    {
                        Player.SendMessage(p, Group.findPerm(LevelPermission.Guest).trueName + "s may only undo 2 minutes."); return;
                    }
                    else if (p.group.Permission < LevelPermission.AdvBuilder && seconds > 300)
                    {
                        Player.SendMessage(p, Group.findPerm(LevelPermission.Builder).trueName + "s may only undo 300 seconds."); return;
                    }
                    else if (p.group.Permission < LevelPermission.Operator && seconds > 1200)
                    {
                        Player.SendMessage(p, Group.findPerm(LevelPermission.AdvBuilder).trueName + "s may only undo 600 seconds."); return;
                    }
                    //else if (p.group.Permission == LevelPermission.Operator && seconds > 5400) { Player.SendMessage(p, "Operators may only undo 5400 seconds."); return; } //Ops can use undo all.
                }

                for (CurrentPos = who.UndoBuffer.Count - 1; CurrentPos >= 0; --CurrentPos)
                {
                    try
                    {
                        Pos = who.UndoBuffer[CurrentPos];
                        Level foundLevel = Level.FindExact(Pos.mapName);
                        b = foundLevel.GetTile(Pos.x, Pos.y, Pos.z);
                        if (Pos.timePlaced.AddSeconds(seconds) >= DateTime.Now)
                        {
                            if (b == Pos.newtype || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava)
                            {
                                foundLevel.Blockchange(Pos.x, Pos.y, Pos.z, Pos.type, true);

                                Pos.newtype = Pos.type; Pos.type = b;
                                if (p != null)
                                {
                                    p.RedoBuffer.Add(Pos);
                                }
                                who.UndoBuffer.RemoveAt(CurrentPos);
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    catch { }
                }

                if (p != who)
                {
                    Player.GlobalChat(p, "Undid " + who.color + who.name + "&g's actions in the past &b" + seconds + " seconds.", false);
                }
                else
                {
                    Player.SendMessage(p, "Undid your actions for in the past &b" + seconds + "&g seconds.");
                }
                return;
            }
            else if (message.Split(' ')[0].ToLower() == "physics")
            {
                if (p.group.Permission < LevelPermission.AdvBuilder)
                {
                    Player.SendMessage(p, "Reserved for Adv+"); return;
                }
                else if (p.group.Permission < LevelPermission.Operator && seconds > 1200)
                {
                    Player.SendMessage(p, "AdvBuilders may only undo 1200 seconds."); return;
                }
                else if (p.group.Permission == LevelPermission.Operator && seconds > 5400)
                {
                    Player.SendMessage(p, "Operators may only undo 5400 seconds."); return;
                }

                //int curPhysics = p.level.physics;
                Command.all.Find("physics").Use(p, "0");
                Level.UndoPos uP;
                ushort        x, y, z;

                if (p.level.UndoBuffer.Count != Server.physUndo)
                {
                    for (CurrentPos = p.level.currentUndo; CurrentPos >= 0; CurrentPos--)
                    {
                        try
                        {
                            uP = p.level.UndoBuffer[CurrentPos];
                            b  = p.level.GetTile(uP.location);
                            if (uP.timePerformed.AddSeconds(seconds) >= DateTime.Now)
                            {
                                if (b == uP.newType || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava)
                                {
                                    p.level.IntToPos(uP.location, out x, out y, out z);
                                    p.level.Blockchange(p, x, y, z, uP.oldType, true);
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                        catch { }
                    }
                }
                else
                {
                    for (CurrentPos = p.level.currentUndo; CurrentPos != p.level.currentUndo + 1; CurrentPos--)
                    {
                        try
                        {
                            if (CurrentPos < 0)
                            {
                                CurrentPos = p.level.UndoBuffer.Count - 1;
                            }
                            uP = p.level.UndoBuffer[CurrentPos];
                            b  = p.level.GetTile(uP.location);
                            if (uP.timePerformed.AddSeconds(seconds) >= DateTime.Now)
                            {
                                if (b == uP.newType || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava)
                                {
                                    p.level.IntToPos(uP.location, out x, out y, out z);
                                    p.level.Blockchange(p, x, y, z, uP.oldType, true);
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                        catch { }
                    }
                }

                //Command.all.Find("physics").Use(p, curPhysics.ToString());
                Player.GlobalMessage("Physics were undone &b" + seconds + "&g seconds");
            }
            else
            {
                if (p != null)
                {
                    if (p.group.Permission < LevelPermission.Operator)
                    {
                        Player.SendMessage(p, "Reserved for OP+"); return;
                    }
                    if (seconds > 5400 && p.group.Permission < LevelPermission.Operator)
                    {
                        Player.SendMessage(p, "Only Operators may undo more than 90 minutes."); return;
                    }
                }

                bool FoundUser = false;

                try
                {
                    DirectoryInfo di;
                    string[]      fileContent;

                    if (p != null)
                    {
                        p.RedoBuffer.Clear();
                    }

                    if (Directory.Exists("extra/undo/" + message.Split(' ')[0].ToLower()))
                    {
                        di = new DirectoryInfo("extra/undo/" + message.Split(' ')[0].ToLower());

                        for (int i = di.GetFiles("*.undo").Length - 1; i >= 0; i--)
                        {
                            fileContent = File.ReadAllText("extra/undo/" + message.Split(' ')[0].ToLower() + "/" + i + ".undo").Split(' ');
                            if (!undoBlah(fileContent, seconds, p))
                            {
                                break;
                            }
                        }
                        FoundUser = true;
                    }

                    if (Directory.Exists("extra/undoPrevious/" + message.Split(' ')[0].ToLower()))
                    {
                        di = new DirectoryInfo("extra/undoPrevious/" + message.Split(' ')[0].ToLower());

                        for (int i = di.GetFiles("*.undo").Length - 1; i >= 0; i--)
                        {
                            fileContent = File.ReadAllText("extra/undoPrevious/" + message.Split(' ')[0].ToLower() + "/" + i + ".undo").Split(' ');
                            if (!undoBlah(fileContent, seconds, p))
                            {
                                break;
                            }
                        }
                        FoundUser = true;
                    }

                    if (FoundUser)
                    {
                        Player.GlobalChat(p, "Undid " + Server.FindColor(message.Split(' ')[0]) + message.Split(' ')[0] + "&g's actions for the past &b" + seconds + " seconds.", false);
                    }
                    else
                    {
                        Player.SendMessage(p, "Could not find player specified.");
                    }
                }
                catch (Exception e)
                {
                    Server.ErrorLog(e);
                }
            }
        }
예제 #12
0
        public override void Use(Player p, string message)
        {
            Player who = null;

            if (message == "")
            {
                who = p; message = p.name;
            }
            else
            {
                who = Player.Find(message);
            }
            if (who != null && !who.hidden)
            {
                Player.SendMessage(p, who.color + who.name + Server.DefaultColor + " is on &b" + who.level.name);
                Player.SendMessage(p, who.color + who.prefix + who.name + Server.DefaultColor + " has :");
                Player.SendMessage(p, "> > the rank of " + who.group.color + who.group.name);
                Player.SendMessage(p, "> > the display name of " + who.color + who.displayName);
                Player.SendMessage(p, "> > &a" + who.money + Server.DefaultColor + " " + Server.moneys);
                Player.SendMessage(p, "> > &cdied &a" + who.overallDeath + Server.DefaultColor + " times");
                Player.SendMessage(p, "> > &bmodified &a" + who.overallBlocks + Server.DefaultColor + " blocks, &a" + who.loginBlocks + Server.DefaultColor + " since logging in.");
                //int ratio = (int)(Math.Round((decimal)(1 / (Math.Min(who.destroyedBlocks, (who.overallBlocks - who.destroyedBlocks)) / Math.Max(who.destroyedBlocks, (who.overallBlocks - who.destroyedBlocks))))));
                try { Player.SendMessage(p, "> > destroyed &a" + who.destroyedBlocks + Server.DefaultColor + " blocks, and built &a" + who.builtBlocks + Server.DefaultColor + "."); }
                catch { }
                // MaxMind
                string countryname = Server.iploopup.getCountry(IPAddress.Parse(who.ip)).getName();
                if (Server.useMaxMind)
                {
                    Player.SendMessage(p, "> > logged in from country &a" + countryname);
                }
                Player.SendMessage(p, "> > time spent on server: &a" + who.timeSpent.Split(' ')[0] + " Days, " + who.timeSpent.Split(' ')[1] + " Hours, " + who.timeSpent.Split(' ')[2] + " Minutes.");
                string storedTime = Convert.ToDateTime(DateTime.Now.Subtract(who.timeLogged).ToString()).ToString("HH:mm:ss");
                Player.SendMessage(p, "> > been logged in for &a" + storedTime);
                Player.SendMessage(p, "> > first logged into the server on &a" + who.firstLogin.ToString("yyyy-MM-dd") + " at " + who.firstLogin.ToString("HH:mm:ss"));
                Player.SendMessage(p, "> > logged in &a" + who.totalLogins + Server.DefaultColor + " times, &c" + who.totalKicked + Server.DefaultColor + " of which ended in a kick.");
                Player.SendMessage(p, "> > " + Awards.awardAmount(who.name) + " awards");
                if (!who.haswom)
                {
                    Player.SendMessage(p, "> > is not using &cWOM Game Client" + Server.DefaultColor + ".");
                }
                else
                {
                    Player.SendMessage(p, "> > is using &aWOM Game Client" + Server.DefaultColor + ", Version &a" + who.womversion + Server.DefaultColor + ".");
                }
                // Last ranked/banned reason:
                if (who.lastRankReason.ToLower() != "none" && !String.IsNullOrEmpty(who.lastRankReason))
                {
                    if (Group.findPerm(LevelPermission.Banned).playerList.Contains(who.name))
                    {
                        Player.SendMessage(p, "> > last &8banned&g at &a" + who.lastRankReason.Split(']')[0].Substring(1) + "&g; Reason: &a" + who.lastRankReason.Substring(who.lastRankReason.IndexOf("]") + 1).Trim());
                    }
                    else
                    {
                        Player.SendMessage(p, "> > last &branked&g at &a" + who.lastRankReason.Split(']')[0].Substring(1) + "&g; Reason: &a" + who.lastRankReason.Substring(who.lastRankReason.IndexOf("]") + 1).Trim());
                    }
                }
                bool skip = false;
                if (p != null)
                {
                    if (p.group.Permission <= LevelPermission.Operator)
                    {
                        skip = true;
                    }
                }
                if (!skip)
                {
                    string givenIP;
                    if (Server.bannedIP.Contains(who.ip))
                    {
                        givenIP = "&8" + who.ip + ", which is banned";
                    }
                    else
                    {
                        givenIP = who.ip;
                    }
                    Player.SendMessage(p, "> > the IP of " + givenIP);
                }
                if (Server.useWhitelist)
                {
                    if (Server.whiteList.Contains(who.name))
                    {
                        Player.SendMessage(p, "> > Player is &fWhitelisted");
                    }
                }
                if (Server.devs.Contains(who.name.ToLower()))
                {
                    Player.SendMessage(p, Server.DefaultColor + "> > Player is a &9Developer");
                }
                if (Server.staff.Contains(who.name.ToLower()))
                {
                    Player.SendMessage(p, Server.DefaultColor + "> > Player is a member of &4MCDawn Staff");
                }
                if (Server.administration.Contains(who.name.ToLower()))
                {
                    Player.SendMessage(p, Server.DefaultColor + "> > Player is a &6MCDawn Administrator");
                }
            }
            else
            {
                Player.SendMessage(p, "\"" + message + "\" is offline! Using /whowas instead."); Command.all.Find("whowas").Use(p, message);
            }
        }
예제 #13
0
파일: Group.cs 프로젝트: blha303/MCDawn
        public static void InitAll()
        {
            GroupList = new List <Group>();

            if (File.Exists("properties/ranks.properties"))
            {
                string[] lines = File.ReadAllLines("properties/ranks.properties");

                Group thisGroup = new Group();
                int   gots      = 0;

                foreach (string s in lines)
                {
                    try
                    {
                        if (s != "" && s[0] != '#')
                        {
                            if (s.Split('=').Length == 2)
                            {
                                string property = s.Split('=')[0].Trim();
                                string value    = s.Split('=')[1].Trim();

                                if (thisGroup.name == "" && property.ToLower() != "rankname")
                                {
                                    Server.s.Log("Hitting an error at " + s + " of ranks.properties");
                                }
                                else
                                {
                                    switch (property.ToLower())
                                    {
                                    case "rankname":
                                        gots      = 0;
                                        thisGroup = new Group();

                                        if (value.ToLower() == "developers" || value.ToLower() == "devs" || value.ToLower() == "developer" || value.ToLower() == "dev")
                                        {
                                            Server.s.Log("You are not a developer. Stop pretending you are.");
                                        }
                                        else if (GroupList.Find(grp => grp.name == value.ToLower()) == null)
                                        {
                                            thisGroup.trueName = value;
                                        }
                                        else
                                        {
                                            Server.s.Log("Cannot add the rank " + value + " twice");
                                        }
                                        break;

                                    case "permission":
                                        int foundPermission;

                                        try
                                        {
                                            foundPermission = int.Parse(value);
                                        }
                                        catch { Server.s.Log("Invalid permission on " + s); break; }

                                        if (thisGroup.Permission != LevelPermission.Null)
                                        {
                                            Server.s.Log("Setting permission again on " + s);
                                            gots--;
                                        }

                                        bool allowed = true;
                                        if (GroupList.Find(grp => grp.Permission == (LevelPermission)foundPermission) != null)
                                        {
                                            allowed = false;
                                        }

                                        if (foundPermission > 119 || foundPermission < -50)
                                        {
                                            Server.s.Log("Permission must be between -50 and 119 for ranks");
                                            break;
                                        }

                                        if (allowed)
                                        {
                                            gots++;
                                            thisGroup.Permission = (LevelPermission)foundPermission;
                                        }
                                        else
                                        {
                                            Server.s.Log("Cannot have 2 ranks set at permission level " + value);
                                        }
                                        break;

                                    case "limit":
                                        int foundLimit;

                                        try
                                        {
                                            foundLimit = int.Parse(value);
                                        }
                                        catch { Server.s.Log("Invalid limit on " + s); break; }

                                        gots++;
                                        thisGroup.maxBlocks = foundLimit;
                                        break;

                                    case "color":
                                        char foundChar;

                                        try
                                        {
                                            foundChar = char.Parse(value);
                                        }
                                        catch { Server.s.Log("Incorrect color on " + s); break; }

                                        if ((foundChar >= '0' && foundChar <= '9') || (foundChar >= 'a' && foundChar <= 'f'))
                                        {
                                            gots++;
                                            thisGroup.color = foundChar.ToString();
                                        }
                                        else
                                        {
                                            Server.s.Log("Invalid color code at " + s);
                                        }
                                        break;

                                    case "filename":
                                        if (value.Contains("\\") || value.Contains("/"))
                                        {
                                            Server.s.Log("Invalid filename on " + s);
                                            break;
                                        }

                                        gots++;
                                        thisGroup.fileName = value;
                                        break;

                                    case "reqhours":
                                        int foundHours;
                                        try
                                        {
                                            foundHours = int.Parse(value);
                                        }
                                        catch { Server.s.Log("Invalid limit on " + s); break; }
                                        gots++;
                                        thisGroup.reqHours = foundHours;
                                        break;
                                    }

                                    if (gots >= 5)
                                    {
                                        GroupList.Add(new Group(thisGroup.Permission, thisGroup.maxBlocks, thisGroup.trueName, thisGroup.color[0], thisGroup.fileName, thisGroup.reqHours));
                                    }
                                }
                            }
                            else
                            {
                                Server.s.Log("In ranks.properties, the line " + s + " is wrongly formatted");
                            }
                        }
                    }
                    catch { }
                }
            }

            if (GroupList.Find(grp => grp.Permission == LevelPermission.Banned) == null)
            {
                GroupList.Add(new Group(LevelPermission.Banned, 1, "Banned", '8', "banned.txt", 0));
            }
            if (Server.useGriefer)
            {
                if (GroupList.Find(grp => grp.Permission == LevelPermission.Griefer) == null)
                {
                    GroupList.Add(new Group(LevelPermission.Griefer, 1, "Griefer", 'f', "griefer.txt", 0));
                }
            }
            if (GroupList.Find(grp => grp.Permission == LevelPermission.Guest) == null)
            {
                GroupList.Add(new Group(LevelPermission.Guest, 1, "Guest", '7', "guest.txt", 0));
            }
            if (GroupList.Find(grp => grp.Permission == LevelPermission.Builder) == null)
            {
                GroupList.Add(new Group(LevelPermission.Builder, 400, "Builder", '2', "builders.txt", 0));
            }
            if (GroupList.Find(grp => grp.Permission == LevelPermission.AdvBuilder) == null)
            {
                GroupList.Add(new Group(LevelPermission.AdvBuilder, 1200, "AdvBuilder", '3', "advbuilders.txt", 0));
            }
            if (GroupList.Find(grp => grp.Permission == LevelPermission.Operator) == null)
            {
                GroupList.Add(new Group(LevelPermission.Operator, 2500, "Operator", 'c', "operators.txt", 0));
            }
            if (GroupList.Find(grp => grp.Permission == LevelPermission.Admin) == null)
            {
                GroupList.Add(new Group(LevelPermission.Admin, 65536, "SuperOP", 'e', "uberOps.txt", 0));
            }
            GroupList.Add(new Group(LevelPermission.Nobody, Int32.MaxValue, "Nobody", '1', "nobody.txt", 0));

            bool swap = true; Group storedGroup;

            while (swap)
            {
                swap = false;
                for (int i = 0; i < GroupList.Count - 1; i++)
                {
                    if (GroupList[i].Permission > GroupList[i + 1].Permission)
                    {
                        swap             = true;
                        storedGroup      = GroupList[i];
                        GroupList[i]     = GroupList[i + 1];
                        GroupList[i + 1] = storedGroup;
                    }
                }
            }

            if (Group.Find(Server.defaultRank) != null)
            {
                standard = Group.Find(Server.defaultRank);
            }
            else
            {
                standard = Group.findPerm(LevelPermission.Guest);
            }

            foreach (Player pl in Player.players)
            {
                pl.group = GroupList.Find(g => g.name == pl.group.name);
            }

            saveGroups(GroupList);
        }
예제 #14
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }
            if (!Directory.Exists("extra/reports/"))
            {
                Directory.CreateDirectory("extra/reports/");
            }
            // report format is: read/unread author of reoprt, time created, user reported, reason.
            if (message.Split(' ')[0].ToLower() == "view" || message.Split(' ')[0].ToLower() == "v")
            {
                if (p.group.Permission < LevelPermission.Operator && p != null)
                {
                    Player.SendMessage(p, "Only players ranked " + Group.findPerm(LevelPermission.Operator).trueName + " and higher may use this command."); return;
                }
                if (message.Split(' ').Length == 1)
                {
                    string unread   = "";
                    string fileList = "";
                    foreach (string s in Directory.GetFiles("extra/reports/"))
                    {
                        fileList += ", " + s.Replace(".report", "").Replace("extra/reports/", "");
                        if (File.ReadAllLines(s)[0].ToLower() == "unread")
                        {
                            unread += ", " + s.Replace(".report", "").Replace("extra/reports/", "");
                        }
                    }
                    if (fileList == "")
                    {
                        fileList = "..None.";
                    }
                    if (unread == "")
                    {
                        unread = "..None";
                    }
                    Player.SendMessage(p, "Type /report view <id> to view a specific report.");
                    Player.SendMessage(p, "Viewable report ids: &c" + fileList.Substring(2));
                    Player.SendMessage(p, "Unread report ids: &c" + unread.Substring(2));
                }
                else if (message.Split(' ').Length == 2)
                {
                    if (File.Exists("extra/reports/" + message.Split(' ')[1] + ".report"))
                    {
                        Player.SendMessage(p, "Viewing report " + message.Split(' ')[1] + ":");
                        for (int i = 0; i < File.ReadAllLines("extra/reports/" + message.Split(' ')[1] + ".report").Length; i++)
                        {
                            if (i > 1)
                            {
                                Player.SendMessage(p, File.ReadAllLines("extra/reports/" + message.Split(' ')[1] + ".report")[i]);
                            }
                        }
                        if (File.ReadAllLines("extra/reports/" + message.Split(' ')[1] + ".report")[0].ToLower() == "unread")
                        {
                            string[] lines = File.ReadAllLines("extra/reports/" + message.Split(' ')[1] + ".report");
                            lines[0] = "read";
                            File.WriteAllLines("extra/reports/" + message.Split(' ')[1] + ".report", lines);
                        }
                    }
                    else
                    {
                        Player.SendMessage(p, "Report could not be found.");
                    }
                }
            }
            else if (message.Split(' ')[0].ToLower() == "delete" || message.Split(' ')[0].ToLower() == "del" || message.Split(' ')[0].ToLower() == "d")
            {
                if (p.group.Permission < LevelPermission.Operator && p != null)
                {
                    Player.SendMessage(p, "Only players ranked " + Group.findPerm(LevelPermission.Operator).trueName + " and higher may use this command."); return;
                }
                if (message.Split(' ')[1].ToLower() == "all")
                {
                    foreach (string s in Directory.GetFiles("extra/reports/"))
                    {
                        File.Delete(s);
                    }
                    Player.SendMessage(p, "Deleted all reports.");
                    return;
                }
                if (File.Exists("extra/reports/" + message.Split(' ')[1] + ".report"))
                {
                    File.Delete("extra/reports/" + message.Split(' ')[1] + ".report");
                    Player.SendMessage(p, "Deleted report.");
                }
                else
                {
                    Player.SendMessage(p, "Report could not be found.");
                }
            }
            else
            {
                string toReport = "";
                Player who      = Player.Find(message.Split(' ')[0]);
                if (who != null)
                {
                    toReport = who.name;
                }
                else
                {
                    toReport = message.Split(' ')[0];
                }
                int newID = 1;
                foreach (string s in Directory.GetFiles("extra/reports/"))
                {
                    int parsed = 0;
                    if (int.TryParse(s.Replace(".report", "").Replace("extra/reports/", ""), out parsed))
                    {
                        if (parsed >= newID)
                        {
                            newID = parsed + 1;
                        }
                    }
                }

                File.WriteAllLines("extra/reports/" + newID + ".report", new string[] {
                    "unread",
                    "Report by: &c" + p.name,
                    "Time created: &c" + DateTime.Now.ToString(),
                    "User reported: &c" + toReport,
                    "Reason: &c" + message.Substring(message.IndexOf(" ") + 1).Trim()
                });
                Player.SendMessage(p, "Your report has been sent to the operators.");
                Player.GlobalMessageOps("To Ops: " + p.color + p.name + "&g has submitted a report.");
                Player.GlobalMessageOps("Type &c/report view " + newID + "&g to view.");
            }
        }
예제 #15
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();
        }
예제 #16
0
        public override void Use(Player p, string message)
        {
            Level foundLevel;

            if (message == "")
            {
                foundLevel = p.level;
            }
            else
            {
                foundLevel = Level.Find(message);
            }

            if (foundLevel == null)
            {
                Player.SendMessage(p, "Could not find specified level."); return;
            }

            Player.SendMessage(p, "&b" + foundLevel.name + "&g: Width=" + foundLevel.width.ToString() + " Height=" + foundLevel.depth.ToString() + " Depth=" + foundLevel.height.ToString());
            // Level is locked/unlocked
            if (foundLevel.locked == true)
            {
                Player.SendMessage(p, "Map is &cLocked");
            }
            else
            {
                Player.SendMessage(p, "Map is &2Unlocked");
            }
            // Level has guns allowed
            if (foundLevel.allowguns == true)
            {
                Player.SendMessage(p, "Guns are &benabled");
            }
            else
            {
                Player.SendMessage(p, "Guns are &bdisabled");
            }

            switch (foundLevel.physics)
            {
            case 0: Player.SendMessage(p, "Physics are &cOFF" + "&g on &b" + foundLevel.name); break;

            case 1: Player.SendMessage(p, "Physics are &aNormal" + "&g on &b" + foundLevel.name); break;

            case 2: Player.SendMessage(p, "Physics are &aAdvanced" + "&g on &b" + foundLevel.name); break;

            case 3: Player.SendMessage(p, "Physics are &aHardcore" + "&g on &b" + foundLevel.name); break;

            case 4: Player.SendMessage(p, "Physics are &aInstant" + "&g on &b" + foundLevel.name); break;

            case 5: Player.SendMessage(p, "Physics are &aDoors Only" + "&g on &b" + foundLevel.name); break;
            }

            try
            {
                Player.SendMessage(p, "Build rank = " + Group.findPerm(foundLevel.permissionbuild).color + Group.findPerm(foundLevel.permissionbuild).trueName);
                Player.SendMessage(p, "Visit rank = " + Group.findPerm(foundLevel.permissionvisit).color + Group.findPerm(foundLevel.permissionvisit).trueName);
            } catch (Exception e) { Server.ErrorLog(e); }

            try { Player.SendMessage(p, "SpeedHack Rank: " + foundLevel.speedHackRank.color + foundLevel.speedHackRank.trueName); }
            catch { Player.SendMessage(p, "SpeedHack Rank: " + Group.findPerm(LevelPermission.Banned).color + Group.findPerm(LevelPermission.Banned).trueName); }

            if (Directory.Exists(@Server.backupLocation + "/" + foundLevel.name))
            {
                int latestBackup = Directory.GetDirectories(@Server.backupLocation + "/" + foundLevel.name).Length;
                Player.SendMessage(p, "Latest backup: &a" + latestBackup + "&g at &a" + Directory.GetCreationTime(@Server.backupLocation + "/" + foundLevel.name + "/" + latestBackup).ToString("yyyy-MM-dd HH:mm:ss")); // + Directory.GetCreationTime(@Server.backupLocation + "/" + latestBackup + "/").ToString("yyyy-MM-dd HH:mm:ss"));
            }
            else
            {
                Player.SendMessage(p, "No backups for this map exist yet.");
            }
        }
예제 #17
0
        public override void Use(Player p, string message)
        {
            if (message.Split(' ').Length < 2)
            {
                Help(p); return;
            }
            Player who     = Player.Find(message.Split(' ')[0]);
            Group  newRank = Group.Find(message.Split(' ')[1]);
            string msgGave;

            if (p != null)
            {
                if (message.Split(' ').Length > 2)
                {
                    msgGave = message.Substring(message.IndexOf(' ', message.IndexOf(' ') + 1)) + " (" + p.name + ")";
                }
                else
                {
                    msgGave = "No reason given. (" + p.name + ").";
                }
            }
            else
            if (message.Split(' ').Length > 2)
            {
                msgGave = message.Substring(message.IndexOf(' ', message.IndexOf(' ') + 1)) + " (Console)";
            }
            else
            {
                msgGave = "No reason given. (Console).";
            }
            if (newRank == null)
            {
                Player.SendMessage(p, "Could not find specified rank."); return;
            }

            Group bannedGroup = Group.findPerm(LevelPermission.Banned);

            if (who == null)
            {
                //if (Server.devs.Contains(message.ToLower())) { p.SendMessage("Can't let you do that, Starfox."); return; }
                string foundName = message.Split(' ')[0];
                if (Group.findPlayerGroup(foundName) == bannedGroup || newRank == bannedGroup)
                {
                    Player.SendMessage(p, "Cannot change the rank to or from \"" + bannedGroup.name + "\".");
                    return;
                }

                if (p != null)
                {
                    if (Group.findPlayerGroup(foundName).Permission >= p.group.Permission || newRank.Permission >= p.group.Permission)
                    {
                        Player.SendMessage(p, "Cannot change the rank of someone equal or higher than you"); return;
                    }
                }

                Group oldGroup = Group.findPlayerGroup(foundName);
                oldGroup.playerList.Remove(foundName);
                oldGroup.playerList.Save();

                newRank.playerList.Add(foundName);
                newRank.playerList.Save();

                msgGave = msgGave.Trim();
                Player.GlobalMessage(foundName + " &f(offline)" + "&g's rank was set to " + newRank.color + newRank.name);
                MySQL.executeQuery("UPDATE Players SET lastRankReason = '[" + DateTime.Now.ToString() + "] " + msgGave.Replace("'", "\\'") + "' WHERE Name = '" + foundName + "'");
                Player.GlobalChat(null, "&6Reason: &f" + msgGave, false);
            }
            else
            {
                //if (!Server.devs.Contains(p.name) && Server.devs.Contains(who.name)) { p.SendMessage("Can't let you do that, Starfox."); return; }
                if (p != null)
                {
                    if (who.group == bannedGroup || newRank == bannedGroup)
                    {
                        Player.SendMessage(p, "Cannot change the rank to or from \"" + bannedGroup.name + "\".");
                        return;
                    }

                    if (who.group.Permission >= p.group.Permission || newRank.Permission >= p.group.Permission)
                    {
                        Player.SendMessage(p, "Cannot change the rank of someone equal or higher to yourself."); return;
                    }
                }

                who.group.playerList.Remove(who.name);
                who.group.playerList.Save();

                newRank.playerList.Add(who.name);
                newRank.playerList.Save();

                msgGave = msgGave.Trim();
                Player.GlobalChat(who, who.color + who.name + "&g's rank was set to " + newRank.color + newRank.name, false);
                Player.GlobalChat(null, "&6Reason: &f" + msgGave, false);
                who.group = newRank;
                who.color = who.group.color;
                Player.GlobalDie(who, false);
                who.SendMessage("You are now ranked " + newRank.color + newRank.name + "&g, type /help for your new set of commands.");
                Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
                try { if (!Server.cli)
                      {
                          MCDawn.Gui.Window.thisWindow.UpdateClientList(Player.players);
                      }
                }
                catch { }
                MySQL.executeQuery("UPDATE Players SET lastRankReason = '[" + DateTime.Now.ToString() + "] " + msgGave.Replace("'", "\\'") + "' WHERE Name = '" + who.originalName + "'");
                who.lastRankReason = "[" + DateTime.Now.ToString() + "] " + msgGave;
            }
        }
예제 #18
0
 public override void Use(Player p, string message)
 { // TODO
     try
     {
         if (message != "")
         {
             Help(p); return;
         }
         message = "";
         string message2 = "";
         bool   Once     = false;
         Server.levels.ForEach(delegate(Level level)
         {
             if (p != null && level.permissionvisit <= p.group.Permission)
             {
                 if (Group.findPerm(level.permissionbuild) != null)
                 {
                     message += ", " + Group.findPerm(level.permissionbuild).color + level.name + " &b[" + level.physics + "]";
                 }
                 else
                 {
                     message += ", " + level.name + " &b[" + level.physics + "]";
                 }
             }
             else if (p != null && level.permissionvisit > p.group.Permission)
             {
                 if (!Once)
                 {
                     Once = true;
                     if (Group.findPerm(level.permissionvisit) != null)
                     {
                         message2 += Group.findPerm(level.permissionvisit).color + level.name + " &b[" + level.physics + "]";
                     }
                     else
                     {
                         message2 += level.name + " &b[" + level.physics + "]";
                     }
                 }
                 else
                 {
                     if (Group.findPerm(level.permissionvisit) != null)
                     {
                         message2 += ", " + Group.findPerm(level.permissionvisit).color + level.name + " &b[" + level.physics + "]";
                     }
                     else
                     {
                         message2 += ", " + level.name + " &b[" + level.physics + "]";
                     }
                 }
             }
             else if (p == null)
             {
                 if (Group.findPerm(level.permissionbuild) != null)
                 {
                     message += ", " + Group.findPerm(level.permissionbuild).color + level.name + " &b[" + level.physics + "]";
                 }
                 else
                 {
                     message += ", " + level.name + " &b[" + level.physics + "]";
                 }
             }
         });
         Player.SendMessage(p, "Loaded: " + message.Remove(0, 2));
         if (message2 != "")
         {
             Player.SendMessage(p, "Can't Goto: " + message2);
         }
         Player.SendMessage(p, "Use &4/unloaded for unloaded levels.");
     }
     catch (Exception e)
     {
         Server.ErrorLog(e);
     }
 }