public static void LoadDonors() { if (File.Exists(DonorsPath) == false) { return; } Dictionary <string, Donor> l = new Dictionary <string, Donor>(); //Read all donor statuses foreach (string u in System.IO.File.ReadAllLines(DonorsPath, System.Text.Encoding.UTF8)) { if (u.Contains(" ")) { continue; } if (u.StartsWith("#")) { continue; } string[] parts = u.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length < 3) { continue; } Donor d = new Donor(); d.Username = parts [0].ToLowerInvariant(); if (int.TryParse(parts [1], out d.Slots) == false) { continue; } if (DateTime.TryParse(parts [2], out d.Expire) == false) { continue; } if (d.Expire < DateTime.Now) { d.Slots = 0; } if (parts.Length < 4) { d.ExpireLegacy = d.Expire; } else if (DateTime.TryParse(parts [3], out d.ExpireLegacy) == false) { continue; } //Duplicate, keep the longest one if (l.ContainsKey(d.Username)) { //Merge var d2 = l [d.Username]; if (d.ExpireLegacy > d2.ExpireLegacy) { d2.ExpireLegacy = d.ExpireLegacy; } if (d.Expire > d2.Expire) { d2.Expire = d.Expire; } d2.Slots += d.Slots; //Merge done continue; } l.Add(d.Username, d); } Donors.Update(l); }
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); }
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); } } }
/// <summary> /// The player representation in the player list /// </summary> static string PlayerName(Client a) { string s = a.Name; if (a.Session is VanillaSession) { if (a.Session.Mode == GameMode.Creative) { s = Chat.Italic + a.Name; } else if (a.Session.Sleeping) { s = a.Name + Chat.DarkBlue + " zzZ"; } } else if (a.Session.World is GreenRoom) { s = Chat.DarkGreen + a.Name; } else if (a.Session.World is Hell) { s = Chat.DarkRed + a.Name; } else if (a.Session.World is TheConstruct) { s = Chat.DarkGray + a.Name; } else if (a.Session is AfkSession) { s = Chat.DarkGray + a.Name + " AFK"; } else if (a.Session.World is MineProxy.Worlds.Void) { s = Chat.Black + a.Name; } var donor = Donors.GetDonor(a.Name); if (donor != null && donor.Expire > DateTime.Now) { string color = ""; if (donor.Slots == 1) { color = Chat.Yellow; } if (donor.Slots == 2) { color = Chat.Gold; } if (donor.Slots >= 3) { color = Chat.Green; } if (a.Session is VanillaSession) { s = color + s; } else { s += color + ":)"; } } return(s); }
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); } }