Exemplo n.º 1
0
        public override void Help(Player p, string message)
        {
            if (message.CaselessEq("options"))
            {
                p.Message("%HOptions: &f{0}", LevelOptions.Options.Join(o => o.Name));
                p.Message("%HUse %T/Help map [option] %Hto see description for that option");
                return;
            }

            LevelOption opt = LevelOptions.Find(message);

            if (opt == null)
            {
                p.Message("Unrecognised option \"{0}\".", message); return;
            }

            bool   isMotd = opt.Name == LevelOptions.MOTD;
            string suffix = isMotd ? " <value>" : (HasArgument(opt.Name) ? " [value]" : "");

            p.Message("%T/Map [level] {0}{1}", opt.Name, suffix);
            p.Message("%H" + opt.Help);
            if (isMotd)
            {
                ShowMotdRules(p);
            }
        }
Exemplo n.º 2
0
        static bool IsMapOption(string[] args)
        {
            LevelOption opt = LevelOptions.Find(args[0]);

            if (opt == null)
            {
                return(false);
            }
            // In rare case someone uses /map motd motd My MOTD
            if (opt.Name == LevelOptions.MOTD && (args.Length == 1 || !args[1].CaselessStarts("motd ")))
            {
                return(true);
            }

            int argsCount = HasArgument(opt.Name) ? 2 : 1;

            return(args.Length == argsCount);
        }
Exemplo n.º 3
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (CheckSuper(p, message, "level name"))
            {
                return;
            }
            if (message.Length == 0)
            {
                message = p.level.name;
            }
            string[] args = message.SplitSpaces(3);
            Level    lvl = null;
            string   optName = null, value = null;

            if (IsMapOption(args))
            {
                if (p.IsSuper)
                {
                    SuperRequiresArgs(p, "level name"); return;
                }
                lvl = p.level;

                optName = args[0];
                args    = message.SplitSpaces(2);
                value   = args.Length > 1 ? args[1] : "";
            }
            else if (args.Length == 1)
            {
                string map = Matcher.FindMaps(p, args[0]);
                if (map == null)
                {
                    return;
                }

                PrintMapInfo(p, LevelInfo.GetConfig(map, out lvl));
                return;
            }
            else
            {
                lvl = Matcher.FindLevels(p, args[0]);
                if (lvl == null)
                {
                    return;
                }

                optName = args[1];
                value   = args.Length > 2 ? args[2] : "";
            }

            if (!CheckExtraPerm(p, data, 1))
            {
                return;
            }
            if (optName.CaselessEq(LevelOptions.RealmOwner) && !CheckExtraPerm(p, data, 2))
            {
                return;
            }
            if (!LevelInfo.Check(p, data.Rank, lvl, "change map settings of this level"))
            {
                return;
            }

            LevelOption opt = LevelOptions.Find(optName);

            if (opt == null)
            {
                p.Message("Could not find option entered.");
            }
            else
            {
                opt.SetFunc(p, lvl, value);
                lvl.SaveSettings();
            }
        }
        static void HandleMap(Player p, string cmd, string value)
        {
            cmd = cmd.ToUpper();
            bool mapOnly = !(cmd.Length == 0 || IsCreateCommand(cmd));

            if (mapOnly && !LevelInfo.IsRealmOwner(p.level, p.name))
            {
                p.Message("You may only perform that action on your own map."); return;
            }

            if (IsCreateCommand(cmd))
            {
                AddMap(p, value);
            }
            else if (cmd == "PHYSICS")
            {
                if (value == "0" || value == "1" || value == "2" || value == "3" || value == "4" || value == "5")
                {
                    CmdPhysics.SetPhysics(p.level, int.Parse(value));
                }
                else
                {
                    p.Message("Accepted numbers are: 0, 1, 2, 3, 4 or 5");
                }
            }
            else if (IsDeleteCommand(cmd))
            {
                DeleteMap(p, value);
            }
            else if (cmd == "SAVE")
            {
                UseCommand(p, "Save", "");
            }
            else if (cmd == "RESTORE")
            {
                UseCommand(p, "Restore", value);
            }
            else if (cmd == "RESIZE")
            {
                value = p.level.name + " " + value;
                string[] args = value.SplitSpaces();
                if (args.Length < 4)
                {
                    Command.Find("ResizeLvl").Help(p); return;
                }

                bool needConfirm;
                if (CmdResizeLvl.DoResize(p, args, p.DefaultCmdData, out needConfirm))
                {
                    return;
                }

                if (!needConfirm)
                {
                    return;
                }
                p.Message("Type &T/os map resize {0} {1} {2} confirm &Sif you're sure.",
                          args[1], args[2], args[3]);
            }
            else if (cmd == "PERVISIT")
            {
                // Older realm maps didn't put you on visit whitelist, so make sure we put the owner here
                AccessController access = p.level.VisitAccess;
                if (!access.Whitelisted.CaselessContains(p.name))
                {
                    access.Whitelist(Player.Console, LevelPermission.Console, p.level, p.name);
                }

                if (value.Length > 0)
                {
                    value = p.level.name + " " + value;
                }
                UseCommand(p, "PerVisit", value);
            }
            else if (cmd == "PERBUILD")
            {
                if (value.Length > 0)
                {
                    value = p.level.name + " " + value;
                }
                UseCommand(p, "PerBuild", value);
            }
            else if (cmd == "TEXTURE" || cmd == "TEXTUREZIP" || cmd == "TEXTUREPACK")
            {
                if (value.Length == 0)
                {
                    value = "normal";
                }
                UseCommand(p, "Texture", "levelzip " + value);
            }
            else
            {
                LevelOption opt = LevelOptions.Find(cmd);
                if (opt == null)
                {
                    p.MessageLines(mapHelp);
                }
                else if (DisallowedMapOption(opt.Name))
                {
                    p.Message("&WYou cannot change that map option via /os map."); return;
                }
                else
                {
                    opt.SetFunc(p, p.level, value);
                    p.level.SaveSettings();
                }
            }
        }