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();
                }
            }
        }
Ejemplo n.º 2
0
        static void HandleMap(Player p, string cmd, string value)
        {
            cmd = cmd.ToUpper();
            bool mapOnly = !(cmd == "ADD" || cmd.Length == 0);

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

            if (cmd == "ADD")
            {
                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
                {
                    Player.Message(p, "Accepted numbers are: 0, 1, 2, 3, 4 or 5");
                }
            }
            else if (cmd == "DELETE" || cmd == "REMOVE")
            {
                DeleteMap(p, value);
            }
            else if (cmd == "SAVE")
            {
                Command.all.FindByName("Save").Use(p, "");
                Player.Message(p, "Map has been saved.");
            }
            else if (cmd == "RESTORE")
            {
                Command.all.FindByName("Restore").Use(p, value);
            }
            else if (cmd == "RESIZE")
            {
                value = p.level.name + " " + value;
                string[] args = value.SplitSpaces();
                if (args.Length < 4)
                {
                    Command.all.FindByName("ResizeLvl").Help(p); return;
                }

                if (CmdResizeLvl.DoResize(p, args))
                {
                    return;
                }
                Player.Message(p, "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
                if (!p.level.VisitAccess.Whitelisted.CaselessContains(p.name))
                {
                    p.level.VisitAccess.Whitelist(null, p.name);
                }

                string rank = value.Length == 0 ? ServerConfig.DefaultRankName : value;
                Group  grp  = Matcher.FindRanks(p, rank);
                if (grp != null)
                {
                    p.level.VisitAccess.SetMin(null, grp);
                }
            }
            else if (cmd == "PERBUILD")
            {
                string rank = value.Length == 0 ? ServerConfig.DefaultRankName : value;
                Group  grp  = Matcher.FindRanks(p, rank);
                if (grp != null)
                {
                    p.level.BuildAccess.SetMin(null, grp);
                }
            }
            else if (cmd == "TEXTURE")
            {
                if (value.Length == 0)
                {
                    Command.all.FindByName("Texture").Use(p, "level normal");
                }
                else
                {
                    Command.all.FindByName("Texture").Use(p, "level " + value);
                }
            }
            else if (cmd == "TEXTUREZIP" || cmd == "TEXTUREPACK")
            {
                if (value.Length == 0)
                {
                    Command.all.FindByName("Texture").Use(p, "levelzip normal");
                }
                else
                {
                    Command.all.FindByName("Texture").Use(p, "levelzip " + value);
                }
            }
            else
            {
                cmd = LevelOptions.Map(cmd.ToLower());
                if (cmd == "physicspeed" || cmd == "overload" || cmd == "realmowner")
                {
                    Player.Message(p, "&cYou cannot change that map option via /os map."); return;
                }
                if (CmdMap.SetMapOption(p, p.level, cmd, value))
                {
                    return;
                }

                Player.MessageLines(p, mapHelp);
            }
        }