public void StartBackend() { stopBackend.Change(-1, -1); if (Suspended) { return; } BackendManager.StartServer(ServerName); }
public sealed override WorldSession Join(Client player) { //reset scoreboard player.Score = null; if (Suspended) { player.TellSystem(Chat.Purple, "Vanilla is suspended by admin, it will be right back"); return(null); } StartBackend(); lock (players) { int pc = 0; foreach (VanillaSession r in players) { if (r.Player.Settings.Cloaked == null) { pc++; } } if (pc >= MinecraftServer.MaxSlots && player.Settings.Cloaked == null) { //Kick old player //New visitors are given an advantage if (player.Uptime.TotalMinutes < 15) { //Kick normal player foreach (VanillaSession r in players) { if (r.Player.Settings.Cloaked != null) { continue; } if (Donors.IsDonor(r.Player)) { continue; } if (r.Player.Uptime.TotalMinutes < 15) { continue; } KickSlot(r.Player); World.Main.Say(Chat.Gray, r.Player.Name + " left its slot to " + player.Name + "(new)"); goto slotFree; } } if (Donors.IsDonor(player.MinecraftUsername)) { //Kick any non donor foreach (VanillaSession r in players) { if (r.Player.Settings.Cloaked != null) { continue; } if (Donors.IsDonor(r.Player)) { continue; } if (r.Player.Uptime.TotalMinutes < 15) { continue; } KickSlot(r.Player); this.Say(Chat.Gray, r.Player.Name + " left its slot to donor " + player.Name); goto slotFree; } foreach (VanillaSession r in players) { if (r.Player.Settings.Cloaked != null) { continue; } if (Donors.IsDonor(r.Player)) { continue; } KickSlot(r.Player); this.Say(Chat.Gray, r.Player.Name + " left its slot to donor " + player.Name); goto slotFree; } goto slotFree; } //Block Chat.ReadFile("full.txt", Chat.Aqua, player); this.Say(Chat.DarkGreen, "No free slot for " + player.Name); return(null); } slotFree: var server = BackendManager.StartServer(ServerName); if (server.Running.WaitOne(10) == false) { Log.WriteServer("Timeout waiting for server to start"); } VanillaSession s = CreateSession(player); players.Add(s); base.Join(s); #if DEBUG Console.WriteLine(s.Player.MinecraftUsername + " Joining Real: " + Players.Length); #endif return(s); } }