Esempio n. 1
0
        public static void Warp(ISender sender, ArgumentList args)
        {
            if (sender is Player)
            {
                string warpName = args.GetString(0);
                Player player   = sender as Player;

                Warp warp = WarpManager.GetWarp(warpName);

                if (warp == default(Warp) || !warp.IsUserAccessible(player))
                {
                    throw new CommandError("Warp not found!");
                }

                if (warp.Location == default(Vector2))
                {
                    throw new CommandError("Warp Location is invalid!");
                }

                if (!player.Teleport(warp.Location))
                {
                    throw new CommandError("There was an error in the Teleport.");
                }
            }
        }
Esempio n. 2
0
        public static void ListWarp(ISender sender, ArgumentList args)
        {
            if (WarpManager.WarpList.Count < 1)
            {
                throw new CommandError("There are no warps.");
            }

            int maxPages = WarpManager.WarpList.Count / 5;
            int page     = args.GetInt(0);

            if (maxPages > 0 && page > maxPages - 1 || page < 1)
            {
                throw new CommandError("Pages: 1 => {0}", maxPages);
            }

            page *= 5;

            if (page >= WarpManager.WarpList.Count)
            {
                page = WarpManager.WarpList.Count;
            }

            int start = page - 5;

            if (page < 4)
            {
                start = 0;
            }

            for (int i = start; i < page; i++)
            {
                Warp warp = WarpManager.WarpList.ToArray()[i];

                if (warp.IsUserAccessible(sender.Name) || !(sender is Player) || sender.Op) //!player's = OP ??
                {
                    sender.Message("Warp: {0}", warp.Name);
                }
                else
                {
                    sender.Message("<PRIVATE>");
                }
            }
        }