Exemple #1
0
        protected override void ExecuteCommand(string[] a)
        {
            var instructions = File.ReadAllLines(pathArgument.Value);

            instructions = instructions.Where(_ => !string.IsNullOrEmpty(_.Trim())).ToArray();
            var index = 0;

            foreach (var instruction in instructions)
            {
                var args = instruction.Split(' ');

                var name = args[0];

                if (name == "exit")
                {
                    return;
                }

                if (!ConsoleCommandProcessor.Run(name, args))
                {
                    Console.WriteLine($"Instruction at line {index} corrupted ({name})");
                }
                index++;
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Log.SetLevel(Log.LogLevel.ConsoleInfo | Log.LogLevel.ConsoleDebug | Log.LogLevel.FileLog);

            NitroxServiceLocator.InitializeDependencyContainer(new ServerAutoFacRegistrar());
            NitroxServiceLocator.BeginNewLifetimeScope();

            configureCultureInfo();
            Server server;

            try
            {
                server = NitroxServiceLocator.LocateService <Server>();
                server.Start();
            }
            catch (Exception e)
            {
                Log.Error(e.ToString());
                return;
            }

            ConsoleCommandProcessor CmdProcessor = NitroxServiceLocator.LocateService <ConsoleCommandProcessor>();

            while (server.IsRunning)
            {
                CmdProcessor.ProcessCommand(Console.ReadLine());
            }
        }
Exemple #3
0
        private static void Main(string[] args)
        {
            Log.SetLevel(Log.LogLevel.Info | Log.LogLevel.Debug);

            NitroxServiceLocator.InitializeDependencyContainer(new ServerAutoFacRegistrar());
            NitroxServiceLocator.BeginNewLifetimeScope();

            ConfigureCultureInfo();
            Server server;

            try
            {
                server = NitroxServiceLocator.LocateService <Server>();
                server.Start();
            }
            catch (Exception e)
            {
                Log.Error(e.ToString());
                return;
            }

            CatchExitEvent();

            ConsoleCommandProcessor cmdProcessor = NitroxServiceLocator.LocateService <ConsoleCommandProcessor>();

            while (server.IsRunning)
            {
                cmdProcessor.ProcessCommand(Console.ReadLine(), Optional <Player> .Empty(), Perms.CONSOLE);
            }
        }
Exemple #4
0
        private static void Main(string[] args)
        {
            ConfigureCultureInfo();
            Log.Setup();

            ConfigureConsoleWindow();

            // Allow game path to be given as command argument
            if (args.Length > 0 && Directory.Exists(args[0]) && File.Exists(Path.Combine(args[0], "Subnautica.exe")))
            {
                string gameDir = Path.GetFullPath(args[0]);
                Log.Info($"Using game files from: {gameDir}");
                gameInstallDir = new Lazy <string>(() => gameDir);
            }
            else
            {
                gameInstallDir = new Lazy <string>(() =>
                {
                    string gameDir = GameInstallationFinder.Instance.FindGame();
                    Log.Info($"Using game files from: {gameDir}");
                    return(gameDir);
                });
            }

            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainOnAssemblyResolve;
            AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += CurrentDomainOnAssemblyResolve;

            NitroxModel.Helper.Map.Main = new SubnauticaMap();

            NitroxServiceLocator.InitializeDependencyContainer(new SubnauticaServerAutoFacRegistrar());
            NitroxServiceLocator.BeginNewLifetimeScope();

            Server server;

            try
            {
                server = NitroxServiceLocator.LocateService <Server>();
                Log.Info($"Loaded save\n{server.SaveSummary}");
                if (!server.Start())
                {
                    Log.Error("Unable to start server.");
                    Console.WriteLine("\nPress any key to continue..");
                    Console.ReadKey(true);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                return;
            }

            CatchExitEvent();

            ConsoleCommandProcessor cmdProcessor = NitroxServiceLocator.LocateService <ConsoleCommandProcessor>();

            while (server.IsRunning)
            {
                cmdProcessor.ProcessCommand(Console.ReadLine(), Optional.Empty, Perms.CONSOLE);
            }
        }
Exemple #5
0
        private static void Main(string[] args)
        {
            ConfigureConsoleWindow();
            ConfigureCultureInfo();

            NitroxModel.Helper.Map.Main = new SubnauticaMap();

            NitroxServiceLocator.InitializeDependencyContainer(new SubnauticaServerAutoFacRegistrar());
            NitroxServiceLocator.BeginNewLifetimeScope();

            Server server;

            try
            {
                server = NitroxServiceLocator.LocateService <Server>();
                server.Start();
            }
            catch (Exception e)
            {
                Log.Error(e.ToString());
                return;
            }

            CatchExitEvent();

            ConsoleCommandProcessor cmdProcessor = NitroxServiceLocator.LocateService <ConsoleCommandProcessor>();

            while (server.IsRunning)
            {
                cmdProcessor.ProcessCommand(Console.ReadLine(), Optional.Empty, Perms.CONSOLE);
            }
        }
Exemple #6
0
 protected override void ExecuteCommand(string[] args)
 {
     Console.WriteLine("Available commands : ");
     foreach (var commandName in ConsoleCommandProcessor.GetRegisteredCommands().OrderBy(_ => _))
     {
         Console.WriteLine(commandName);
     }
 }
Exemple #7
0
        public Server(ServerConfig config)
        {
            serverConfiguration = config;
            Instance            = this;
            worldPersistence    = new WorldPersistence();
            world         = worldPersistence.Load();
            packetHandler = new PacketHandler(world);
            udpServer     = new UdpServer(packetHandler, world.PlayerManager, world.EntitySimulation, serverConfiguration);
            ConsoleCommandProcessor.RegisterCommands();

            //Maybe add settings for the interval?
            saveTimer           = new Timer();
            saveTimer.Interval  = 60000;
            saveTimer.AutoReset = true;
            saveTimer.Elapsed  += delegate
            {
                Save();
            };
        }
Exemple #8
0
        static void Main(string[] args)
        {
            Log.SetLevel(Log.LogLevel.ConsoleInfo | Log.LogLevel.ConsoleDebug);

            try
            {
                ServerConfig config = new ServerConfig();
                Server       server = new Server(config);
                server.Start();
            }
            catch (Exception e)
            {
                Log.Error(e.ToString());
            }

            while (IsRunning)
            {
                ConsoleCommandProcessor.ProcessCommand(Console.ReadLine());
            }
        }
Exemple #9
0
        protected override void ExecuteCommand(string[] t)
        {
            Console.WriteLine("Macro mode enabled.\n Type \"save [path]\" to save your macro.\n Type \"exit\" to exit without saving changes.");
            var instructions = new List <string>();

            while (true)
            {
                Console.WriteLine("Please input instructions :");

                var line = Console.ReadLine();

                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }

                var args = line.Split(' ');

                var name = args[0];

                if (name == "exit")
                {
                    return;
                }

                if (name == "save")
                {
                    var path = args.Length == 2 ? args[1] : "instructions.txt";
                    SaveInstructions(instructions, path);
                    Console.WriteLine($"Saved to {path}");
                    return;
                }

                if (ConsoleCommandProcessor.Run(name, args))
                {
                    instructions.Add(line);
                }
            }
        }
Exemple #10
0
        private static void Main(string[] args)
        {
            ConfigureConsoleWindow();
            ConfigureCultureInfo();

            NitroxModel.Helper.Map.Main = new SubnauticaMap();

            NitroxServiceLocator.InitializeDependencyContainer(new SubnauticaServerAutoFacRegistrar());
            NitroxServiceLocator.BeginNewLifetimeScope();

            Server server;

            try
            {
                server = NitroxServiceLocator.LocateService <Server>();
                Log.Info($"Loaded save\n{server.SaveSummary}");
                if (!server.Start())
                {
                    Log.Error("Unable to start server.");
                    Console.WriteLine("\nPress any key to continue..");
                    Console.ReadKey(true);
                }
            }
            catch (Exception e)
            {
                Log.Error(e.ToString());
                return;
            }

            CatchExitEvent();

            ConsoleCommandProcessor cmdProcessor = NitroxServiceLocator.LocateService <ConsoleCommandProcessor>();

            while (server.IsRunning)
            {
                cmdProcessor.ProcessCommand(Console.ReadLine(), Optional.Empty, Perms.CONSOLE);
            }
        }
Exemple #11
0
 public ServerCommandProcessor(ConsoleCommandProcessor cmdProcessor)
 {
     this.cmdProcessor = cmdProcessor;
 }
Exemple #12
0
        private static async Task Main(string[] args)
        {
            // The thread that writers to console is paused while selecting text in console. So console writer needs to be async.
            Log.Setup(asyncConsoleWriter: true, isConsoleApp: true);
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;

            ConfigureCultureInfo();

            AppMutex.Hold(() =>
            {
                Log.Info("Waiting for 30 seconds on other Nitrox servers to initialize before starting..");
            }, 30000);
            Server server;

            try
            {
                // Allow game path to be given as command argument
                if (args.Length > 0 && Directory.Exists(args[0]) && File.Exists(Path.Combine(args[0], "Subnautica.exe")))
                {
                    string gameDir = Path.GetFullPath(args[0]);
                    Log.Info($"Using game files from: {gameDir}");
                    gameInstallDir = new Lazy <string>(() => gameDir);
                }
                else
                {
                    gameInstallDir = new Lazy <string>(() =>
                    {
                        string gameDir = GameInstallationFinder.Instance.FindGame();
                        Log.Info($"Using game files from: {gameDir}");
                        return(gameDir);
                    });
                }

                AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainOnAssemblyResolve;
                AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += CurrentDomainOnAssemblyResolve;

                Map.Main = new SubnauticaMap();

                NitroxServiceLocator.InitializeDependencyContainer(new SubnauticaServerAutoFacRegistrar());
                NitroxServiceLocator.BeginNewLifetimeScope();

                server = NitroxServiceLocator.LocateService <Server>();
                await WaitForAvailablePortAsync(server.Port);

                if (!server.Start())
                {
                    throw new Exception("Unable to start server.");
                }
                Log.Info("Server is waiting for players!");

                CatchExitEvent();
            }
            finally
            {
                // Allow other servers to start initializing.
                AppMutex.Release();
            }

            Log.Info("To get help for commands, run help in console or /help in chatbox");
            ConsoleCommandProcessor cmdProcessor = NitroxServiceLocator.LocateService <ConsoleCommandProcessor>();

            while (server.IsRunning)
            {
                cmdProcessor.ProcessCommand(Console.ReadLine(), Optional.Empty, Perms.CONSOLE);
            }
        }
 public ServerCommandProcessor(ConsoleCommandProcessor cmdProcessor, PlayerData playerData)
 {
     this.cmdProcessor = cmdProcessor;
     this.playerData   = playerData;
 }
        public override void Process(ServerCommand packet, Player player)
        {
            string msg = string.Join(" ", packet.CmdArgs);

            ConsoleCommandProcessor.ProcessCommand(msg);
        }