static void TellMode(Client player) { if (player.Settings.Cloaked != null) { player.TellSystem(Chat.Purple, "You are a " + Chat.DarkAqua + player.Settings.Cloaked); } else { player.TellSystem(Chat.Purple, "You are yourself"); } }
public static void TellChannel(Client player) { if (player.ChatChannel == null) { player.TellSystem(Chat.Green, "You are talking to everyone"); } else { player.TellSystem(Chat.Green, "You are talking in the \"" + Chat.DarkGreen + player.ChatChannel + Chat.Green + "\" channel"); player.TellSystem(Chat.Green, "Reset using /reset"); } }
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"); } } }
/// <summary> /// Read inbox messages to player /// </summary> public static void Read(Client player, string[] cmd, int iarg) { string name = PrepareName(player.MinecraftUsername); if (name == null) { player.TellSystem(Chat.Red, "Invalid name: " + player.MinecraftUsername); return; } string path = Path.Combine(dir, name); string[] messages; lock (locking) { if (File.Exists(path) == false) messages = new string[0]; else { messages = File.ReadAllLines(path); File.Delete(path); } } if (messages.Length == 0) player.TellSystem(Chat.Purple, "Inbox: no new messages"); foreach (string line in messages) { string[] parts = line.Split(new char[]{'\t'}, 3); if (parts.Length != 3) player.TellSystem(Chat.Purple, line); else { DateTime timestamp; DateTime.TryParse(parts [0], out timestamp); TimeSpan ago = DateTime.Now - timestamp; string agoString; if (ago.TotalHours < 1) agoString = ago.TotalMinutes.ToString("0") + " minutes"; else if (ago.TotalDays < 1) agoString = ago.TotalHours.ToString("0") + " hours"; else agoString = ago.TotalDays.ToString("0") + " days"; player.TellSystem(Chat.Yellow, "From " + parts [1] + " " + agoString + " ago"); player.TellSystem(Chat.White + "> ", parts [2]); } } Status(player); }
internal void AddPlayer(Client player, string newResident) { RegionList regions = player.Session.World.Regions; if (IsResident(player) == false) { player.TellSystem(Chat.Yellow, " You are not a resident of this region"); if (player.Admin() == false) { return; } } AddPlayer(player.MinecraftUsername, newResident, regions); player.TellSystem(Chat.Aqua, newResident + " added to " + Name); }
public static bool ReadFile(string path, string prefix, Client player) { path = Path.Combine("chat", path); if (File.Exists(path) == false) { if (path.Contains(" ") == false) { Log.WriteServer("File not found: " + path); } return(false); } using (TextReader reader = new StreamReader(path)) { while (true) { string line = reader.ReadLine(); if (line == null) { break; } if (line.StartsWith("\t")) { prefix = line.Substring(1); continue; } player.TellSystem(prefix, line); } } return(true); }
/// <summary> /// Change the region protection type /// </summary> public void SetType(Client player, string type) { if (ResidentPermissions(player) == false) { player.TellSystem(Chat.Yellow, " You are not a resident of this region"); return; } type = type.ToLowerInvariant().Trim(); switch (type) { case "": //public case PublicType.Type: case Protected.Type: case Adventure.Type: case SpawnRegion.Type: break; //OK default: if (player.Admin() == false) { player.TellSystem(Chat.Red, "Unknown type: " + type); player.TellSystem(Chat.Yellow, "Choose one of: public, protected, adventure, night"); return; } else { player.TellSystem(Chat.Yellow, "Custom type: " + type); } break; } Type = type; player.TellSystem(Chat.Aqua, "Region type is now: " + type); RegionLoader.Save(player.Session.World.Regions); //Update all players foreach (Client c in PlayerList.List) { if (c.Session.CurrentRegion == this) { RegionCrossing.SetRegion(c.Session); } } }
public static void TellStatTo(Client about, ClientSettings settings, Client toPlayer) { string name = "Offline"; TimeSpan uptime = settings.Uptime; if (about != null) { uptime = about.Uptime; name = about.Name; if (about.Country != null) toPlayer.TellSystem(Chat.Yellow + name + " ", "From: " + about.Country); } if (settings.FirstOnline.Ticks > 0) toPlayer.TellSystem(Chat.Yellow + name + " ", "First login: "******"0") + Chat.Blue + " days ago"); if (uptime.TotalDays > 1) toPlayer.TellSystem(Chat.Yellow + name + " ", "Online: " + uptime.TotalDays.ToString("0.0") + Chat.Blue + " days"); else toPlayer.TellSystem(Chat.Yellow + name + " ", "Online: " + uptime.TotalHours.ToString("0.0") + Chat.Blue + " hours"); toPlayer.TellSystem(Chat.Yellow + name + " ", "Walked " + settings.WalkDistance.ToString("0") + Chat.Blue + " blocks"); toPlayer.TellSystem(Chat.Yellow + name + " ", "Last Online: " + (DateTime.Now - settings.LastOnline).TotalHours.ToString("0.0") + " hours ago"); }
public static void TellStatTo(Client about, ClientSettings settings, Client toPlayer) { string name = "Offline"; TimeSpan uptime = settings.Uptime; if (about != null) { uptime = about.Uptime; name = about.Name; if (about.Country != null) { toPlayer.TellSystem(Chat.Yellow + name + " ", "From: " + about.Country); } } if (settings.FirstOnline.Ticks > 0) { toPlayer.TellSystem(Chat.Yellow + name + " ", "First login: "******"0") + Chat.Blue + " days ago"); } if (uptime.TotalDays > 1) { toPlayer.TellSystem(Chat.Yellow + name + " ", "Online: " + uptime.TotalDays.ToString("0.0") + Chat.Blue + " days"); } else { toPlayer.TellSystem(Chat.Yellow + name + " ", "Online: " + uptime.TotalHours.ToString("0.0") + Chat.Blue + " hours"); } toPlayer.TellSystem(Chat.Yellow + name + " ", "Walked " + settings.WalkDistance.ToString("0") + Chat.Blue + " blocks"); toPlayer.TellSystem(Chat.Yellow + name + " ", "Last Online: " + (DateTime.Now - settings.LastOnline).TotalHours.ToString("0.0") + " hours ago"); }
internal void AddPlayer(string residentPlayer, string newResident, RegionList region) { Residents.Add(newResident); RegionLoader.Save(region); Log.WritePlayer(residentPlayer, "Region added resident " + newResident); Client nr = PlayerList.GetPlayerByName(newResident); if (nr != null) { nr.TellSystem(Chat.Aqua, residentPlayer + " added you to " + Name); RegionCrossing.SetRegion(nr.Session); } }
public static void SetCloak(Client player, string type) { if (type == null) { player.Settings.Cloaked = null; } else { try { MobType mt = (MobType)Enum.Parse(typeof(MobType), type); player.Settings.Cloaked = mt.ToString(); cloakBack.Remove(player.MinecraftUsername); cloakBack.Add(player.MinecraftUsername, player.Session.Position); } catch (Exception) { player.TellSystem(Chat.DarkRed, "Unknown mob: " + type); } } player.SaveProxyPlayer(); VanillaSession rs = player.Session as VanillaSession; if (rs != null) { if (player.Settings.Cloaked == null) { SpawnPlayer spawnNamedEntity = new SpawnPlayer(rs.EID, player); spawnNamedEntity.Position = rs.Position; spawnNamedEntity.Pitch = rs.Pitch; spawnNamedEntity.Yaw = rs.Yaw; PlayerList.QueueToAll(spawnNamedEntity); player.Queue.Queue(new DestroyEntities(rs.EID)); player.Session.World.Send("gamemode 0 " + player.MinecraftUsername); } else { PlayerList.QueueToAll(new DestroyEntities(rs.EID)); player.Session.World.Send("gamemode 1 " + player.MinecraftUsername); } } TellMode(player); PlayerList.UpdateTabPlayers(); }
internal void TellResidentsSystem(Client player, string prefix, string message) { foreach (string username in Residents.ToArray()) { if (player != null && username.ToLowerInvariant() == player.MinecraftUsername.ToLowerInvariant()) { continue; } Client p = PlayerList.GetPlayerByUsername(username); if (p != null) { p.TellSystem(prefix, message); } } }
internal void RemovePlayer(Client player, string removeUsername) { RegionList regions = player.Session.World.Regions; if (ResidentPermissions(player) == false) { Log.WritePlayer(player, "Failed to remove " + removeUsername + " from region " + Name); player.TellSystem(Chat.Yellow, " You are not a resident of this region"); return; } removeUsername = removeUsername.ToLowerInvariant(); foreach (string s in Residents) { if (s.ToLowerInvariant() == removeUsername) { removeUsername = s; break; } } if (Residents.Remove(removeUsername) == false) { player.TellSystem(Chat.Red, removeUsername + " not found in region " + Name); return; } Log.WritePlayer(player, "Region: removed resident " + removeUsername); RegionLoader.Save(regions); player.TellSystem(Chat.Aqua, removeUsername + " removed from " + Name); Client p = PlayerList.GetPlayerByName(removeUsername); if (p != null && p != player) { p.TellSystem(Chat.Aqua, player.Name + " removed you from " + Name); } }
internal void Rename(Client player, string name) { RegionList region = player.Session.World.Regions; if (ResidentPermissions(player) == false) { player.TellSystem(Chat.Yellow, " You are not a resident of this region"); return; } Log.WritePlayer(player, "Region renamed " + Name + " to " + name); TellResidentsSystem(null, Chat.Blue, player.Name + " renamed " + Name + " to " + name); Name = name; RegionLoader.Save(region); Entering(player); }
public static void SetCloak(Client player, string type) { if (type == null) player.Settings.Cloaked = null; else { try { MobType mt = (MobType)Enum.Parse(typeof(MobType), type); player.Settings.Cloaked = mt.ToString(); cloakBack.Remove(player.MinecraftUsername); cloakBack.Add(player.MinecraftUsername, player.Session.Position); } catch (Exception) { player.TellSystem(Chat.DarkRed, "Unknown mob: " + type); } } player.SaveProxyPlayer(); VanillaSession rs = player.Session as VanillaSession; if (rs != null) { if (player.Settings.Cloaked == null) { SpawnPlayer spawnNamedEntity = new SpawnPlayer(rs.EID, player); spawnNamedEntity.Position = rs.Position; spawnNamedEntity.Pitch = rs.Pitch; spawnNamedEntity.Yaw = rs.Yaw; rs.World.SendToAllBut(spawnNamedEntity, player.Session); rs.Vanilla.Send("gamemode 0 " + player.MinecraftUsername); } else { PlayerList.QueueToAll(new DestroyEntities(rs.EID)); rs.Vanilla.Send("gamemode 1 " + player.MinecraftUsername); } } TellMode(player); PlayerList.UpdateTabPlayers(); }
/// <summary> /// Write message to player /// </summary> public static void Write(Client fromPlayer, string toPlayer, string message) { string name = PrepareName(toPlayer); if (name == null) { fromPlayer.TellSystem(Chat.Red, "Invalid name: " + toPlayer); return; } string path = Path.Combine(dir, name); string line = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\t" + fromPlayer.Name + "\t" + message + "\n"; lock (locking) { File.AppendAllText(path, line); } }
/// <summary> /// Report inbox status to player /// </summary> public static void Status(Client player) { string name = PrepareName(player.MinecraftUsername); if (name == null) { player.TellSystem(Chat.Red, "Invalid name: " + player.MinecraftUsername); return; } string path = Path.Combine(dir, name); lock (locking) { if (File.Exists(path)) player.Inbox = File.ReadAllLines(path).Length; else player.Inbox = 0; } }
internal virtual void Entering(Client player) { if (Type == SpawnRegion.Type) { SpawnRegion.Entering(player); } if (Type == SpawnTimeRegion.Type) { SpawnTimeRegion.Entering(player); return; } Log.WriteRegion(player, this, true); Regions.WarpPortalVisuals.EnterRegion(player, this); //Region message if (Message != null) { player.TellAbove(Chat.DarkAqua + "[region] ", Message); } else { player.TellAbove(Chat.DarkAqua, "Entering " + Name); } if (player.Settings.Cloaked != null) { return; } if (ReportVisits == false) { return; } string message = player.Name + " entered " + ColorName + " " + FromDirection(player.Session.Position); #if DEBUG player.TellSystem("DEBUG " + Chat.Blue, message); #endif TellResidentsSystem(player, Chat.Blue, message); }
internal void SetMessage(Client player, string message) { RegionList regions = player.Session.World.Regions; if (ResidentPermissions(player) == false) { player.TellSystem(Chat.Yellow, " You are not a resident of this region"); return; } if (message == "-" || message == "off" || message == "rem" || message == "remove") { message = null; } Message = message; Log.WritePlayer(player, "Message for " + Name + " set to " + Message); RegionLoader.Save(regions); TellResidentsSystem(null, Chat.Blue, player.Name + " changed region message to " + Message); }
internal void SetReport(Client player, string state) { RegionList regions = player.Session.World.Regions; if (ResidentPermissions(player) == false) { player.TellSystem(Chat.Yellow, " You are not a resident of this region"); return; } if (state == "on") { ReportVisits = true; } if (state == "off") { ReportVisits = false; } RegionLoader.Save(regions); }
/// <summary> /// Report inbox status to player /// </summary> public static void Status(Client player) { string name = PrepareName(player.MinecraftUsername); if (name == null) { player.TellSystem(Chat.Red, "Invalid name: " + player.MinecraftUsername); return; } string path = Path.Combine(dir, name); lock (locking) { if (File.Exists(path)) { player.Inbox = File.ReadAllLines(path).Length; } else { player.Inbox = 0; } } }
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; } } }
static void TellMode(Client player) { if (player.Settings.Cloaked != null) player.TellSystem(Chat.Purple, "You are a " + Chat.DarkAqua + player.Settings.Cloaked); else player.TellSystem(Chat.Purple, "You are yourself"); }
/// <summary> /// Read inbox messages to player /// </summary> public static void Read(Client player, string[] cmd, int iarg) { string name = PrepareName(player.MinecraftUsername); if (name == null) { player.TellSystem(Chat.Red, "Invalid name: " + player.MinecraftUsername); return; } string path = Path.Combine(dir, name); string[] messages; lock (locking) { if (File.Exists(path) == false) { messages = new string[0]; } else { messages = File.ReadAllLines(path); File.Delete(path); } } if (messages.Length == 0) { player.TellSystem(Chat.Purple, "Inbox: no new messages"); } foreach (string line in messages) { string[] parts = line.Split(new char[] { '\t' }, 3); if (parts.Length != 3) { player.TellSystem(Chat.Purple, line); } else { DateTime timestamp; DateTime.TryParse(parts [0], out timestamp); TimeSpan ago = DateTime.Now - timestamp; string agoString; if (ago.TotalHours < 1) { agoString = ago.TotalMinutes.ToString("0") + " minutes"; } else if (ago.TotalDays < 1) { agoString = ago.TotalHours.ToString("0") + " hours"; } else { agoString = ago.TotalDays.ToString("0") + " days"; } player.TellSystem(Chat.Yellow, "From " + parts [1] + " " + agoString + " ago"); player.TellSystem(Chat.White + "> ", parts [2]); } } Status(player); }
public static bool ReadFile(string path, string prefix, Client player) { path = Path.Combine("chat", path); if (File.Exists(path) == false) { if (path.Contains(" ") == false) Log.WriteServer("File not found: " + path); return false; } using (TextReader reader = new StreamReader (path)) { while (true) { string line = reader.ReadLine(); if (line == null) break; if (line.StartsWith("\t")) { prefix = line.Substring(1); continue; } player.TellSystem(prefix, line); } } return true; }
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); } }
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); } }
public void Resize(int minX, int maxX, int minY, int maxY, int minZ, int maxZ, Client player) { RegionList regions = player.Session.World.Regions; Region test = new Region(minX, maxX, minY, maxY, minZ, maxZ); WorldRegion parent = RegionCrossing.GetParentRegion(regions.List, this); if (parent == null) { player.TellSystem(Chat.Red, "parent not found"); return; } if (player.Admin() == false) { if ((Donors.IsDonor(player) == false)) { player.TellSystem(Chat.Aqua, "Only for donors and admins may resize a region"); return; } //Useless since when only donors get this far: if (minY < 50 && (!player.Donor)) { player.TellSystem(Chat.Red, "Only admins and donors may make regions below Y=50"); return; } if (ResidentPermissions(player) == false) { player.TellSystem(Chat.Yellow, "You are not a resident of this region"); return; } if (parent.ResidentPermissions(player) == false) { player.TellSystem(Chat.Yellow, "You are not a resident of the parent region"); return; } } List <WorldRegion> list; if (parent == this) { list = player.Session.World.Regions.List; } else { list = parent.SubRegions; } //Make sure the new size overlaps the old one so we don't make huge mistakes if (test.Overlap(this) == false) { player.TellSystem(Chat.Red, "New size must overlap old one"); player.TellSystem(Chat.Red, "New size " + test); player.TellSystem(Chat.Red, "Old size " + this.Coords()); return; } //Check that the new size fits in the parent if (parent != this) { if (parent.Cover(test) == false) { player.TellSystem(Chat.Red, "parent " + parent.Name + " is too small " + parent.Coords()); return; } } //else we are in the top level, no limit there //Make sure new size does not collide with siblings foreach (WorldRegion w in list) { if (w.Dimension != Dimension) //If toplevel "siblings" are all toplevel regions { continue; } if (w == this) { continue; } if (w.Overlap(test)) { player.TellSystem(Chat.Red, "new size overlap sibling " + w); return; } } //Chech that subregions still fit into the new size if (SubRegions != null) { foreach (WorldRegion w in SubRegions) { if (test.Cover(w) == false) { player.TellSystem(Chat.Red, "New size does not cover subregion:"); player.TellSystem(Chat.Red, w.ToString()); return; } } } Log.WritePlayer(player, "Region Resized: from " + this + " to " + test); MinX = test.MinX; MaxX = test.MaxX; MinY = test.MinY; MaxY = test.MaxY; MinZ = test.MinZ; MaxZ = test.MaxZ; RegionLoader.Save(regions); player.TellSystem(Chat.Purple, "Region resized: " + this); }
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 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() && 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() == 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"); } }