public static void Main(string[] args) { startTime = DateTime.Now; if (Process.GetProcessesByName("MCForge").Length != 1) { foreach (Process pr in Process.GetProcessesByName("MCForge")) { if (pr.MainModule.BaseAddress == Process.GetCurrentProcess().MainModule.BaseAddress) if (pr.Id != Process.GetCurrentProcess().Id) pr.Kill(); } } PidgeonLogger.Init(); AppDomain.CurrentDomain.UnhandledException += GlobalExHandler; Application.ThreadException += ThreadExHandler; bool skip = false; remake: try { if (!File.Exists("Viewmode.cfg") || skip) { StreamWriter SW = new StreamWriter(File.Create("Viewmode.cfg")); SW.WriteLine("#This file controls how the console window is shown to the server host"); SW.WriteLine("#cli: True or False (Determines whether a CLI interface is used) (Set True if on Mono)"); SW.WriteLine("#high-quality: True or false (Determines whether the GUI interface uses higher quality objects)"); SW.WriteLine(); SW.WriteLine("cli = false"); SW.WriteLine("high-quality = true"); SW.Flush(); SW.Close(); SW.Dispose(); } if (File.ReadAllText("Viewmode.cfg") == "") { skip = true; goto remake; } string[] foundView = File.ReadAllLines("Viewmode.cfg"); if (foundView[0][0] != '#') { skip = true; goto remake; } if (foundView[4].Split(' ')[2].ToLower() == "true") { Server s = new Server(); s.OnLog += WriteToConsole; s.OnCommand += WriteToConsole; s.OnSystem += WriteToConsole; s.Start(); Console.Title = Server.name + " - MCForge " + Server.Version; usingConsole = true; handleComm(); //Application.Run(); } else { IntPtr hConsole = GetConsoleWindow(); if (IntPtr.Zero != hConsole) { ShowWindow(hConsole, 0); } UpdateCheck(true); if (foundView[5].Split(' ')[2].ToLower() == "true") { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); } updateTimer.Elapsed += delegate { UpdateCheck(); }; updateTimer.Start(); Application.Run(new MCForge.Gui.Window()); } WriteToConsole("Completed in " + (DateTime.Now - startTime).Milliseconds + "ms"); } catch (Exception e) { Server.ErrorLog(e); } }
private void Window_Load(object sender, EventArgs e) { thisWindow = this; MaximizeBox = false; this.Text = "<server name here>"; //this.Icon = new Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MCLawl.Lawl.ico")); this.Show(); this.BringToFront(); WindowState = FormWindowState.Normal; s = new Server(); s.OnLog += WriteLine; s.OnCommand += newCommand; s.OnError += newError; s.OnSystem += newSystem; foreach (TabPage tP in tabControl1.TabPages) tabControl1.SelectTab(tP); tabControl1.SelectTab(tabControl1.TabPages[0]); s.HeartBeatFail += HeartBeatFail; s.OnURLChange += UpdateUrl; s.OnPlayerListChange += UpdateClientList; s.OnSettingsUpdate += SettingsUpdate; s.Start(); notifyIcon1.Text = ("MCForge Server: " + Server.name).Truncate(64); this.notifyIcon1.ContextMenuStrip = this.iconContext; this.notifyIcon1.Icon = this.Icon; this.notifyIcon1.Visible = true; this.notifyIcon1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseClick); //if (File.Exists(Logger.ErrorLogPath)) //txtErrors.Lines = File.ReadAllLines(Logger.ErrorLogPath); if (File.Exists("Changelog.txt")) { txtChangelog.Text = "Changelog for " + Server.Version + ":"; foreach (string line in File.ReadAllLines(("Changelog.txt"))) { txtChangelog.AppendText("\r\n " + line); } } // Bind player list dgvPlayers.DataSource = pc; dgvPlayers.Font = new Font("Calibri", 8.25f); dgvMaps.DataSource = new LevelCollection(new LevelListView()); dgvMaps.Font = new Font("Calibri", 8.25f); System.Timers.Timer UpdateListTimer = new System.Timers.Timer(10000); UpdateListTimer.Elapsed += delegate { UpdateClientList(Player.players); UpdateMapList("'"); }; UpdateListTimer.Start(); }
private void Window_Load(object sender, EventArgs e) { btnProperties.Enabled = false; thisWindow = this; MaximizeBox = false; this.Text = "Starting MCForge..."; //this.Icon = new Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MCLawl.Lawl.ico")); this.Show(); this.BringToFront(); WindowState = FormWindowState.Normal; new Thread(() => { s = new Server(); s.OnLog += WriteLine; s.OnCommand += newCommand; s.OnError += newError; s.OnSystem += newSystem; s.OnAdmin += WriteAdmin; s.OnOp += WriteOp; /*foreach (TabPage tP in tabControl1.TabPages) tabControl1.SelectTab(tP); tabControl1.SelectTab(tabControl1.TabPages[0]);*/ s.HeartBeatFail += HeartBeatFail; s.OnURLChange += UpdateUrl; s.OnPlayerListChange += UpdateClientList; s.OnSettingsUpdate += SettingsUpdate; s.Start(); //btnProperties.Enabled = true; if (btnProperties.InvokeRequired) { VoidDelegate d = btnPropertiesenable; Invoke(d); } else { btnProperties.Enabled = true; } }).Start(); notifyIcon1.Text = ("MCForge Server: " + Server.name).Truncate(64); this.notifyIcon1.ContextMenuStrip = this.iconContext; this.notifyIcon1.Icon = this.Icon; this.notifyIcon1.Visible = true; this.notifyIcon1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseClick); //if (File.Exists(Logger.ErrorLogPath)) //txtErrors.Lines = File.ReadAllLines(Logger.ErrorLogPath); if (File.Exists("Changelog.txt")) { txtChangelog.Text = "Changelog for " + Server.Version + ":"; foreach (string line in File.ReadAllLines(("Changelog.txt"))) { txtChangelog.AppendText("\r\n " + line); } } // Bind player list dgvPlayers.DataSource = pc; dgvPlayers.Font = new Font("Calibri", 8.25f); dgvMaps.DataSource = new LevelCollection(new LevelListView()); dgvMaps.Font = new Font("Calibri", 8.25f); dgvMapsTab.DataSource = new LevelCollection(new LevelListViewForTab()); dgvMapsTab.Font = new Font("Calibri", 8.25f); /*using (System.Timers.Timer UpdateListTimer = new System.Timers.Timer(10000)) { UpdateListTimer.Elapsed += delegate { UpdateClientList(Player.players); UpdateMapList("'"); Server.s.Log("Lists updated!"); }; UpdateListTimer.Start(); }*/ UpdateListTimer.Elapsed += delegate { try { UpdateClientList(Player.players); UpdateMapList("'"); } catch {} // needed for slower computers //Server.s.Log("Lists updated!"); }; UpdateListTimer.Start(); }
//public static Window thisWindow; private void Window_Load(object sender, EventArgs e) { btnProperties.Enabled = false; //thisWindow = this; MaximizeBox = false; this.Text = "Starting MCForge..."; //this.Icon = new Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MCLawl.Lawl.ico")); this.Show(); this.BringToFront(); WindowState = FormWindowState.Normal; new Thread(() => { s = new Server(); s.OnLog += WriteLine; s.OnCommand += newCommand; s.OnError += newError; s.OnSystem += newSystem; s.OnAdmin += WriteAdmin; s.OnOp += WriteOp; s.HeartBeatFail += HeartBeatFail; s.OnURLChange += UpdateUrl; s.OnPlayerListChange += UpdateClientList; s.OnSettingsUpdate += SettingsUpdate; s.Start(); Player.PlayerConnect += new Player.OnPlayerConnect(Player_PlayerConnect); Player.PlayerDisconnect += new Player.OnPlayerDisconnect(Player_PlayerDisconnect); Level.LevelLoaded += new Level.OnLevelLoaded(Level_LevelLoaded); Level.LevelUnload += new Level.OnLevelUnload(Level_LevelUnload); GlobalChatBot.OnNewRecieveGlobalMessage += new GlobalChatBot.RecieveChat(GlobalChatRecieve); GlobalChatBot.OnNewSayGlobalMessage += new GlobalChatBot.SendChat(GlobalChatSay); RunOnUiThread(delegate { btnProperties.Enabled = true; }); }).Start(); notifyIcon1.Text = ("MCForge Server: " + Server.name).Truncate(64); this.notifyIcon1.ContextMenuStrip = this.iconContext; this.notifyIcon1.Icon = this.Icon; this.notifyIcon1.Visible = true; this.notifyIcon1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseClick); if (File.Exists("Changelog.txt")) { txtChangelog.Text = "Changelog for " + Server.Version + ":"; foreach (string line in File.ReadAllLines(("Changelog.txt"))) { txtChangelog.AppendText("\r\n " + line); } } // Bind player list dgvPlayers.DataSource = pc; dgvPlayers.Font = new Font("Calibri", 8.25f); dgvMaps.DataSource = new LevelCollection(new LevelListView()); dgvMaps.Font = new Font("Calibri", 8.25f); dgvMapsTab.DataSource = new LevelCollection(new LevelListViewForTab()); dgvMapsTab.Font = new Font("Calibri", 8.25f); /*using (System.Timers.Timer UpdateListTimer = new System.Timers.Timer(10000)) { UpdateListTimer.Elapsed += delegate { UpdateClientList(Player.players); UpdateMapList("'"); Server.s.Log("Lists updated!"); }; UpdateListTimer.Start(); }*/ UpdateListTimer.Elapsed += delegate { try { UpdateClientList(Player.players); UpdateMapList(); } catch { } // needed for slower computers //Server.s.Log("Lists updated!"); }; UpdateListTimer.Start(); }