public static void Pardon(Client admin, string username) { BadPlayer pardoned = null; lock (blacklist) { foreach (BadPlayer b in blacklist.List) { if (b.Username.ToLowerInvariant() != username.ToLowerInvariant()) { continue; } //Remove history if (admin.Admin(Permissions.Ban) && b.BannedUntil < DateTime.Now) { blacklist.List.Remove(b); SaveBanned(); admin.TellSystem(Chat.Purple, "Ban record removed"); return; } pardoned = b; break; } } if (pardoned != null) { if (admin != null && admin.Admin(Permissions.Ban) == false && pardoned.BannedUntil > DateTime.Now.AddMinutes(30)) { admin.TellSystem(Chat.Purple, "Sorry players banned for longer periods of time cannot be pardoned"); return; } if (admin == null || admin.Settings.Cloaked != null) { PardonBad(pardoned, "Server"); } else { PardonBad(pardoned, admin.Name); } } else { if (admin != null) { admin.TellSystem(Chat.Red, username + " not found"); } } }
internal static BadPlayer CheckBanned(string unverifiedUsername) { BadPlayer b = GetBanHistory(unverifiedUsername); if (b == null) { return(null); } if (b.BannedUntil < DateTime.Now) { return(null); } return(b); }
public static void IPCorrelate(Client player, string username) { lock (ipUsername) { //Add if new ip if (ipUsername.ContainsKey(player.RemoteEndPoint.Address) == false) { ipUsername.Add(player.RemoteEndPoint.Address, new List <string>()); } List <string> usernames = ipUsername[player.RemoteEndPoint.Address]; //Add if new username if (usernames.Contains(username) == false) { usernames.Add(username); } //Dont report banned players if (player.MinecraftUsername == null) { return; } foreach (string u in usernames) { if (u == player.MinecraftUsername) { continue; } BadPlayer b = Banned.GetBanHistory(u); if (b == null) { Log.WritePlayer(player, "AKA " + u); Chatting.Parser.TellAdmin(Chat.Purple + player.MinecraftUsername + Chat.Aqua + " AKA " + Chat.Yellow + u); } else { Log.WritePlayer(player, "AKA " + b); if (b.BannedUntil < DateTime.Now) { Chatting.Parser.TellAdmin(Chat.Purple + player.MinecraftUsername + Chat.Aqua + " AKA " + Chat.DarkRed + u + Chat.White + " Expired: " + b.Reason); } else { Chatting.Parser.TellAdmin(Chat.Purple + player.MinecraftUsername + Chat.Aqua + " AKA " + Chat.Red + u + Chat.White + " " + b.Reason); } } } } }
static void PardonBad(BadPlayer bad, string who) { bad.BannedUntil = DateTime.Now; SaveBanned(); Client c = PlayerList.GetPlayerByName(bad.Username); if (c != null) { c.SetWorld(World.Main); } Log.WritePlayer(bad.Username, " pardoned by " + who); Chatting.Parser.Say(Chat.Purple, bad.Username + " unbanned by " + who); }
/// <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(); } }
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); } } }
public static void VotePardon(Client player, string username) { if (player.Uptime < TimeSpan.FromHours(8)) { player.TellSystem(Chat.Red, "You need 8 hours gametime befor you can vote."); return; } BadPlayer b = CheckBanned(username); if (b == null) { player.TellSystem(Chat.Red, "Player not banned: " + username); return; } //Block permanent bans if (b.BannedUntil > DateTime.Now.AddMinutes(30)) { player.TellSystem(Chat.Yellow, b.Username + " is banned by admin"); player.TellSystem(Chat.Yellow, "Contact " + MinecraftServer.AdminEmail + " to request unban."); return; } lock (b.UnbanVote) { if (b.UnbanVote.ContainsKey(player.MinecraftUsername)) { player.TellSystem(Chat.Yellow, "Already voted for unbanning " + b.Username); return; } b.UnbanVote.Add(player.MinecraftUsername, player); Chatting.Parser.Say(Chat.Purple, player.Name + " voted to unban " + b.Username); Log.WritePlayer(player, "Voted unban " + b.Username); //Check if enough votes int votesLeft = 3 - b.UnbanVote.Count; TimeSpan voteTimeLeft = TimeSpan.FromDays(3); foreach (Client v in b.UnbanVote.Values) { voteTimeLeft -= v.Uptime; } if (votesLeft <= 0 && voteTimeLeft.Ticks < 0) { //Unban string who = ""; foreach (var ben in b.UnbanVote.Values) { who += ben.Name + ","; } who = who.TrimEnd(',', ' '); PardonBad(b, "vote from " + who); return; } else { string m = b.Username + " need "; if (votesLeft > 0) { m += votesLeft + " votes"; } if (voteTimeLeft.Ticks > 0) { if (votesLeft > 0) { m += " and "; } m += voteTimeLeft.TotalHours.ToString("0,0") + " gametime votes"; } Chatting.Parser.Say(Chat.Purple, m); return; } } }
public static void Ban(Client admin, string username, DateTime bannedUntil, string reason) { if (admin != null && admin.Admin(Permissions.Ban) == false) { admin.TellSystem(Chat.Yellow, "Disabled"); return; } if (Donors.IsDonor(username) && bannedUntil < DateTime.Now.AddMinutes(35)) { Log.WritePlayer(username, "Donor not Banned: " + reason); if (admin != null) { admin.TellSystem(Chat.Gold, "Donor not banned for: " + reason); } return; } bool newban = false; BadPlayer b = GetBanHistory(username); if (b == null) { //Make sure we spelled correctly if (admin != null) { if (File.Exists("proxy/players/" + Path.GetFileName(username) + ".json") == false) { admin.TellSystem(Chat.Red, "No such player: " + username); return; } } newban = true; b = new BadPlayer(); b.Username = username; b.BannedUntil = bannedUntil; b.Reason = reason; lock (blacklist) blacklist.List.Add(b); } else { if (b.BannedUntil < DateTime.Now) { newban = true; } //Make sure longer bans are not removed by a shorter violation if (b.BannedUntil > bannedUntil) { return; } b.BannedUntil = bannedUntil; b.Reason = reason; } SaveBanned(); //Console.WriteLine ("Banning " + b.Username + " for " + b.Reason); double banMinutes = (b.BannedUntil - DateTime.Now).TotalMinutes; string banlength = "forever"; if (banMinutes < 24 * 60 * 30) { banlength = banMinutes.ToString("0") + " minutes"; } if (admin != null) { Log.WritePlayer(b.Username, "Banned " + banlength + " by " + admin.MinecraftUsername + ": " + reason); } else { Log.WritePlayer(b.Username, "Banned " + banlength + ": " + reason); } Client pp = PlayerList.GetPlayerByUsernameOrName(username); if (pp != null) { if (newban) { Chatting.Parser.Say(Chat.Purple, pp.Name + " is banned " + banlength + ": " + reason); } if (pp.Session is HellSession == false) { pp.SetWorld(World.HellBanned); } } else { admin.TellSystem(Chat.Purple, username + " was banned(offline): " + reason); } }
static void PardonBad(BadPlayer bad, string who) { bad.BannedUntil = DateTime.Now; SaveBanned(); Client c = PlayerList.GetPlayerByName(bad.Username); if (c != null) c.SetWorld(World.Main); Log.WritePlayer(bad.Username, " pardoned by " + who); Chatting.Parser.Say(Chat.Purple, bad.Username + " unbanned by " + who); }
public static void Ban(Client admin, string username, DateTime bannedUntil, string reason) { if (admin != null && admin.Admin() == false) { admin.TellSystem(Chat.Yellow, "Disabled"); return; } if (Donors.IsDonor(username) && bannedUntil < DateTime.Now.AddMinutes(35)) { Log.WritePlayer(username, "Donor not Banned: " + reason); if (admin != null) admin.TellSystem(Chat.Gold, "Donor not banned for: " + reason); return; } bool newban = false; BadPlayer b = GetBanHistory(username); if (b == null) { //Make sure we spelled correctly if (admin != null) { if (File.Exists("proxy/players/" + Path.GetFileName(username) + ".json") == false) { admin.TellSystem(Chat.Red, "No such player: " + username); return; } } newban = true; b = new BadPlayer(); b.Username = username; b.BannedUntil = bannedUntil; b.Reason = reason; lock (blacklist) blacklist.List.Add(b); } else { if (b.BannedUntil < DateTime.Now) newban = true; //Make sure longer bans are not removed by a shorter violation if (b.BannedUntil > bannedUntil) return; b.BannedUntil = bannedUntil; b.Reason = reason; } SaveBanned(); //Console.WriteLine ("Banning " + b.Username + " for " + b.Reason); double banMinutes = (b.BannedUntil - DateTime.Now).TotalMinutes; string banlength = "forever"; if (banMinutes < 24 * 60 * 30) banlength = banMinutes.ToString("0") + " minutes"; if (admin != null) Log.WritePlayer(b.Username, "Banned " + banlength + " by " + admin.MinecraftUsername + ": " + reason); else Log.WritePlayer(b.Username, "Banned " + banlength + ": " + reason); Client pp = PlayerList.GetPlayerByUsernameOrName(username); if (pp != null) { if (newban) Chatting.Parser.Say(Chat.Purple, pp.Name + " is banned " + banlength + ": " + reason); if (pp.Session is HellSession == false) pp.SetWorld(World.HellBanned); } else { admin.TellSystem(Chat.Purple, username + " was banned(offline): " + reason); } }