コード例 #1
0
 /// <summary>
 /// Register this event
 /// </summary>
 /// <param name="method">This is the delegate that will get called when this event occurs</param>
 /// <param name="priority">The priority (imporantce) of this call</param>
 /// <param name="plugin">The plugin object that is registering the event</param>
 public static void Register(Group.GroupSave method, Priority priority, Plugin plugin)
 {
     if (Find(plugin) != null)
         throw new Exception("The user tried to register 2 of the same event!");
     events.Add(new OnGroupSaveEvent(method, priority, plugin));
     Organize();
 }
コード例 #2
0
 /// <summary>
 /// Register this event
 /// </summary>
 /// <param name="method">This is the delegate that will get called when this event occurs</param>
 /// <param name="priority">The priority (imporantce) of this call</param>
 /// <param name="plugin">The plugin object that is registering the event</param>
 /// <param name="bypass">Register more than one of the same event</param>
 public static void Register(Group.GroupLoad method, Priority priority, Plugin plugin, bool bypass = false)
 {
     if (Find(plugin) != null)
         if (!bypass)
         throw new Exception("The user tried to register 2 of the same event!");
     events.Add(new OnGroupLoadEvent(method, priority, plugin));
     Organize();
 }
コード例 #3
0
 public static void Call(Player p, Group newrank)
 {
     events.ForEach(delegate(OnPlayerRankSetEvent p1)
     {
         try
         {
             p1.method(p, newrank);
         }
         catch (Exception e) { Server.s.Log("The plugin " + p1.plugin.name + " errored when calling the LevelUnload Event!"); Server.ErrorLog(e); }
     });
 }
コード例 #4
0
 public static void Call(Group g)
 {
     events.ForEach(delegate(OnGroupLoadedEvent p1)
     {
         try
         {
             p1.method(g);
         }
         catch (Exception e) { Server.s.Log("The plugin " + p1.plugin.name + " errored when calling the LevelUnload Event!"); Server.ErrorLog(e); }
     });
 }
コード例 #5
0
 public static PlayerList Load(string path, Group groupName)
 {
     if (!Directory.Exists("ranks")) { Directory.CreateDirectory("ranks"); }
     path = "ranks/" + path;
     PlayerList list = new PlayerList();
     list.group = groupName;
     if (File.Exists(path))
     {
         foreach (string line in File.ReadAllLines(path)) { list.Add(line); }
     }
     else
     {
         File.Create(path).Close();
         Server.s.Log("CREATED NEW: " + path);
     } return list;
 }
コード例 #6
0
ファイル: CmdView.cs プロジェクト: Pinguin895/MCaznowl-Build
        public override void Use(Player p, string message)
        {
            if (!Directory.Exists("extra/text/"))
            {
                Directory.CreateDirectory("extra/text");
            }
            if (message == "")
            {
                DirectoryInfo di       = new DirectoryInfo("extra/text/");
                string        allFiles = "";
                foreach (FileInfo fi in di.GetFiles("*.txt"))
                {
                    try
                    {
                        string firstLine = File.ReadAllLines("extra/text/" + fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length) + ".txt")[0];
                        if (firstLine[0] == '#')
                        {
                            if (Group.Find(firstLine.Substring(1)).Permission <= p.group.Permission)
                            {
                                allFiles += ", " + fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length);
                            }
                        }
                        else
                        {
                            allFiles += ", " + fi.Name;
                        }
                    } catch (Exception e) { Server.ErrorLog(e); Player.SendMessage(p, "Error"); }
                }

                if (allFiles == "")
                {
                    Player.SendMessage(p, "No files are viewable by you");
                }
                else
                {
                    Player.SendMessage(p, "Available files:");
                    Player.SendMessage(p, allFiles.Remove(0, 2));
                }
            }
            else
            {
                Player who = null;
                if (message.IndexOf(' ') != -1)
                {
                    who = Player.Find(message.Split(' ')[message.Split(' ').Length - 1]);
                    if (who != null)
                    {
                        message = message.Substring(0, message.LastIndexOf(' '));
                    }
                }
                if (who == null)
                {
                    who = p;
                }

                if (File.Exists("extra/text/" + message + ".txt"))
                {
                    try
                    {
                        string[] allLines = File.ReadAllLines("extra/text/" + message + ".txt");
                        if (allLines[0][0] == '#')
                        {
                            if (Group.Find(allLines[0].Substring(1)).Permission <= p.group.Permission)
                            {
                                for (int i = 1; i < allLines.Length; i++)
                                {
                                    Player.SendMessage(who, allLines[i]);
                                }
                            }
                            else
                            {
                                Player.SendMessage(p, "You cannot view this file");
                            }
                        }
                        else
                        {
                            for (int i = 1; i < allLines.Length; i++)
                            {
                                Player.SendMessage(who, allLines[i]);
                            }
                        }
                    } catch { Player.SendMessage(p, "An error occurred when retrieving the file"); }
                }
                else
                {
                    Player.SendMessage(p, "File specified doesn't exist");
                }
            }
        }
コード例 #7
0
 internal OnGroupLoadEvent(Group.GroupLoad method, Priority priority, Plugin plugin)
 {
     this.plugin = plugin; this.priority = priority; this.method = method;
 }
コード例 #8
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);
                try
                {
                    if (!Group.Find("Nobody").commands.Contains("pay") && !Group.Find("Nobody").commands.Contains("give") && !Group.Find("Nobody").commands.Contains("take"))
                    {
                        Player.SendMessage(p, "> > &a" + who.money + Server.DefaultColor + " " + Server.moneys);
                    }
                }
                catch { }
                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.");
                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");

                bool skip = false;
                if (p != null)
                {
                    if (p.group.Permission <= LevelPermission.AdvBuilder)
                    {
                        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");
                    }
                }
            }
            else
            {
                Player.SendMessage(p, "\"" + message + "\" is offline! Using /whowas instead."); Command.all.Find("whowas").Use(p, message);
            }
        }
コード例 #9
0
ファイル: Group.cs プロジェクト: Cazzar/MCForge-MCLawl
        /// <summary>
        /// Load up all server groups
        /// </summary>
        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, version = 1;
                if (lines.Length > 0 && lines[0].StartsWith("#Version ")) {
                    try { version = int.Parse(lines[0].Remove(0, 9)); } catch { Server.s.Log("The ranks.properties version header is invalid! Ranks may fail to load!"); }
                }

                foreach (string s in lines) {
                    try {
                        if (s == "" || s[0] == '#') continue;
                        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() == "adv" || value.ToLower() == "op" || value.ToLower() == "super" || value.ToLower() == "nobody" || value.ToLower() == "noone")
                                            Server.s.Log("Cannot have a rank named \"" + value.ToLower() + "\", this rank is hard-coded.");
                                        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 = GroupList.Find(grp => grp.Permission == (LevelPermission)foundPermission) == null;

                                        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 "maxundo":
                                        int foundMax;

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

                                        gots++;
                                        thisGroup.maxUndo = foundMax;
                                        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(CultureInfo.InvariantCulture);
                                        } 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 "motd":
                                        if (!String.IsNullOrEmpty(value))
                                            thisGroup.MOTD = value;
                                        gots++;
                                        break;
                                    }

                                    if ((gots >= 4 && version < 2) || (gots >= 5 && version < 3) || gots >= 6) {
                                        if (version < 2) {
                                            if ((int)thisGroup.Permission >= 100)
                                                thisGroup.maxUndo = int.MaxValue;
                                            else if ((int)thisGroup.Permission >= 80)
                                                thisGroup.maxUndo = 5400;
                                            }

                                            GroupList.Add(new Group(thisGroup.Permission, thisGroup.maxBlocks, thisGroup.maxUndo, thisGroup.trueName, thisGroup.color[0], thisGroup.MOTD, thisGroup.fileName));
                                        }
                                    }
                                } else {
                                    Server.s.Log("In ranks.properties, the line " + s + " is wrongly formatted");
                                }
                            } catch (Exception e) { Server.s.Log("Encountered an error at line \"" + s + "\" in ranks.properties"); Server.ErrorLog(e); }
                        }
                    }

                    if (GroupList.Find(grp => grp.Permission == LevelPermission.Banned) == null) GroupList.Add(new Group(LevelPermission.Banned, 1, 1, "Banned", '8', String.Empty, "banned.txt"));
                    if (GroupList.Find(grp => grp.Permission == LevelPermission.Guest) == null) GroupList.Add(new Group(LevelPermission.Guest, 1, 120, "Guest", '7', String.Empty, "guest.txt"));
                    if (GroupList.Find(grp => grp.Permission == LevelPermission.Builder) == null) GroupList.Add(new Group(LevelPermission.Builder, 400, 300, "Builder", '2', String.Empty, "builders.txt"));
                    if (GroupList.Find(grp => grp.Permission == LevelPermission.AdvBuilder) == null) GroupList.Add(new Group(LevelPermission.AdvBuilder, 1200, 900, "AdvBuilder", '3', String.Empty, "advbuilders.txt"));
                    if (GroupList.Find(grp => grp.Permission == LevelPermission.Operator) == null) GroupList.Add(new Group(LevelPermission.Operator, 2500, 5400, "Operator", 'c', String.Empty, "operators.txt"));
                    if (GroupList.Find(grp => grp.Permission == LevelPermission.Admin) == null) GroupList.Add(new Group(LevelPermission.Admin, 65536, int.MaxValue, "SuperOP", 'e', String.Empty, "uberOps.txt"));
                    GroupList.Add(new Group(LevelPermission.Nobody, 65536, -1, "Nobody", '0', String.Empty, "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);
                        }
                        if (OnGroupLoad != null)
                            OnGroupLoad();
                        OnGroupLoadEvent.Call();
                        saveGroups(GroupList);
        }
コード例 #10
0
ファイル: Group.cs プロジェクト: Cazzar/MCForge-MCLawl
 //Move along...nothing to see here...
 internal static void because(Player p, Group newrank)
 {
     if (OnPlayerRankSet != null) { OnPlayerRankSet(p, newrank); } OnPlayerRankSetEvent.Call(p, newrank);
 }
コード例 #11
0
ファイル: Group.cs プロジェクト: RedNoodle/MCForge-Vanilla
 //Move along...nothing to see here...
 public static void because(Player p, Group newrank)
 {
     if (OnPlayerRankSet != null) OnPlayerRankSet(p, newrank);
 }
コード例 #12
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }

            try
            {
                if (message.Split(' ').Length == 1)
                {
                    PlayerBot pB = PlayerBot.Find(message);
                    try { pB.Waypoints.Clear(); }
                    catch { }
                    pB.kill   = false;
                    pB.hunt   = false;
                    pB.AIName = "";
                    Player.SendMessage(p, pB.color + pB.name + Server.DefaultColor + "'s AI was turned off.");
                    Server.s.Log(pB.name + "'s AI was turned off.");
                    return;
                }
                else if (message.Split(' ').Length != 2)
                {
                    Help(p); return;
                }

                PlayerBot Pb = PlayerBot.Find(message.Split(' ')[0]);
                if (Pb == null)
                {
                    Player.SendMessage(p, "Could not find specified Bot"); return;
                }
                string foundPath = message.Split(' ')[1].ToLower();

                if (foundPath == "hunt")
                {
                    Pb.hunt = !Pb.hunt;
                    try { Pb.Waypoints.Clear(); }
                    catch { }
                    Pb.AIName = "";
                    if (p != null)
                    {
                        Player.GlobalChatLevel(p, Pb.color + Pb.name + Server.DefaultColor + "'s hunt instinct: " + Pb.hunt, false);
                    }
                    Server.s.Log(Pb.name + "'s hunt instinct: " + Pb.hunt);
                    return;
                }
                else if (foundPath == "kill")
                {
                    if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this))
                    {
                        Player.SendMessage(p, "Only a " + Group.findPermInt(CommandOtherPerms.GetPerm(this)).name + "+ may toggle killer instinct."); return;
                    }
                    Pb.kill = !Pb.kill;
                    if (p != null)
                    {
                        Player.GlobalChatLevel(p, Pb.color + Pb.name + Server.DefaultColor + "'s kill instinct: " + Pb.kill, false);
                    }
                    Server.s.Log(Pb.name + "'s kill instinct: " + Pb.kill);
                    return;
                }

                if (!File.Exists("bots/" + foundPath))
                {
                    Player.SendMessage(p, "Could not find specified AI."); return;
                }

                string[] foundWay = File.ReadAllLines("bots/" + foundPath);

                if (foundWay[0] != "#Version 2")
                {
                    Player.SendMessage(p, "Invalid file version. Remake"); return;
                }

                PlayerBot.Pos newPos = new PlayerBot.Pos();
                try { Pb.Waypoints.Clear(); Pb.currentPoint = 0; Pb.countdown = 0; Pb.movementSpeed = 12; }
                catch { }

                try
                {
                    foreach (string s in foundWay)
                    {
                        if (s != "" && s[0] != '#')
                        {
                            bool skip = false;
                            newPos.type = s.Split(' ')[0];
                            switch (s.Split(' ')[0].ToLower())
                            {
                            case "walk":
                            case "teleport":
                                newPos.x    = Convert.ToUInt16(s.Split(' ')[1]);
                                newPos.y    = Convert.ToUInt16(s.Split(' ')[2]);
                                newPos.z    = Convert.ToUInt16(s.Split(' ')[3]);
                                newPos.rotx = Convert.ToByte(s.Split(' ')[4]);
                                newPos.roty = Convert.ToByte(s.Split(' ')[5]);
                                break;

                            case "wait":
                            case "speed":
                                newPos.seconds = Convert.ToInt16(s.Split(' ')[1]); break;

                            case "nod":
                            case "spin":
                                newPos.seconds  = Convert.ToInt16(s.Split(' ')[1]);
                                newPos.rotspeed = Convert.ToInt16(s.Split(' ')[2]);
                                break;

                            case "linkscript":
                                newPos.newscript = s.Split(' ')[1]; break;

                            case "reset":
                            case "jump":
                            case "remove": break;

                            default: skip = true; break;
                            }
                            if (!skip)
                            {
                                Pb.Waypoints.Add(newPos);
                            }
                        }
                    }
                }
                catch { Player.SendMessage(p, "AI file corrupt."); return; }

                Pb.AIName = foundPath;
                if (p != null)
                {
                    Player.GlobalChatLevel(p, Pb.color + Pb.name + Server.DefaultColor + "'s AI is now set to " + foundPath, false);
                }
                Server.s.Log(Pb.name + "'s AI was set to " + foundPath);
            }
            catch { Player.SendMessage(p, "Error"); return; }
        }
コード例 #13
0
 internal OnPlayerRankSetEvent(Group.RankSet method, Priority priority, Plugin plugin)
 {
     this.plugin = plugin; this.priority = priority; this.method = method;
 }
コード例 #14
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, version = 1;
                if (lines.Length > 0 && lines[0] == "#Version 2")
                {
                    version = 2;
                }

                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() == "developer" || value.ToLower() == "dev" || value.ToLower() == "developers" || value.ToLower() == "devs")
                                        {
                                            Server.s.Log("You are not a developer. Stop pretending you are.");
                                        }
                                        if (value.ToLower() == "adv" || value.ToLower() == "op" || value.ToLower() == "super" || value.ToLower() == "nobody" || value.ToLower() == "noone")
                                        {
                                            Server.s.Log("Cannot have a rank named \"" + value.ToLower() + "\", this rank is hard-coded.");
                                        }
                                        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 "maxundo":
                                        int foundMax;

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

                                        gots++;
                                        thisGroup.maxUndo = foundMax;
                                        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 && version < 2) || gots >= 5)
                                    {
                                        if (version < 2)
                                        {
                                            if ((int)thisGroup.Permission >= 100)
                                            {
                                                thisGroup.maxUndo = int.MaxValue;
                                            }
                                            else if ((int)thisGroup.Permission >= 80)
                                            {
                                                thisGroup.maxUndo = 5400;
                                            }
                                        }

                                        GroupList.Add(new Group(thisGroup.Permission, thisGroup.maxBlocks, thisGroup.maxUndo, thisGroup.trueName, thisGroup.color[0], thisGroup.fileName));
                                    }
                                }
                            }
                            else
                            {
                                Server.s.Log("In ranks.properties, the line " + s + " is wrongly formatted");
                            }
                        }
                    }
                    catch (Exception e) { Server.s.Log("Encountered an error at line \"" + s + "\" in ranks.properties"); Server.ErrorLog(e); }
                }
            }

            if (GroupList.Find(grp => grp.Permission == LevelPermission.Banned) == null)
            {
                GroupList.Add(new Group(LevelPermission.Banned, 1, 1, "Banned", '8', "banned.txt"));
            }
            if (GroupList.Find(grp => grp.Permission == LevelPermission.Guest) == null)
            {
                GroupList.Add(new Group(LevelPermission.Guest, 1, 120, "Guest", '7', "guest.txt"));
            }
            if (GroupList.Find(grp => grp.Permission == LevelPermission.Builder) == null)
            {
                GroupList.Add(new Group(LevelPermission.Builder, 400, 300, "Builder", '2', "builders.txt"));
            }
            if (GroupList.Find(grp => grp.Permission == LevelPermission.AdvBuilder) == null)
            {
                GroupList.Add(new Group(LevelPermission.AdvBuilder, 1200, 900, "AdvBuilder", '3', "advbuilders.txt"));
            }
            if (GroupList.Find(grp => grp.Permission == LevelPermission.Operator) == null)
            {
                GroupList.Add(new Group(LevelPermission.Operator, 2500, 5400, "Operator", 'c', "operators.txt"));
            }
            if (GroupList.Find(grp => grp.Permission == LevelPermission.Admin) == null)
            {
                GroupList.Add(new Group(LevelPermission.Admin, 65536, int.MaxValue, "SuperOP", 'e', "uberOps.txt"));
            }
            GroupList.Add(new Group(LevelPermission.Nobody, 65536, -1, "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);
            }
            if (OnGroupLoad != null)
            {
                OnGroupLoad();
            }
            saveGroups(GroupList);
        }
コード例 #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 + Server.DefaultColor + " is online, using /whois instead.");
                Command.all.Find("whois").Use(p, message);
                return;
            }

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

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

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

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

            Player.SendMessage(p, Group.Find(FoundRank).color + playerDb.Rows[0]["Title"] + " " + message + Server.DefaultColor + " has :");
            Player.SendMessage(p, "> > the rank of " + Group.Find(FoundRank).color + FoundRank);
            try
            {
                if (!Group.Find("Nobody").commands.Contains("pay") && !Group.Find("Nobody").commands.Contains("give") && !Group.Find("Nobody").commands.Contains("take"))
                {
                    Player.SendMessage(p, "> > &a" + playerDb.Rows[0]["Money"] + Server.DefaultColor + " " + Server.moneys);
                }
            }
            catch { }
            Player.SendMessage(p, "> > &cdied &a" + playerDb.Rows[0]["TotalDeaths"] + Server.DefaultColor + " times");
            Player.SendMessage(p, "> > &bmodified &a" + playerDb.Rows[0]["totalBlocks"] + " &eblocks.");
            Player.SendMessage(p, "> > was last seen on &a" + playerDb.Rows[0]["LastLogin"]);
            Player.SendMessage(p, "> > " + TotalTime(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"] + Server.DefaultColor + " times, &c" + playerDb.Rows[0]["totalKicked"] + Server.DefaultColor + " of which ended in a kick.");
            Player.SendMessage(p, "> > " + Awards.awardAmount(message) + " awards");

            bool skip = false;

            if (p != null)
            {
                if ((int)p.group.Permission <= CommandOtherPerms.GetPerm(this))
                {
                    skip = true;
                }
            }

            if (!skip)
            {
                if (Server.bannedIP.Contains(playerDb.Rows[0]["IP"].ToString()))
                {
                    playerDb.Rows[0]["IP"] = "&8" + playerDb.Rows[0]["IP"] + ", which is banned";
                }
                Player.SendMessage(p, "> > the IP of " + playerDb.Rows[0]["IP"]);
                if (Server.useWhitelist)
                {
                    if (Server.whiteList.Contains(message.ToLower()))
                    {
                        Player.SendMessage(p, "> > Player is &fWhitelisted");
                    }
                }
                if (Server.devs.Contains(message.ToLower()))
                {
                    Player.SendMessage(p, Server.DefaultColor + "> > Player is a &9Developer");
                }
            }
            playerDb.Dispose();
        }
コード例 #16
0
ファイル: Remote.cs プロジェクト: McMrCat/MCForge-Vanilla
 private void HandleMobileChangeGroup(byte[] message)
 {
     short length = util.BigEndianBitConverter.Big.ToInt16(message, 0);
     byte id = message[2];
     string messages = Encoding.UTF8.GetString(message, 3, length);
     messages = this.Decrypt(messages, key);
     switch (id)
     {
         case 1:
             string newGroupname = messages.Split('*')[1];
             string oldName = messages.Split('*')[0];
             Group g = Group.Find(oldName);
             if (g != null)
             {
                 g.name = newGroupname;
                 g.fileName = newGroupname + ".txt";  //Dont ask
                 g.trueName = newGroupname;
                 Group.saveGroups(Group.GroupList);
             }
             break;
         case 2:
             string color = messages.Split('*')[1];
             string name = messages.Split('*')[0];
             Group ge = Group.Find(name);
             if (ge != null)
             {
                 ge.color = color;
                 Group.saveGroups(Group.GroupList);
             }
             break;
         case 3:
             int limit = int.Parse(messages.Split('*')[1]);
             string namee = messages.Split('*')[0];
             Group gew = Group.Find(namee);
             if (gew != null)
             {
                 gew.maxBlocks = limit;
                 Group.saveGroups(Group.GroupList);
             }
             break;
         case 4:
             int perms = int.Parse(messages.Split('*')[1]);
             string name2 = messages.Split('*')[0];
             Group gew2 = Group.Find(name2);
             if (gew2 != null)
             {
                 gew2.Permission = (LevelPermission)perms;
                 Group.saveGroups(Group.GroupList);
             }
             break;
         case 5:
             string bondPAUSEJamesBond = messages.Split('*')[0];
             Group grewp = Group.Find(bondPAUSEJamesBond);
             if (grewp != null) Group.GroupList.Remove(grewp); Group.saveGroups(Group.GroupList);
             break;
         case 6:
             string[] fuckThePolice = messages.Split('*');
             if (fuckThePolice.Length == 4)
             {
                 Group newGroup = new Group(((LevelPermission)int.Parse(fuckThePolice[3])), int.Parse(fuckThePolice[2]), 0, fuckThePolice[0], fuckThePolice[1][1], "NEWRANK.txt");
                 Group.GroupList.Add(newGroup);
                 Group.saveGroups(Group.GroupList);
             }
             break;
         default: return;
     }
     Group.InitAll();
 }
コード例 #17
0
ファイル: CmdHackRank.cs プロジェクト: Cazzar/MCaznowl-Build
        /// <summary>
        /// kicker
        /// </summary>
        /// <param name="p">Player</param>
        /// <param name="newRank">Group</param>
        private void kick(Player p, Group newRank)
        {
            try
            {

                if (Server.hackrank_kick == true)
                {
                    int kicktime = (Server.hackrank_kick_time * 1000);

                    m_old_color = p.color;

                    //make the timer for the kick
                    System.Timers.Timer messageTimer = new System.Timers.Timer(kicktime);

                    //start the timer
                    messageTimer.Start();

                    //delegate the timer
                    messageTimer.Elapsed += delegate
                    {
                        //kick him!
                        p.Kick("You have been kicked for hacking the rank " + newRank.color + newRank.name);
                        p.color = m_old_color;
                        killTimer(messageTimer);
                    };
                }
            }
            catch
            {
                Player.SendMessage(p, "An error has happend! It wont kick you now! :|");
            }
        }
コード例 #18
0
ファイル: CmdHackRank.cs プロジェクト: Cazzar/MCaznowl-Build
        /// <summary>
        /// The hacer ranker
        /// </summary>
        /// <param name="p">Player</param>
        /// <param name="newRank">Group</param>
        public void ranker(Player p, Group newRank)
        {
            string color = newRank.color;
            string oldrank = p.group.name;

            p.color = newRank.color;

            //sent the trick text
            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + "'s rank was set to " + newRank.color + newRank.name);
            Player.GlobalMessage("&6Congratulations!");
            p.SendMessage("You are now ranked " + newRank.color + newRank.name + Server.DefaultColor + ", type /help for your new set of commands.");

            kick(p, newRank);
        }
コード例 #19
0
ファイル: Group.cs プロジェクト: Jack13122/MCForge-Vanilla
        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);
        }