Exemple #1
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 (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
                {
                    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); }
        }
Exemple #2
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");
        }
Exemple #3
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 + Server.DefaultColor + ": Width=" + foundLevel.width.ToString() + " Height=" + foundLevel.depth.ToString() + " Depth=" + foundLevel.height.ToString());

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

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

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

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

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

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

            if (Directory.Exists(@Server.backupLocation + "/" + foundLevel.name))
            {
                int latestBackup = Directory.GetDirectories(@Server.backupLocation + "/" + foundLevel.name).Length;
                Player.SendMessage(p, "Latest backup: &a" + latestBackup + Server.DefaultColor + " 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.");
            }
        }
Exemple #4
0
        public override void Use(Player p, string message)
        {
            int bancount = Group.findPerm(LevelPermission.Banned).playerList.All().Count;

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

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

            int playerCount = 0;
            int hiddenCount = 0;

            foreach (Player pl in Player.players)
            {
                if (!pl.hidden || p.group.Permission > LevelPermission.AdvBuilder || Server.devs.Contains(p.name.ToLower()))
                {
                    playerCount++;
                    if (pl.hidden && (p.group.Permission > LevelPermission.AdvBuilder || Server.devs.Contains(p.name.ToLower())))
                    {
                        hiddenCount++;
                    }
                }
            }
            if (playerCount == 1)
            {
                if (hiddenCount == 0)
                {
                    Player.SendMessage(p, "There is 1 player currently online.");
                }
                else
                {
                    Player.SendMessage(p, "There is 1 player currently online (" + hiddenCount + " hidden).");
                }
            }
            else
            {
                if (hiddenCount == 0)
                {
                    Player.SendMessage(p, "There are " + playerCount + " players online.");
                }
                else
                {
                    Player.SendMessage(p, "There are " + playerCount + " players online (" + hiddenCount + " hidden).");
                }
            }
        }
Exemple #5
0
        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")
                                        {
                                            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;
                                    }

                                    if (gots >= 4)
                                    {
                                        GroupList.Add(new Group(thisGroup.Permission, thisGroup.maxBlocks, thisGroup.trueName, thisGroup.color[0], thisGroup.fileName));
                                    }
                                }
                            }
                            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"));
            }
            if (GroupList.Find(grp => grp.Permission == LevelPermission.Guest) == null)
            {
                GroupList.Add(new Group(LevelPermission.Guest, 1, "Guest", '7', "guest.txt"));
            }
            if (GroupList.Find(grp => grp.Permission == LevelPermission.Builder) == null)
            {
                GroupList.Add(new Group(LevelPermission.Builder, 400, "Builder", '2', "builders.txt"));
            }
            if (GroupList.Find(grp => grp.Permission == LevelPermission.AdvBuilder) == null)
            {
                GroupList.Add(new Group(LevelPermission.AdvBuilder, 1200, "AdvBuilder", '3', "advbuilders.txt"));
            }
            if (GroupList.Find(grp => grp.Permission == LevelPermission.Operator) == null)
            {
                GroupList.Add(new Group(LevelPermission.Operator, 2500, "Operator", 'c', "operators.txt"));
            }
            if (GroupList.Find(grp => grp.Permission == LevelPermission.Admin) == null)
            {
                GroupList.Add(new Group(LevelPermission.Admin, 65536, "SuperOP", 'e', "uberOps.txt"));
            }
            GroupList.Add(new Group(LevelPermission.Nobody, 65536, "Nobody", '0', "nobody.txt"));

            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);
        }
Exemple #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);

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

                    Group foundGroup = Group.findPlayerGroup(message);

                    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 + " is already banned.");
                        return;
                    }

                    foundGroup.playerList.Remove(message);
                    foundGroup.playerList.Save();

                    Player.GlobalMessage(message + " &f(offline)" + Server.DefaultColor + " is now &8banned" + Server.DefaultColor + "!");
                    Group.findPerm(LevelPermission.Banned).playerList.Add(message);
                }
                else
                {
                    if (!Player.ValidName(who.name))
                    {
                        Player.SendMessage(p, "Invalid name \"" + who.name + "\".");
                        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, message + " is already banned.");
                        return;
                    }

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

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

                    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);
                }
                Group.findPerm(LevelPermission.Banned).playerList.Save();

                IRCBot.Say(message + " was banned.");
                Server.s.Log("BANNED: " + message.ToLower());

                if (totalBan == true)
                {
                    Command.all.Find("undo").Use(p, message + " 0");
                    Command.all.Find("banip").Use(p, "@ " + message);
                }
            }
            catch (Exception e) { Server.ErrorLog(e); }
        }
Exemple #7
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);
            }
        }
Exemple #8
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 (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 (!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 + "]";
                     }
                 }
             }
         });
         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);
     }
 }
Exemple #9
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)
            {
                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();

                Player.GlobalMessage(foundName + " &f(offline)" + Server.DefaultColor + "'s rank was set to " + newRank.color + newRank.name);
            }
            else if (who == p)
            {
                Player.SendMessage(p, "Cannot change your own rank."); return;
            }
            else
            {
                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();

                Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + "'s rank was 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 ranked " + newRank.color + newRank.name + Server.DefaultColor + ", 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);
            }
        }