Exemple #1
0
        protected void UseCore(Player p, string message, CommandData data,
                               WarpList warps, string group)
        {
            string[] args = message.SplitSpaces();
            string   cmd  = args[0];

            if (cmd.Length == 0)
            {
                Help(p); return;
            }
            bool checkExtraPerms = warps == WarpList.Global;

            if (IsListCommand(cmd))
            {
                string modifier = args.Length > 1 ? args[1] : "";
                MultiPageOutput.Output(p, warps.Items, FormatWarp, group + " list", group + "s", modifier, true);
                return;
            }
            else if (args.Length == 1)
            {
                Warp warp = Matcher.FindWarps(p, warps, cmd);
                if (warp != null)
                {
                    warps.Goto(warp, p);
                }
                return;
            }

            string name = args[1];

            if (IsCreateCommand(cmd))
            {
                if (checkExtraPerms && !CheckExtraPerm(p, data, 1))
                {
                    return;
                }
                if (warps.Exists(name))
                {
                    p.Message("{0} already exists", group); return;
                }

                warps.Create(name, p);
                p.Message("{0} {1} created.", group, name);
            }
            else if (IsDeleteCommand(cmd))
            {
                if (checkExtraPerms && !CheckExtraPerm(p, data, 1))
                {
                    return;
                }
                Warp warp = Matcher.FindWarps(p, warps, name);
                if (warp == null)
                {
                    return;
                }

                warps.Remove(warp, p);
                p.Message("{0} {1} deleted.", group, warp.Name);
            }
            else if (IsEditCommand(cmd))
            {
                if (checkExtraPerms && !CheckExtraPerm(p, data, 1))
                {
                    return;
                }
                Warp warp = Matcher.FindWarps(p, warps, name);
                if (warp == null)
                {
                    return;
                }

                warps.Update(warp, p);
                p.Message("{0} {1} moved.", group, warp.Name);
            }
            else if (cmd.CaselessEq("goto"))
            {
                Warp warp = Matcher.FindWarps(p, warps, name);
                if (warp != null)
                {
                    warps.Goto(warp, p);
                }
            }
            else
            {
                Help(p);
            }
        }
Exemple #2
0
        protected void UseCore(Player p, string message, WarpList warps,
                               string group, bool checkExtraPerms)
        {
            string[] args = message.SplitSpaces();
            string   cmd  = args[0];

            if (cmd.Length == 0)
            {
                Help(p); return;
            }

            if (cmd.CaselessEq("list"))
            {
                string modifier = args.Length > 1 ? args[1] : "";
                MultiPageOutput.Output(p, warps.Items, FormatWarp, group + " list", group + "s", modifier, true);
                return;
            }
            else if (args.Length == 1)
            {
                Warp warp = Matcher.FindWarps(p, warps, cmd);
                if (warp != null)
                {
                    warps.Goto(warp, p);
                }
                return;
            }

            string name = args[1];

            if (cmd.CaselessEq("create") || cmd.CaselessEq("add"))
            {
                if (checkExtraPerms && !CheckExtraPerm(p, 1))
                {
                    return;
                }
                if (warps.Exists(name))
                {
                    Player.Message(p, "{0} already exists", group); return;
                }

                warps.Create(name, p);
                Player.Message(p, "{0} {1} created.", group, name);
            }
            else if (cmd.CaselessEq("delete") || cmd.CaselessEq("remove"))
            {
                if (checkExtraPerms && !CheckExtraPerm(p, 2))
                {
                    return;
                }
                Warp warp = Matcher.FindWarps(p, warps, name);
                if (warp == null)
                {
                    return;
                }

                warps.Remove(warp, p);
                Player.Message(p, "{0} {1} deleted.", group, warp.Name);
            }
            else if (cmd.CaselessEq("move") || cmd.CaselessEq("update"))
            {
                if (checkExtraPerms && !CheckExtraPerm(p, 3))
                {
                    return;
                }
                Warp warp = Matcher.FindWarps(p, warps, name);
                if (warp == null)
                {
                    return;
                }

                warps.Update(warp, p);
                Player.Message(p, "{0} {1} moved.", group, warp.Name);
            }
            else if (cmd.CaselessEq("goto"))
            {
                Warp warp = Matcher.FindWarps(p, warps, name);
                if (warp != null)
                {
                    warps.Goto(warp, p);
                }
            }
            else
            {
                Help(p);
            }
        }
Exemple #3
0
        public override void Use(Player p, string message)
        {
            if (Player.IsSuper(p))
            {
                MessageInGameOnly(p); return;
            }
            WarpList warps = WarpList.Global;

            string[] args = message.ToLower().Split(' ');
            string   cmd  = args[0];

            if (cmd == "")
            {
                Help(p); return;
            }

            if (args.Length == 1 && (cmd == "list" || cmd == "view"))
            {
                Player.Message(p, "Warps:");
                foreach (Warp wr in warps.Items)
                {
                    if (LevelInfo.FindExact(wr.lvlname) != null)
                    {
                        Player.Message(p, wr.name + " : " + wr.lvlname);
                    }
                }
                return;
            }
            else if (args.Length == 1)
            {
                if (!warps.Exists(cmd))
                {
                    Player.Message(p, "That warp does not exist");
                }
                warps.Goto(cmd, p);
                return;
            }

            string name = args[1];

            if (cmd == "create" || cmd == "add")
            {
                if (!CheckExtraPerm(p, 1))
                {
                    MessageNeedExtra(p, "create warps.", 1); return;
                }
                if (warps.Exists(name))
                {
                    Player.Message(p, "That warp already exists"); return;
                }
                Player who = args.Length == 2 ? p : PlayerInfo.FindMatches(p, args[2]);
                if (who == null)
                {
                    return;
                }

                warps.Create(name, who);
                Player.Message(p, "Warp created.");
            }
            else if (cmd == "delete" || cmd == "remove")
            {
                if (!CheckExtraPerm(p, 2))
                {
                    MessageNeedExtra(p, "delete warps.", 2); return;
                }
                if (!warps.Exists(name))
                {
                    Player.Message(p, "That warp does not exist"); return;
                }

                warps.Remove(name, p);
                Player.Message(p, "Warp deleted.");
            }
            else if (cmd == "move" || cmd == "change" || cmd == "edit")
            {
                if (!CheckExtraPerm(p, 3))
                {
                    MessageNeedExtra(p, "move warps.", 3); return;
                }
                if (!warps.Exists(name))
                {
                    Player.Message(p, "Warp doesn't exist!!"); return;
                }
                Player who = args.Length == 2 ? p : PlayerInfo.FindMatches(p, args[2]);
                if (who == null)
                {
                    return;
                }

                warps.Update(name, who);
                Player.Message(p, "Warp moved.");
            }
            else
            {
                Help(p);
            }
        }