static int CleanBanned(List <WorldRegion> list) { int removed = 0; foreach (WorldRegion w in list) { var rem = new List <string>(); foreach (string res in w.Residents) { var b = Banned.CheckBanned(res); if (b == null) { continue; } if ((b.BannedUntil - DateTime.Now).TotalDays < 30) { continue; } rem.Add(res); } removed += rem.Count; foreach (var r in rem) { w.Residents.Remove(r); } removed += CleanBanned(w.SubRegions); } return(removed); }
/// <summary> /// Special worlds where the entrance region matters /// such as banks and warpzones /// </summary> public void SetWorld(World w) { lock (sessionLock) { if (Phase == Phases.FinalClose) { w = World.Void; } WorldSession old = Session; Session = World.Void.Join(this); clientThread.State = "Void"; if (old != null) { old.Close("going to " + w); } WorldSession n; //Banned players BadPlayer b = Banned.CheckBanned(this); if (b == null) { n = w.Join(this); AfkSession afk = n as AfkSession; if (afk != null) { afk.OriginalWorld = old.World; } } else { n = World.HellBanned.Join(this); } //If we are denied if (n == null) { Session = World.Wait.Join(this); } else { Session = n; } clientThread.State = Session.ToString(); } }
public void FromClient(PacketFromClient packet) { if (packet.PacketID == PassThrough.ID) { Session.FromClient(packet); return; } //Ping update if (packet.PacketID == KeepAlivePong.ID) { var ka = packet as KeepAlivePong; lock (pings) { if (pings.ContainsKey(ka.KeepAliveID)) { Ping = (DateTime.Now - pings[ka.KeepAliveID]).TotalMilliseconds; pings.Remove(ka.KeepAliveID); } } } //Send possessed packets SendToPossessors(packet); //Check for invalid data, hacked clients(Derp) double pitch = 0; if (packet.PacketID == PlayerPositionLookClient.ID) { pitch = ((PlayerPositionLookClient)packet).Pitch; } if (pitch > 91 || pitch < -91) { //this.Ban (null, DateTime.Now.AddMinutes (42), "Modified client"); if (Banned.CheckBanned(MinecraftUsername) == null) { Chatting.Parser.TellAdmin(Permissions.Ban, Name + Chat.Gray + " crazy head angle " + pitch.ToString("0.0")); } SendToClient(new EntityStatus(EntityID, MineProxy.Data.EntityStatuses.EntityHurt)); } if (packet.PacketID == Packets.ClientSettings.ID) { var vd = (Packets.ClientSettings)packet; this.Locale = vd.Locale; this.ViewDistance = vd.ViewDistance; } //Check for book signatures if (packet.PacketID == MCBook.ID && packet is MCBook) { var b = packet as MCBook; if (b != null) { Log.WriteBook(this, b); Debug.WriteLine("Book: " + b); //Check for signatures RuleBook.Rules.Verify(this, b); } } WorldSession s = Session; try { switch (packet.PacketID) { case ChatMessageClient.ID: Parser.ParseClient(this, (ChatMessageClient)packet); //AfkTime = DateTime.Now; return; case TabCompleteClient.ID: Parser.ParseClient(this, (TabCompleteClient)packet); return; default: s.FromClient(packet); break; } } catch (SessionClosedException sc) { SessionClosed(s, sc); } catch (IOException sc) { SessionClosed(s, sc); } #if !DEBUG catch (Exception e) { Log.Write(e, this); SessionClosed(s, e); } #endif }
public static void LogoutPlayer(Client pp) { bool removed = false; lock (list) { removed = list.Contains(pp); list.Remove(pp); List = list.ToArray(); } if (removed) { QueueToAll(PlayerListItem.RemovePlayer(pp)); } //PlayerList.UpdateRefreshTabPlayers(); Log.WriteUsersLog(); if (removed && pp.MinecraftUsername != null && pp.Settings.Cloaked == null && Banned.CheckBanned(pp) == null && pp.MinecraftUsername != "Player") { Chatting.Parser.Say(Chat.Gray, pp.Name + " left the game"); } }
static void Welcome(Client player) { var header = new PlayerListHeaderFooter(); header.Header = new ChatJson(); header.Header.Translate = "%1$s\n%2$s"; header.Header.With = new List <ChatJson>() { new ChatJson() { Text = " ==== MCTraveler.eu ==== ", Color = "yellow", }, new ChatJson() { Text = " ======================= ", Color = "gray", }, }; header.Footer = new ChatJson() { Text = " ======================= ", Color = "gray", }; player.Queue.Queue(header); SendTabHeader(player); // if (player.ClientVersion < MinecraftServer.Version) // player.Tell(Chat.Purple, "You should upgrade to " + MinecraftServer.Version.ToString().Replace('_', '.')); /* * int count = 0; * foreach (Client p in PlayerList.List) * if (p.Cloaked == null && p.MinecraftUsername != "Player") * count ++; * if (count == 1) * player.Tell(Chat.Yellow, "Welcome, " + player.Name + " you are the first one here"); * else if (count == 2) * player.Tell(Chat.Yellow, "Welcome, " + player.Name + " there is one other player here"); * else * player.Tell(Chat.Yellow, "Welcome, " + player.Name + " there are " + (count - 1) + " other players here"); */ //Tell donor status //player.Tell(Donors.Status(player.MinecraftUsername)); string version = ""; if (player.ClientVersion < MinecraftServer.FrontendVersion) { version = Chat.Gray + "(" + player.ClientVersion.ToText() + ")"; } if (player.Settings.Cloaked == null && Banned.CheckBanned(player) == null && player.MinecraftUsername != "Player") { if (player.Uptime.TotalMinutes < 1) { Log.WritePlayer(player, "Login FirstTime"); Chatting.Parser.Say(Chat.Purple, "Welcome " + Chat.Yellow + player.Name + Chat.Purple + " from " + player.Country + version); } else { if (Donors.IsDonor(player)) { Chatting.Parser.Say(Chat.Gold, player.Name + " (donor!) joined from " + player.Country + version); } else { Chatting.Parser.Say(Chat.Yellow, player.Name + " joined from " + player.Country + version); } } //Report old bans to admin BadPlayer bp = Banned.GetBanHistory(player.MinecraftUsername); if (bp != null) { Chatting.Parser.TellAdmin("BanHistory: " + bp.BannedUntil.ToString("yyyy-MM-dd") + " " + bp.Reason); } } }