コード例 #1
0
        public override void Help(Player p, string message)
        {
            string opt = LevelOptions.Map(message.ToLower());

            foreach (var help in LevelOptions.Help)
            {
                if (!help.Key.CaselessEq(opt))
                {
                    continue;
                }
                Player.Message(p, "%T/map [level] {0}{1}", opt, Suffix(opt));
                Player.Message(p, "%H" + help.Value);
                return;
            }
            Player.Message(p, "Unrecognised option \"{0}\".", opt);
        }
コード例 #2
0
        internal static bool SetMapOption(Player p, Level lvl, string opt, string value)
        {
            opt = LevelOptions.Map(opt.ToLower());
            foreach (var option in LevelOptions.Options)
            {
                if (!option.Key.CaselessEq(opt))
                {
                    continue;
                }

                option.Value(p, lvl, value);
                Level.SaveSettings(lvl);
                return(true);
            }
            return(false);
        }
コード例 #3
0
        static bool IsMapOption(string[] args)
        {
            string opt = LevelOptions.Map(args[0].ToLower());

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

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

            return(args.Length == argsCount);
        }
コード例 #4
0
        static void HandleMap(Player p, string opt, string value)
        {
            bool mapOnly = !(opt == "ADD" || opt == "DELETE" || opt == "SAVE");

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

            if (opt == "ADD")
            {
                AddMap(p, value);
            }
            else if (opt == "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 (opt == "DELETE")
            {
                DeleteMap(p, value);
            }
            else if (opt == "SAVE")
            {
                byte mapNum = 0;
                if (value == "")
                {
                    Player.Message(p, "To save one of your maps type %T/os map save [map number]");
                }
                else if (value == "1")
                {
                    Command.all.Find("save").Use(p, FirstMapName(p));
                    Player.Message(p, "Map 1 has been saved.");
                }
                else if (byte.TryParse(value, out mapNum))
                {
                    Command.all.Find("save").Use(p, p.name.ToLower() + value);
                    Player.Message(p, "Map " + value + " has been saved.");
                }
                else
                {
                    Player.MessageLines(p, mapHelp);
                }
            }
            else if (opt == "RESTORE")
            {
                Command.all.Find("restore").Use(p, value);
            }
            else if (opt == "PERVISIT")
            {
                string rank = value == "" ? Server.defaultRank : value;
                Command.all.Find("pervisit").Use(p, rank);
            }
            else if (opt == "PERBUILD")
            {
                string rank = value == "" ? Server.defaultRank : value;
                Command.all.Find("perbuild").Use(p, rank);
            }
            else if (opt == "TEXTURE")
            {
                if (value == "")
                {
                    Command.all.Find("texture").Use(p, "level normal");
                }
                else
                {
                    Command.all.Find("texture").Use(p, "level " + value);
                }
            }
            else if (opt == "TEXTUREZIP")
            {
                if (value == "")
                {
                    Command.all.Find("texture").Use(p, "levelzip normal");
                }
                else
                {
                    Command.all.Find("texture").Use(p, "levelzip " + value);
                }
            }
            else
            {
                opt = LevelOptions.Map(opt.ToLower());
                if (opt == "physicspeed" || opt == "overload" || opt == "realmowner")
                {
                    Player.Message(p, "&cYou cannot change that map option via /os map."); return;
                }
                if (CmdMap.SetMapOption(p, p.level, opt, value))
                {
                    return;
                }

                Player.MessageLines(p, mapHelp);
            }
        }
コード例 #5
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);
            }
        }