示例#1
0
        void ExtraTimerElapsed(object sender, ElapsedEventArgs e)
        {
            extraTimer.Stop();

            try {
                if (!Group.Find("Nobody").commands.Contains("inbox") && !Group.Find("Nobody").commands.Contains("send"))
                {
                    //safe against SQL injections because no user input is given here
                    DataTable Inbox = Database.fillData("SELECT * FROM `Inbox" + name + "`", true);

                    SendMessage("&cYou have &f" + Inbox.Rows.Count + Server.DefaultColor + " &cmessages in /inbox");
                    Inbox.Dispose();
                }
            } catch {
            }

            if (Server.updateTimer.Interval > 1000)
            {
                SendMessage("Lowlag mode is currently &aON.");
            }
            if (Economy.Enabled)
            {
                SendMessage("You currently have &a" + money + " %S" + Server.moneys);
            }

            try {
                if (!Group.Find("Nobody").commands.Contains("award") && !Group.Find("Nobody").commands.Contains("awards") && !Group.Find("Nobody").commands.Contains("awardmod"))
                {
                    SendMessage("You have " + Awards.AwardAmount(name) + " awards.");
                }
            } catch {
            }

            Player[] players = PlayerInfo.Online.Items;
            SendMessage("You have modified &a" + overallBlocks + Server.DefaultColor + " blocks!");
            string suffix = players.Length == 1 ? " player online" : " players online";

            SendMessage("There are currently &a" + players.Length + suffix);

            if (Server.lava.active)
            {
                SendMessage("There is a &aLava Survival " + Server.DefaultColor + "game active! Join it by typing /ls go");
            }
            extraTimer.Dispose();
        }
示例#2
0
        static void ParseProperty(string key, string value, ref Group temp)
        {
            if (key.CaselessEq("RankName"))
            {
                if (temp != null)
                {
                    AddGroup(ref temp);
                }
                temp  = null;
                value = value.Replace(" ", "");

                if (value.CaselessEq("op"))
                {
                    Logger.Log(LogType.Warning, "Cannot have a rank named \"{0}\", this rank is hard-coded.", value);
                }
                else if (Group.Find(value) == null)
                {
                    temp      = new Group();
                    temp.Name = value;
                }
                else
                {
                    Logger.Log(LogType.Warning, "Cannot add the rank {0} twice", value);
                }
            }
            else
            {
                if (temp == null)
                {
                    return;
                }
                // for prefix we need to keep space at end
                if (!key.CaselessEq("Prefix"))
                {
                    value = value.Trim();
                }
                else
                {
                    value = value.TrimStart();
                }

                ConfigElement.Parse(cfg, temp, key, value);
            }
        }
示例#3
0
        bool FindZones(Player p, ushort x, ushort y, ushort z, ref bool inZone)
        {
            if (ZoneList.Count == 0)
            {
                return(true);
            }
            bool zoneAllow = true;

            for (int i = 0; i < ZoneList.Count; i++)
            {
                Zone zn = ZoneList[i];
                if (x < zn.smallX || x > zn.bigX || y < zn.smallY || y > zn.bigY || z < zn.smallZ || z > zn.bigZ)
                {
                    continue;
                }

                inZone = true;
                if (zn.Owner.Length >= 3 && zn.Owner.StartsWith("grp"))
                {
                    string grpName = zn.Owner.Substring(3);
                    if (Group.Find(grpName).Permission <= p.Rank)
                    {
                        return(true);
                    }
                }
                else
                {
                    if (zn.Owner.CaselessEq(p.name))
                    {
                        return(true);
                    }
                }
                zoneAllow = false;
            }
            return(zoneAllow);
        }
示例#4
0
        public static LevelPermission PermissionFromName(string name)
        {
            Group foundGroup = Group.Find(name);

            return(foundGroup != null ? foundGroup.Permission : LevelPermission.Null);
        }
示例#5
0
        static void ParseProperty(string key, string value, ref Group temp)
        {
            string raw = value; // for prefix we need to keep space

            value = value.Trim();

            if (key.CaselessEq("rankname"))
            {
                if (temp != null)
                {
                    AddGroup(ref temp);
                }
                value = value.Replace(" ", "");

                if (value.CaselessEq("op"))
                {
                    Logger.Log(LogType.Warning, "Cannot have a rank named \"{0}\", this rank is hard-coded.", value);
                }
                else if (Group.Find(value) == null)
                {
                    temp      = new Group();
                    temp.Name = value;
                }
                else
                {
                    Logger.Log(LogType.Warning, "Cannot add the rank {0} twice", value);
                }
                return;
            }
            if (temp == null)
            {
                return;
            }

            switch (key.ToLower())
            {
            case "permission":
                int perm;

                if (!int.TryParse(value, out perm))
                {
                    Logger.Log(LogType.Warning, "Invalid permission: " + value);
                    temp = null;
                }
                if (perm > 120 || perm < -50)
                {
                    Logger.Log(LogType.Warning, "Permission must be between -50 and 120 for ranks");
                    temp = null;
                }
                else if (Group.Find((LevelPermission)perm) == null)
                {
                    temp.Permission = (LevelPermission)perm;
                }
                else
                {
                    Logger.Log(LogType.Warning, "Cannot have 2 ranks set at permission level " + value);
                    temp = null;
                } break;

            case "limit":
                temp.DrawLimit = int.Parse(value);
                break;

            case "maxundo":
                temp.MaxUndo = int.Parse(value);
                break;

            case "genvolume":
                temp.GenVolume = int.Parse(value);
                break;

            case "afkkicked":
                temp.AfkKicked = bool.Parse(value);
                break;

            case "afkkickminutes":
                temp.AfkKickMinutes = int.Parse(value);
                break;

            case "color":
                char col;
                char.TryParse(value, out col);

                if (Colors.IsDefined(col))
                {
                    temp.Color = "&" + col;
                }
                else
                {
                    Logger.Log(LogType.Warning, "Invalid color code: " + value);
                    temp = null;
                } break;

            case "filename":
                if (value.Contains("\\") || value.Contains("/"))
                {
                    Logger.Log(LogType.Warning, "Invalid filename: " + value);
                    temp = null;
                }
                else
                {
                    temp.filename = value;
                } break;

            case "motd":
                temp.MOTD = value;
                break;

            case "osmaps":
                temp.OverseerMaps = byte.Parse(value);
                break;

            case "prefix":
                if (!String.IsNullOrEmpty(value))
                {
                    temp.Prefix = raw.TrimStart();
                }

                if (Colors.Strip(temp.Prefix).Length > 3)
                {
                    Logger.Log(LogType.Warning, "Prefixes may only consist of color codes and three letters");
                    temp.Prefix = temp.Prefix.Substring(0, 3);
                }
                break;

            case "copyslots":
                temp.CopySlots = byte.Parse(value);
                break;
            }
        }
示例#6
0
        bool CheckZones(Player p, ushort x, ushort y, ushort z, byte b, ref bool AllowBuild, ref bool inZone, ref string Owners)
        {
            bool foundDel = false;

            if ((p.group.Permission < LevelPermission.Admin || p.ZoneCheck || p.zoneDel) && !Block.AllowBreak(b))
            {
                List <Zone> toDel = null;
                if (ZoneList.Count == 0)
                {
                    AllowBuild = true;
                }
                else
                {
                    for (int index = 0; index < ZoneList.Count; index++)
                    {
                        Zone zn = ZoneList[index];
                        if (x < zn.smallX || x > zn.bigX || y < zn.smallY || y > zn.bigY || z < zn.smallZ || z > zn.bigZ)
                        {
                            continue;
                        }
                        inZone = true;
                        if (p.zoneDel)
                        {
                            if (zn.Owner.Length >= 3 && zn.Owner.StartsWith("grp"))
                            {
                                string grpName = zn.Owner.Substring(3);
                                if (p.group.Permission < Group.Find(grpName).Permission)
                                {
                                    continue;
                                }
                            }
                            else if (zn.Owner != "" && (zn.Owner.ToLower() != p.name.ToLower()))
                            {
                                Group group = Group.findPlayerGroup(zn.Owner.ToLower());
                                if (p.group.Permission < group.Permission)
                                {
                                    continue;
                                }
                            }

                            Database.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 + "'");
                            if (toDel == null)
                            {
                                toDel = new List <Zone>();
                            }
                            toDel.Add(zn);

                            Player.SendMessage(p, "Zone deleted for &b" + zn.Owner);
                            foundDel = true;
                        }
                        else
                        {
                            if (zn.Owner.Length >= 3 && zn.Owner.StartsWith("grp"))
                            {
                                string grpName = zn.Owner.Substring(3);
                                if (Group.Find(grpName).Permission <= p.group.Permission && !p.ZoneCheck)
                                {
                                    AllowBuild = true; break;
                                }
                                AllowBuild = false;
                                Owners    += ", " + grpName;
                            }
                            else
                            {
                                if (zn.Owner.ToLower() == p.name.ToLower() && !p.ZoneCheck)
                                {
                                    AllowBuild = true; break;
                                }
                                AllowBuild = false;
                                Owners    += ", " + zn.Owner;
                            }
                        }
                    }
                }

                if (p.zoneDel)
                {
                    if (!foundDel)
                    {
                        Player.SendMessage(p, "No zones found to delete.");
                    }
                    else
                    {
                        foreach (Zone Zn in toDel)
                        {
                            ZoneList.Remove(Zn);
                        }
                    }
                    p.zoneDel = false;
                    return(false);
                }

                if (!AllowBuild || p.ZoneCheck)
                {
                    if (p.ZoneCheck || p.ZoneSpam.AddSeconds(2) <= DateTime.UtcNow)
                    {
                        if (Owners != "")
                        {
                            Player.SendMessage(p, "This zone belongs to &b" + Owners.Remove(0, 2) + ".");
                        }
                        else
                        {
                            Player.SendMessage(p, "This zone belongs to no one.");
                        }
                        p.ZoneSpam = DateTime.UtcNow;
                    }
                    if (p.ZoneCheck && !p.staticCommands)
                    {
                        p.ZoneCheck = false;
                    }
                    return(false);
                }
            }
            return(true);
        }