Пример #1
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] args = message.SplitSpaces();
            if (!Formatter.ValidFilename(p, args[0]))
            {
                return;
            }

            string    language = args.Length > 1 ? args[1] : "";
            ICompiler engine   = CompilerOperations.GetCompiler(p, language);

            if (engine == null)
            {
                return;
            }

            string path = engine.CommandPath(args[0]);

            if (File.Exists(path))
            {
                p.Message("File {0} already exists. Choose another name.", path); return;
            }

            string source = engine.GenExampleCommand(args[0]);

            File.WriteAllText(path, source);
            p.Message("Successfully saved example command &fCmd{0} &Sto {1}", args[0], path);
        }
Пример #2
0
        public override void Use(Player p, string message, CommandData data)
        {
            string[] args = message.SplitSpaces();
            bool     plugin = args[0].CaselessEq("plugin");
            string   name, lang;

            if (plugin)
            {
                // compile plugin [name] <language>
                name = args.Length > 1 ? args[1] : "";
                lang = args.Length > 2 ? args[2] : "";
            }
            else
            {
                // compile [name] <language>
                name = args[0];
                lang = args.Length > 1 ? args[1] : "";
            }

            if (name.Length == 0)
            {
                Help(p); return;
            }
            if (!Formatter.ValidFilename(p, name))
            {
                return;
            }

            ICompiler compiler = CompilerOperations.GetCompiler(p, lang);

            if (compiler == null)
            {
                return;
            }

            if (plugin)
            {
                CompilePlugin(p, name, compiler);
            }
            else
            {
                CompileCommand(p, name, compiler);
            }
        }