コード例 #1
0
ファイル: Level.Blocks.cs プロジェクト: ProtheanGod/KingMC
        public bool CheckAffectPermissions(Player p, ushort x, ushort y, ushort z, ExtBlock old, ExtBlock block)
        {
            if (!p.group.Blocks[old.BlockID] && !Block.AllowBreak(old.BlockID) && !Block.BuildIn(old.BlockID))
            {
                return(false);
            }
            if (p.PlayingTntWars && !CheckTNTWarsChange(p, x, y, z, ref block.BlockID))
            {
                return(false);
            }
            Zone[] zones = Zones.Items;
            if (zones.Length == 0)
            {
                return(CheckRank(p));
            }

            // Check zones specifically allowed in
            for (int i = 0; i < zones.Length; i++)
            {
                Zone zn = zones[i];
                if (x < zn.MinX || x > zn.MaxX || y < zn.MinY || y > zn.MaxY || z < zn.MinZ || z > zn.MaxZ)
                {
                    continue;
                }

                ZoneConfig cfg = zn.Config;
                if (p.group.Permission >= cfg.BuildMin)
                {
                    return(true);
                }
                if (cfg.BuildWhitelist.Count > 0 && cfg.BuildWhitelist.CaselessContains(p.name))
                {
                    return(true);
                }
            }

            // Check zones denied from
            for (int i = 0; i < zones.Length; i++)
            {
                Zone zn = zones[i];
                if (x < zn.MinX || x > zn.MaxX || y < zn.MinY || y > zn.MaxY || z < zn.MinZ || z > zn.MaxZ)
                {
                    continue;
                }
                AccessResult access = zn.Access.Check(p);
                if (access == AccessResult.Allowed || access == AccessResult.Whitelisted)
                {
                    continue;
                }

                if (p.ZoneSpam > DateTime.UtcNow)
                {
                    return(false);
                }
                zn.Access.CheckDetailed(p);
                p.ZoneSpam = DateTime.UtcNow.AddSeconds(2);
                return(false);
            }
            return(CheckRank(p));
        }
コード例 #2
0
        /// <summary> Returns the AccessController denying the player from changing blocks at the given coordinates. </summary>
        /// <remarks> If no AccessController denies the player, returns null. </remarks>
        public AccessController CanAffect(Player p, ushort x, ushort y, ushort z)
        {
            Zone[] zones = Zones.Items;
            if (zones.Length == 0)
            {
                goto checkRank;                    // TODO: avoid this
            }
            // Check zones specifically allowed in
            for (int i = 0; i < zones.Length; i++)
            {
                Zone zn = zones[i];
                if (x < zn.MinX || x > zn.MaxX || y < zn.MinY || y > zn.MaxY || z < zn.MinZ || z > zn.MaxZ)
                {
                    continue;
                }

                ZoneConfig cfg = zn.Config;
                if (cfg.BuildBlacklist.Count > 0 && cfg.BuildBlacklist.CaselessContains(p.name))
                {
                    break;
                }

                if (p.group.Permission >= cfg.BuildMin)
                {
                    return(null);
                }
                if (cfg.BuildWhitelist.Count > 0 && cfg.BuildWhitelist.CaselessContains(p.name))
                {
                    return(null);
                }
            }

            // Check zones denied from
            for (int i = 0; i < zones.Length; i++)
            {
                Zone zn = zones[i];
                if (x < zn.MinX || x > zn.MaxX || y < zn.MinY || y > zn.MaxY || z < zn.MinZ || z > zn.MaxZ)
                {
                    continue;
                }
                AccessResult access = zn.Access.Check(p.name, p.Rank);
                if (access == AccessResult.Allowed || access == AccessResult.Whitelisted)
                {
                    continue;
                }

                return(zn.Access);
            }

checkRank:
            if (p.level == this)
            {
                return(p.AllowBuild ? null : BuildAccess);
            }
            else
            {
                return(BuildAccess.CheckAllowed(p) ? null : BuildAccess);
            }
        }
コード例 #3
0
ファイル: Zone.cs プロジェクト: takaaptech/MCGalaxy
 public ZoneAccessController(ZoneConfig cfg)
 {
     this.cfg = cfg;
 }
コード例 #4
0
ファイル: Zone.cs プロジェクト: takaaptech/MCGalaxy
 public Zone()
 {
     Config = new ZoneConfig();
     Access = new ZoneAccessController(Config);
 }
コード例 #5
0
 public ZoneAccessController(Level lvl, ZoneConfig cfg)
 {
     this.lvl = lvl;
     this.cfg = cfg;
 }
コード例 #6
0
 public Zone(Level lvl)
 {
     Config = new ZoneConfig();
     Access = new ZoneAccessController(lvl, Config);
 }