void ButtonStopClick(object sender, EventArgs e)
        {
            this.stateLock.EnterWriteLock();

            try
            {
                if (!this.isRunning)
                {
                    return;
                }

                Task.Run(() => {
                    //Screenshot.stopAutoScreenshot();
                    RCONLogic.stopLogic();
                    CSVWriter.stopWriter();

                    this.isRunning = false;
                    DebugWindow.writeLine(string.Format("Stop recording.\n"));
                });
            }
            catch
            {
            }
            finally
            {
                this.stateLock.ExitWriteLock();
            }
        }
        public MainForm(string destinationFolder, string metaInformation, string minecraftServer, string minecraftRCONPassword)
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            // Get the own version:
            var versionAttribute = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).FirstOrDefault() as AssemblyFileVersionAttribute;

            this.version = versionAttribute != null ? versionAttribute.Version : "0";

            // Write the title:
            this.Text = string.Format("[Mine]craft [Re]search [Obs]ervation v{0}: {1}", version, metaInformation);

            this.destinationFolder     = destinationFolder;
            this.metaInformation       = metaInformation;
            this.minecraftServer       = minecraftServer;
            this.minecraftRCONPassword = minecraftRCONPassword;

            Screenshot.setDestinationFolder(this.destinationFolder);
            Screenshot.setMetaInformation(this.metaInformation);
            CSVWriter.setMetaInfo(this.metaInformation);
            CSVWriter.setDestinationFolder(this.destinationFolder);
            RCONLogic.setMinecraftServer(this.minecraftServer);
            RCONLogic.setMinecraftRCONPassword(this.minecraftRCONPassword);

            new DebugWindow(string.Format("[Mine]craft [Re]search [Obs]ervation v{0}, Messages: {1}", version, metaInformation)).Show(this);

            // Redirect any outpout to the standard out also in the message i.e. debug window:
            Console.SetOut(new LineEventWriter(lineReceiver));
            DebugWindow.writeLine(string.Format("Init done: Ready.\n"));
        }
示例#3
0
        private static void checkActivePlayers()
        {
            try
            {
                var answer = RCONLogic.rconClient.sendMessage(RCONMessageType.Command, @"list");
                if (answer == string.Empty)
                {
                    return;
                }

                var start   = answer.IndexOf(':') + 1;
                var players = answer.Substring(start).Split(',');
                var now     = DateTime.UtcNow;

                // Call the plugins:
                PluginExecuteCommandsOnce4EachPlayer.executePlugin(RCONLogic.rconClient, players);
                PluginDistributedInventory.executePlugin(RCONLogic.rconClient, players);

                foreach (var player in players.Where(n => n != string.Empty))
                {
                    var name = player.RemoveColorCodes().Trim();

                    answer = RCONLogic.rconClient.sendMessage(RCONMessageType.Command, @"mc find " + name);
                    if (answer == string.Empty)
                    {
                        continue;
                    }

                    var posText    = answer.RemoveColorCodes();
                    var elements   = posText.Split(' ');
                    var x          = int.Parse(elements[5]);
                    var y          = int.Parse(elements[7]);
                    var z          = int.Parse(elements[9]);
                    var lineResult = string.Format("{4:yyyyMMddHHmmssfff};{0};{1};{2};{3}\n", name, x, y, z, now);

                    CSVWriter.writeLine(lineResult);
                }
            }
            catch (Exception e)
            {
                DebugWindow.writeLine(string.Format("Exception: {0}\n", e.Message));
                DebugWindow.writeLine(string.Format("Exception: {0}\n", e.StackTrace));
            }
        }
        void ButtonStartClick(object sender, EventArgs e)
        {
            this.stateLock.EnterWriteLock();

            try
            {
                if (this.isRunning)
                {
                    return;
                }

                this.isRunning        = true;
                this.buttonState.Text = "State: Running";

                DebugWindow.writeLine(string.Format("Start recording.\n"));

                //Screenshot.startAutoScreenshot(8);
                CSVWriter.startWriter();
                RCONLogic.startLogic();
                Task.Factory.StartNew(() =>
                {
                    while (this.isRunning)
                    {
                        animation();
                        Thread.Sleep(500);
                    }

                    resetAnimation();
                }, TaskCreationOptions.LongRunning);
            }
            catch
            {
            }
            finally
            {
                this.stateLock.ExitWriteLock();
            }
        }