Beispiel #1
0
        public CanPlaceResult CanPlace(int x, int y, int h, Block newBlock, bool isManual)
        {
            CanPlaceResult result;
            Block          block = World.Map.GetBlock(x, y, h);

            // check special blocktypes
            if (newBlock == Block.Admincrete && !Can(Permission.PlaceAdmincrete))
            {
                result = CanPlaceResult.BlocktypeDenied;
                goto eventCheck;
            }
            else if ((newBlock == Block.Water || newBlock == Block.StillWater) && !Can(Permission.PlaceWater))
            {
                result = CanPlaceResult.BlocktypeDenied;
                goto eventCheck;
            }
            else if ((newBlock == Block.Lava || newBlock == Block.StillLava) && !Can(Permission.PlaceLava))
            {
                result = CanPlaceResult.BlocktypeDenied;
                goto eventCheck;
            }

            // check deleting admincrete
            if (block == Block.Admincrete && !Can(Permission.DeleteAdmincrete))
            {
                result = CanPlaceResult.BlocktypeDenied;
                goto eventCheck;
            }

            // check zones & world permissions
            PermissionOverride zoneCheckResult = World.Map.CheckZones(x, y, h, this);

            if (zoneCheckResult == PermissionOverride.Allow)
            {
                result = CanPlaceResult.Allowed;
                goto eventCheck;
            }
            else if (zoneCheckResult == PermissionOverride.Deny)
            {
                result = CanPlaceResult.ZoneDenied;
                goto eventCheck;
            }

            // Check world permissions
            switch (World.BuildSecurity.CheckDetailed(Info))
            {
            case SecurityCheckResult.Allowed:
                // Check rank permissions
                if ((Can(Permission.Build) || newBlock == Block.Air) &&
                    (Can(Permission.Delete) || block == Block.Air))
                {
                    result = CanPlaceResult.Allowed;
                    goto eventCheck;
                }
                else
                {
                    result = CanPlaceResult.RankDenied;
                    goto eventCheck;
                }

            case SecurityCheckResult.WhiteListed:
                result = CanPlaceResult.Allowed;
                goto eventCheck;

            default:
                result = CanPlaceResult.WorldDenied;
                goto eventCheck;
            }

eventCheck:
            return(Server.RaisePlayerPlacingBlockEvent(this, (short)x, (short)y, (short)h, block, newBlock, isManual, result));
        }