Esempio n. 1
0
        static void ZoneInfoHandler(Player player, Command cmd)
        {
            string zoneName = cmd.Next();

            if (zoneName == null)
            {
                player.Message("No zone name specified. See &H/Help ZInfo");
                return;
            }

            Zone zone = player.WorldMap.Zones.Find(zoneName);

            if (zone == null)
            {
                player.MessageNoZone(zoneName);
                return;
            }

            player.Message("About zone \"{0}\": size {1} x {2} x {3}, contains {4} blocks, editable by {5}+.",
                           zone.Name,
                           zone.Bounds.Width, zone.Bounds.Length, zone.Bounds.Height,
                           zone.Bounds.Volume,
                           zone.Controller.MinRank.ClassyName);

            player.Message("  Zone center is at ({0},{1},{2}).",
                           (zone.Bounds.XMin + zone.Bounds.XMax) / 2,
                           (zone.Bounds.YMin + zone.Bounds.YMax) / 2,
                           (zone.Bounds.ZMin + zone.Bounds.ZMax) / 2);

            if (zone.CreatedBy != null)
            {
                player.Message("  Zone created by {0}&S on {1:MMM d} at {1:h:mm} ({2} ago).",
                               zone.CreatedByClassy,
                               zone.CreatedDate,
                               DateTime.UtcNow.Subtract(zone.CreatedDate).ToMiniString());
            }

            if (zone.EditedBy != null)
            {
                player.Message("  Zone last edited by {0}&S on {1:MMM d} at {1:h:mm} ({2}d {3}h ago).",
                               zone.EditedByClassy,
                               zone.EditedDate,
                               DateTime.UtcNow.Subtract(zone.EditedDate).Days,
                               DateTime.UtcNow.Subtract(zone.EditedDate).Hours);
            }

            PlayerExceptions zoneExceptions = zone.ExceptionList;

            if (zoneExceptions.Included.Length > 0)
            {
                player.Message("  Zone whitelist includes: {0}",
                               zoneExceptions.Included.JoinToClassyString());
            }

            if (zoneExceptions.Excluded.Length > 0)
            {
                player.Message("  Zone blacklist excludes: {0}",
                               zoneExceptions.Excluded.JoinToClassyString());
            }

            if (null != zone.Message)
            {
                player.Message("  Zone has custom deny build message: " + zone.Message);
            }
            else
            {
                player.Message("  Zone has no custom deny build message");
            }
        }
Esempio n. 2
0
        public static void OnPlayerPlacingBlock(object sender, PlayerPlacingBlockEventArgs e)
        {
            if (e.Context != BlockChangeContext.Manual && e.Context != BlockChangeContext.Replaced)
            {
                return;
            }
            if (e.Result != CanPlaceResult.ZoneDenied)
            {
                return;
            }
            if (e.Player.Info.Rank != RankManager.LowestRank)
            {
                return;
            }
            if (e.NewBlock != Block.Air)
            {
                return;
            }

            Player   player = e.Player;
            TrapInfo ptrapinfo;

            if (trapinfo.ContainsKey(player))
            {
                ptrapinfo = trapinfo[player];
            }
            else
            {
                ptrapinfo = trapinfo[player] = new TrapInfo();
            }

            Zone deniedZone = player.World.Map.Zones.FindDenied(e.Coords, player);

            if (deniedZone == null)
            {
                return;
            }

            PlayerExceptions playerList = deniedZone.ExceptionList;
            bool             trapzone   = false;

            for (int i = 0; i < playerList.Included.Length; i++)
            {
                if (playerList.Included[i].Name == "trap")
                {
                    trapzone = true;
                    break;
                }
            }
            if (!trapzone)
            {
                return;
            }

            if (DateTime.UtcNow.Subtract(ptrapinfo.timer).TotalMinutes >= 5)
            {
                ptrapinfo.timer = DateTime.UtcNow;
                ptrapinfo.count = 0;
            }
            ptrapinfo.count++;
            if (ptrapinfo.count > 20)
            {
                player.Info.BanIP(Player.Console, "Griefing Detection (" + deniedZone.Name + ")", true, true);
            }

            e.Result = CanPlaceResult.PluginDeniedNoUpdate;
        }