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> /// Completes the command. /// </summary> /// <returns>The completion or null if no match was found.</returns> /// <param name="player">Player.</param> /// <param name="c">command without the leading /</param> public void CompleteCommand(Client player, string c, TabComplete tab) { if (player.Admin()) { Complete(AdminStrings, c, tab); } Complete(CommandStrings, c, tab); }
/// <summary> /// Return true if player is resident or admin /// </summary> public bool ResidentPermissions(Client player) { if (player.Admin()) { return(true); } return(IsResident(player.MinecraftUsername)); }
static void CloakCommand(Client player, string[] cmd, int iarg) { if (player.Admin(Permissions.Cloak) == false) { return; } if (cmd.Length < 2) { TellMode(player); return; } switch (cmd [iarg]) { case "clear": case "reset": case "normal": case "off": SetCloak(player, null); break; case "none": case "invisible": case "on": SetCloak(player, MobType.None.ToString()); break; /* * case "Villager": * case "Snowman": * case "EnderDragon": * player.Tell (Chat.Red, cmd [1] + " is disabled/not working"); * return; */ case "back": if (cloakBack.ContainsKey(player.MinecraftUsername) == false) { throw new ErrorException("No saved position, use /cloak first"); } player.Warp(cloakBack [player.MinecraftUsername], player.Session.Dimension, World.Main); break; default: SetCloak(player, cmd [iarg]); break; } }
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); }
/// <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); } } }
static void CloakCommand(Client player, string[] cmd, int iarg) { if (player.Admin() == false) return; if (cmd.Length < 2) { TellMode(player); return; } switch (cmd [iarg]) { case "clear": case "reset": case "normal": case "off": SetCloak(player, null); break; case "none": case "invisible": case "on": SetCloak(player, MobType.None.ToString()); break; /* case "Villager": case "Snowman": case "EnderDragon": player.Tell (Chat.Red, cmd [1] + " is disabled/not working"); return; */ case "back": if (cloakBack.ContainsKey(player.MinecraftUsername) == false) throw new ErrorException("No saved position, use /cloak first"); player.Warp(cloakBack [player.MinecraftUsername], player.Session.Dimension, World.Main); break; default: SetCloak(player, cmd [iarg]); break; } }
public virtual bool ParseCommand(Client player, string[] cmd, int iarg) { string command = cmd [iarg - 1]; if (player.Admin()) { if (AdminCommandParse.ContainsKey(command)) { AdminCommandParse [command](player, cmd, iarg); return(true); } } if (CommandParse.ContainsKey(command)) { CommandParse [command](player, cmd, iarg); return(true); } return(false); }
/// <summary> /// Completes the command. /// </summary> /// <returns>The completion or null if no match was found.</returns> /// <param name="player">Player.</param> /// <param name="c">command without the leading /</param> public void CompleteCommand(Client player, string c, TabComplete tab) { if (player.Admin()) Complete(AdminStrings, c, tab); Complete(CommandStrings, c, tab); }
public virtual bool ParseCommand(Client player, string[] cmd, int iarg) { string command = cmd [iarg - 1]; if (player.Admin()) { if (AdminCommandParse.ContainsKey(command)) { AdminCommandParse [command](player, cmd, iarg); return true; } } if (CommandParse.ContainsKey(command)) { CommandParse [command](player, cmd, iarg); return true; } return false; }
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 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 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"); } }
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); } }