public static World FindMainWorld( Player player ) { World rankMain = player.Info.Rank.MainWorld; if( rankMain != null && player.CanJoin( rankMain ) ) { return rankMain; } else { return MainWorld; } }
public static World FindMainWorld( Player player ) { World rankMain = player.Info.Rank.MainWorld; if ((player.Info.TimesVisited == 1 || player.Info.HasRTR == false) && FindWorldExact("Tutorial") != null) return FindWorldOrPrintMatches(player, "Tutorial"); if( rankMain != null && player.CanJoin( rankMain ) && player.Info.JoinOnRankWorld == true ) { return rankMain; } else { return MainWorld; } }
public static World FindMainWorld(Player player) { World rankMain = player.Info.Rank.MainWorld; if (rankMain != null && player.CanJoin(rankMain)) { return(rankMain); } else { return(MainWorld); } }
public static World FindMainWorld([NotNull] Player player) { if (player == null) { throw new ArgumentNullException("player"); } World rankMain = player.Info.Rank.MainWorld; if (rankMain != null && player.CanJoin(rankMain)) { return(rankMain); } else { return(MainWorld); } }
static void WorldBringHandler( Player player, CommandReader cmd ) { string playerName = cmd.Next(); string worldName = cmd.Next(); if( playerName == null || worldName == null ) { CdWorldBring.PrintUsage( player ); return; } Player target = Server.FindPlayerOrPrintMatches( player, playerName, false, false, true ); World world = WorldManager.FindWorldOrPrintMatches( player, worldName ); if( target == null || world == null ) return; if( !player.Can( Permission.Bring, target.Info.Rank ) ) { player.Message( "You may only bring players ranked {0}&S or lower.", player.Info.Rank.GetLimit( Permission.Bring ).ClassyName ); player.Message( "{0}&S is ranked {1}", target.ClassyName, target.Info.Rank.ClassyName ); return; } if( world == target.World ) { player.Message( "Player {0}&S is already in world {1}&S. They were brought to spawn.", target.ClassyName, world.ClassyName ); target.TeleportTo( target.WorldMap.Spawn ); return; } SecurityCheckResult check = world.AccessSecurity.CheckDetailed( target.Info ); if( check == SecurityCheckResult.RankTooLow ) { if( player.CanJoin( world ) ) { if( cmd.IsConfirmed ) { BringPlayerToWorld( player, target, world, true, false ); } else { Logger.Log( LogType.UserActivity, "WBring: Asked {0} to confirm overriding world permissions to bring player {1} to world {2}", player.Name, target.Name, world.Name ); player.Confirm( cmd, "Player {0}&S is ranked too low to join {1}&S. Override world permissions?", target.ClassyName, world.ClassyName ); } } else { player.Message( "Neither you nor {0}&S are allowed to join world {1}", target.ClassyName, world.ClassyName ); } } else { BringPlayerToWorld( player, target, world, false, false ); } }
static void BringHandler( Player player, CommandReader cmd ) { string name = cmd.Next(); if( name == null ) { CdBring.PrintUsage( player ); return; } // bringing someone to another player (instead of to self) string toName = cmd.Next(); Player toPlayer = player; if( toName != null ) { toPlayer = Server.FindPlayerOrPrintMatches( player, toName, true, false, true ); if( toPlayer == null ) return; } else if( toPlayer.World == null ) { player.Message( "When used from console, /Bring requires both names to be given." ); return; } World world = toPlayer.World; if( world == null ) PlayerOpException.ThrowNoWorld( toPlayer ); Player target = Server.FindPlayerOrPrintMatches( player, name, true, false, true ); if( target == null ) return; if( !player.Can( Permission.Bring, target.Info.Rank ) ) { player.Message( "You may only bring players ranked {0}&S or lower.", player.Info.Rank.GetLimit( Permission.Bring ).ClassyName ); player.Message( "{0}&S is ranked {1}", target.ClassyName, target.Info.Rank.ClassyName ); return; } if( target.World == world ) { // teleport within the same world target.TeleportTo( toPlayer.Position ); } else { // teleport to a different world SecurityCheckResult check = world.AccessSecurity.CheckDetailed( target.Info ); if( check == SecurityCheckResult.RankTooLow ) { if( player.CanJoin( world ) ) { if( cmd.IsConfirmed ) { BringPlayerToWorld( player, target, world, true, true ); } else { Logger.Log( LogType.UserActivity, "Bring: Asked {0} to confirm overriding world permissions to bring player {1} to world {2}", player.Name, target.Name, world.Name ); player.Confirm( cmd, "Player {0}&S is ranked too low to join {1}&S. Override world permissions?", target.ClassyName, world.ClassyName ); } } else { player.Message( "Neither you nor {0}&S are allowed to join world {1}", target.ClassyName, world.ClassyName ); } } else { BringPlayerToWorld( player, target, world, false, true ); } } }
static void SetMainWorld(Player player, World world) { if (world == WorldManager.MainWorld) { player.Message("World {0}&S is already set as main.", world.ClassyName); } else if (!player.Info.Rank.AllowSecurityCircumvention && !player.CanJoin(world)) { // Prevent players from exploiting /WMain to gain access to restricted maps switch (world.AccessSecurity.CheckDetailed(player.Info)) { case SecurityCheckResult.RankTooHigh: case SecurityCheckResult.RankTooLow: player.Message("You are not allowed to set {0}&S as the main world (by rank).", world.ClassyName); return; case SecurityCheckResult.BlackListed: player.Message("You are not allowed to set {0}&S as the main world (blacklisted).", world.ClassyName); return; } } else { if (world.AccessSecurity.HasRestrictions) { world.AccessSecurity.Reset(); player.Message("The main world cannot have access restrictions. " + "All access restrictions were removed from world {0}", world.ClassyName); } try { WorldManager.MainWorld = world; } catch (WorldOpException ex) { player.Message(ex.Message); return; } WorldManager.SaveWorldList(); Server.Message("{0}&S set {1}&S to be the main world.", player.ClassyName, world.ClassyName); Logger.Log(LogType.UserActivity, "{0} set {1} to be the main world.", player.Name, world.Name); } }
static void WorldBringHandler( Player player, CommandReader cmd ) { string playerName = cmd.Next(); string worldName = cmd.Next(); if( playerName == null || worldName == null ) { CdWorldBring.PrintUsage( player ); return; } Player target = Server.FindPlayerOrPrintMatches(player, playerName, SearchOptions.Default); World world = WorldManager.FindWorldOrPrintMatches( player, worldName ); if( target == null || world == null ) return; if (target == player) { player.Message( "&WYou cannot &H/WBring&W yourself." ); return; } if( !player.Can( Permission.Bring, target.Info.Rank ) ) { player.Message( "You may only bring players ranked {0}&S or lower.", player.Info.Rank.GetLimit( Permission.Bring ).ClassyName ); player.Message( "{0}&S is ranked {1}", target.ClassyName, target.Info.Rank.ClassyName ); return; } if( world == target.World ) { player.Message( "{0}&S is already in world {1}&S. They were brought to spawn.", target.ClassyName, world.ClassyName); if (target.World != null) { target.LastWorld = target.World; target.LastPosition = target.Position; } target.TeleportTo( target.WorldMap.Spawn ); return; } SecurityCheckResult check = world.AccessSecurity.CheckDetailed( target.Info ); if( check == SecurityCheckResult.RankTooLow ) { if( player.CanJoin( world ) ) { if( cmd.IsConfirmed ) { BringPlayerToWorld( player, target, world, true, false ); } else { //Allow banned players to be moved about... if (target.Info.Rank.Name == "Banned") { player.Message("&sYou CAN move banned players about... It is considered bad form though..."); } Logger.Log( LogType.UserActivity, "WBring: Asked {0} to confirm overriding world permissions to bring player {1} to world {2}", player.Name, target.Name, world.Name ); player.Confirm( cmd, "{0} {1}&S is ranked too low to join {2}&S. Override world permissions?", target.Info.Rank.ClassyName, target.ClassyName, world.ClassyName ); } } else { player.Message( "Neither you nor {0}&S are allowed to join world {1}", target.ClassyName, world.ClassyName ); } } else { //Allow banned players to be moved about... if (target.Info.Rank.Name == "Banned") { player.Message("&sYou CAN move banned players about... It is considered bad form though..."); } BringPlayerToWorld( player, target, world, false, false ); } }
internal static void Worlds( Player player, Command cmd ) { string param = cmd.Next(); bool listVisible = true, listHidden = false, listAllLoaded = false; if( !String.IsNullOrEmpty( param ) ) { switch( Char.ToLower( param[0] ) ) { case 'a': listHidden = true; break; case 'h': listVisible = false; listHidden = true; break; case 'l': listAllLoaded = true; listVisible = false; listHidden = false; break; default: cdWorlds.PrintUsage( player ); return; } } StringBuilder sb = new StringBuilder(); bool first = true; int count = 0; World[] worldListCache = WorldManager.WorldList; foreach( World world in worldListCache ) { bool visible = player.CanJoin( world ) && !world.IsHidden; if( (world.IsLoaded && listAllLoaded) || (visible && listVisible) || (!visible && listHidden) ) { if( !first ) { sb.Append( ", " ); } sb.Append( world.GetClassyName() ); count++; first = false; } } if( listAllLoaded ) { player.MessagePrefixed( "&S ", "There are " + count + " loaded worlds: " + sb ); } else if( listVisible && !listHidden ) { player.MessagePrefixed( "&S ", "There are " + count + " available worlds: " + sb ); } else if( !listVisible ) { player.MessagePrefixed( "&S ", "There are " + count + " hidden worlds: " + sb ); } else { player.MessagePrefixed( "&S ", "There are " + count + " worlds total: " + sb ); } }
internal static void WorldMain( Player player, Command cmd ) { string worldName = cmd.Next(); if( worldName == null ) { player.Message( "Main world is {0}", WorldManager.MainWorld.GetClassyName() ); return; } World world = WorldManager.FindWorldOrPrintMatches( player, worldName ); if( world == null ) { return; } else if( world == WorldManager.MainWorld ) { player.Message( "World {0}&S is already set as main.", world.GetClassyName() ); } else if( !player.Info.Rank.AllowSecurityCircumvention && !player.CanJoin( world ) ) { // Prevent players from exploiting /wmain to gain access to restricted maps switch( world.AccessSecurity.CheckDetailed( player.Info ) ) { case SecurityCheckResult.RankTooHigh: case SecurityCheckResult.RankTooLow: player.Message( "You are not allowed to set {0}&S as the main world (by rank).", world.GetClassyName() ); return; case SecurityCheckResult.BlackListed: player.Message( "You are not allowed to set {0}&S as the main world (blacklisted).", world.GetClassyName() ); return; } } else { if( world.AccessSecurity.HasRestrictions() ) { world.AccessSecurity.Reset(); player.Message( "The main world cannot have access restrictions. " + "All access restrictions were removed from world {0}", world.GetClassyName() ); } if( !world.SetMainWorld() ) { player.Message( "Main world was not changed." ); return; } WorldManager.SaveWorldList(); Server.SendToAll( "{0}&S set {1}&S to be the main world.", player.GetClassyName(), world.GetClassyName() ); Logger.Log( "{0} set {1} to be the main world.", LogType.UserActivity, player.Name, world.Name ); } }
private static void MWHandler(Player player, CommandReader cmd) { switch (cmd.Next()) { #region Create case "create": case "c": string sizeStringc = cmd.Next(); int sizec; if (sizeStringc == null) { sizeStringc = "Normal"; } switch (sizeStringc.ToLower()) { case "64": case "tiny": sizec = 64; sizeStringc = "Tiny"; break; case "128": case "normal": sizec = 128; sizeStringc = "Normal"; break; case "256": case "large": sizec = 256; sizeStringc = "Large"; break; case "512": case "huge": sizec = 512; sizeStringc = "Huge"; break; default: sizec = 128; sizeStringc = "Normal"; break; } World[] totalc = WorldManager.FindWorlds(Player.Console, "PW_" + player.Name + "_"); if (totalc.Count() >= player.Info.Rank.MaxPersonalWorlds && player.Info.Rank != RankManager.HighestRank) { player.Message("You can only have a maximum of {0} personal worlds. Sorry!", player.Info.Rank.MaxPersonalWorlds); break; } string worldNamec = string.Format("PW_{0}_{1}", player.Name, (totalc.Any()) ? "" + (totalc.Count() + 1) : "1"); player.Message("Creating your {0}({1}) personal world: {2}", sizeStringc, sizec, worldNamec); Map map = MapGenerator.GenerateFlatgrass(sizec, sizec, sizec); Server.RequestGC(); if (map.Save("./Maps/" + worldNamec + ".fcm")) { player.Message("Done!. Saved to {0}.fcm", worldNamec); } else { player.Message("&WAn error occurred while saving generated map to {0}.fcm", worldNamec); } Rank buildRank = RankManager.HighestRank; Rank accessRank = RankManager.HighestRank; lock (WorldManager.SyncRoot) { World newWorld; try { newWorld = WorldManager.AddWorld(player, worldNamec, map, false); } catch (WorldOpException ex) { player.Message("WLoad: {0}", ex.Message); break; } player.LastUsedWorldName = worldNamec; newWorld.BuildSecurity.MinRank = buildRank; if (accessRank == null) { newWorld.AccessSecurity.ResetMinRank(); } else { newWorld.AccessSecurity.MinRank = accessRank; } newWorld.BlockDB.AutoToggleIfNeeded(); newWorld.LoadedBy = player.Name; newWorld.LoadedOn = DateTime.UtcNow; newWorld.IsHidden = true; Logger.Log(LogType.UserActivity, "{0} {1} &screated a new world named \"{2}\" (loaded from \"{3}\")", player.Info.Rank.Name, player.Name, worldNamec, worldNamec); newWorld.AccessSecurity.Include(player.Info); newWorld.BuildSecurity.Include(player.Info); newWorld.EdgeLevel = (short) (sizec/2); WorldManager.SaveWorldList(); } Server.RequestGC(); break; #endregion #region Reset case "reset": case "r": string wNumberStringr = cmd.Next(); int wNumberr; if (!int.TryParse(wNumberStringr, out wNumberr)) { wNumberr = 1; } string mapFiler = WorldManager.FindMapFile(Player.Console, "PW_" + player.Name + "_" + wNumberr); if (mapFiler == null) { player.Message("You have no personal worlds by that number: {0}", wNumberr); break; } if (!cmd.IsConfirmed) { player.Confirm(cmd, "This will reset your personal world: " + " PW_" + player.Name + "_" + wNumberr + "&n" + "&cThis cannot be undone!"); break; } World worldr = WorldManager.FindWorldExact("PW_" + player.Name + "_" + wNumberr); map = MapGenerator.GenerateFlatgrass(worldr.map.Width, worldr.map.Length, worldr.map.Height); worldr.MapChangedBy = player.Name; worldr.ChangeMap(map); player.Message("Your personal world({0}) has been reset to flatgrass!", wNumberr); Server.RequestGC(); break; #endregion #region Delete case "delete": case "d": case "remove": string wNumberStringd = cmd.Next(); int wNumberd; if (!int.TryParse(wNumberStringd, out wNumberd)) { wNumberd = 1; } string mapFiled = WorldManager.FindMapFile(Player.Console, "PW_" + player.Name + "_" + wNumberd); if (mapFiled == null) { player.Message("You have no personal worlds by that number: {0}", wNumberd); break; } if (!cmd.IsConfirmed) { player.Confirm(cmd, "This will delete your personal world: " + " PW_" + player.Name + "_" + wNumberd + "&n" + "&cThis cannot be undone!"); break; } World worldd = WorldManager.FindWorldExact("PW_" + player.Name + "_" + wNumberd); if (worldd != null) WorldManager.RemoveWorld(worldd); if (File.Exists("./maps/PW_" + player.Name + "_" + wNumberd + ".fcm")) { File.Delete("./maps/PW_" + player.Name + "_" + wNumberd + ".fcm"); } player.Message("Your personal world({0}) has been deleted!", wNumberd); Server.RequestGC(); break; #endregion #region Join case "j": case "join": string wNumberStringj = cmd.Next(); int wNumberj; if (!int.TryParse(wNumberStringj, out wNumberj)) { wNumberj = 1; } string playerStringj = cmd.Next(); PlayerInfo playerj = null; if (playerStringj != null) { playerj = PlayerDB.FindPlayerInfoOrPrintMatches(player, playerStringj, SearchOptions.Default); } string mapFilej = WorldManager.FindMapFile(Player.Console, "PW_" + ((playerj == null) ? player.Name : playerj.Name) + "_" + wNumberj); if (mapFilej == null) { player.Message("{0} no personal worlds by that number: {1}", (playerj == null) ? "You have" : "There are", wNumberj); break; } World worldj = WorldManager.FindWorldExact("PW_" + ((playerj == null) ? player.Name : playerj.Name) + "_" + wNumberj); if (worldj != null && player.CanJoin(worldj)) { player.JoinWorld(worldj, WorldChangeReason.ManualJoin); } else { player.Message("You cannot join that world!"); } break; #endregion #region BuildAccess case "buildaccess": case "ba": string wNumberStringba = cmd.Next(); string exceptionba = cmd.Next(); int wNumberba; bool changesWereMade = false; if (!int.TryParse(wNumberStringba, out wNumberba)) { wNumberba = 1; exceptionba = wNumberStringba; } string mapFileba = WorldManager.FindMapFile(Player.Console, "PW_" + player.Name + "_" + wNumberba); if (mapFileba == null) { player.Message("You have no personal worlds by that number: {0}", wNumberba); break; } World worldba = WorldManager.FindWorldExact("PW_" + player.Name + "_" + wNumberba); if (exceptionba == null) { CdMyWorld.PrintUsage(player); break; } if (exceptionba.Equals("-*")) { PlayerInfo[] oldWhitelistba = worldba.BuildSecurity.ExceptionList.Included.ToArray(); if (oldWhitelistba.Length > 0) { worldba.BuildSecurity.ResetIncludedList(); player.Message("Build whitelist of personal world {0}&S cleared: {1}", worldba.ClassyName, oldWhitelistba.JoinToClassyString()); Logger.Log(LogType.UserActivity, "{0} {1} &scleared build whitelist of personal world {2}: {3}", player.Info.Rank.Name, player.Name, worldba.Name, oldWhitelistba.JoinToString(pi => pi.Name)); worldba.BuildSecurity.Include(player.Info); } else { player.Message("Build whitelist of personal world {0}&S is empty.", worldba.ClassyName); } goto saveba; } // Clear blacklist if (exceptionba.Equals("+*")) { PlayerInfo[] oldBlacklist = worldba.BuildSecurity.ExceptionList.Excluded.ToArray(); if (oldBlacklist.Length > 0) { worldba.BuildSecurity.ResetExcludedList(); player.Message("Build blacklist of personal world {0}&S cleared: {1}", worldba.ClassyName, oldBlacklist.JoinToClassyString()); Logger.Log(LogType.UserActivity, "{0} {1} &scleared build blacklist of personal world {2}: {3}", player.Info.Rank.Name, player.Name, worldba.Name, oldBlacklist.JoinToString(pi => pi.Name)); } else { player.Message("Build blacklist of personal world {0}&S is empty.", worldba.ClassyName); } goto saveba; } // Whitelisting individuals if (exceptionba.StartsWith("+")) { PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches(player, exceptionba.Substring(1), SearchOptions.Default); if (info == null) return; // prevent players from whitelisting themselves to bypass protection if (player.Info == info) { goto saveba; } if (worldba.BuildSecurity.Check(info)) { player.Message("{0}&S is already allowed to build in {1}", info.ClassyName, worldba.ClassyName); goto saveba; } Player target = info.PlayerObject; if (target == player) target = null; // to avoid duplicate messages switch (worldba.BuildSecurity.Include(info)) { case PermissionOverride.Deny: if (worldba.BuildSecurity.Check(info)) { player.Message("{0}&S is no longer barred from building in {1}", info.ClassyName, worldba.ClassyName); if (target != null) { target.Message( "You can now build in personal world {0}&S (removed from blacklist by {1}&S).", worldba.ClassyName, player.ClassyName); } } else { player.Message( "{0}&S was removed from the build blacklist of {1}&S. " + "Player is still NOT allowed to build.", info.ClassyName, worldba.ClassyName); if (target != null) { target.Message( "You were removed from the build blacklist of world {0}&S by {1}&S. " + "You are still NOT allowed to build.", worldba.ClassyName, player.ClassyName); } } Logger.Log(LogType.UserActivity, "{0} removed {1} from the build blacklist of {2}", player.Name, info.Name, worldba.Name); changesWereMade = true; break; case PermissionOverride.None: player.Message("{0}&S is now allowed to build in {1}", info.ClassyName, worldba.ClassyName); if (target != null) { target.Message("You can now build in world {0}&S (whitelisted by {1}&S).", worldba.ClassyName, player.ClassyName); } Logger.Log(LogType.UserActivity, "{0} added {1} to the build whitelist on personal world {2}", player.Name, info.Name, worldba.Name); changesWereMade = true; break; case PermissionOverride.Allow: player.Message("{0}&S is already on the build whitelist of {1}", info.ClassyName, worldba.ClassyName); break; } // Blacklisting individuals } else if (exceptionba.StartsWith("-")) { PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches(player, exceptionba.Substring(1), SearchOptions.Default); if (info == null) return; if (!worldba.BuildSecurity.Check(info)) { player.Message("{0}&S is already barred from building in {1}", info.ClassyName, worldba.ClassyName); goto saveba; } Player target = info.PlayerObject; if (target == player) target = null; // to avoid duplicate messages switch (worldba.BuildSecurity.Exclude(info)) { case PermissionOverride.Deny: player.Message("{0}&S is already on build blacklist of {1}", info.ClassyName, worldba.ClassyName); break; case PermissionOverride.None: player.Message("{0}&S is now barred from building in {1}", info.ClassyName, worldba.ClassyName); if (target != null) { target.Message("&WYou were barred by {0}&W from building in personal world {1}", player.ClassyName, worldba.ClassyName); } Logger.Log(LogType.UserActivity, "{0} added {1} to the build blacklist on personal world {2}", player.Name, info.Name, worldba.Name); changesWereMade = true; break; case PermissionOverride.Allow: if (worldba.BuildSecurity.Check(info)) { player.Message( "{0}&S is no longer on the build whitelist of {1}&S. " + "Player is still allowed to build.", info.ClassyName, worldba.ClassyName); if (target != null) { target.Message( "You were removed from the build whitelist of personal world {0}&S by {1}&S. " + "You are still allowed to build.", worldba.ClassyName, player.ClassyName); } } else { player.Message("{0}&S is no longer allowed to build in {1}", info.ClassyName, worldba.ClassyName); if (target != null) { target.Message( "&WYou can no longer build in personal world {0}&W (removed from whitelist by {1}&W).", worldba.ClassyName, player.ClassyName); } } Logger.Log(LogType.UserActivity, "{0} removed {1} from the build whitelist on personal world {2}", player.Name, info.Name, worldba.Name); changesWereMade = true; break; } } saveba: if (changesWereMade) { WorldManager.SaveWorldList(); } break; #endregion #region JoinAccess case "ja": case "joinaccess": string wNumberStringja = cmd.Next(); string exceptionja = cmd.Next(); int wNumberja; bool changesWereMadeja = false; if (!int.TryParse(wNumberStringja, out wNumberja)) { wNumberja = 1; exceptionja = wNumberStringja; } string mapFileja = WorldManager.FindMapFile(Player.Console, "PW_" + player.Name + "_" + wNumberja); if (mapFileja == null) { player.Message("You have no personal worlds by that number: {0}", wNumberja); goto saveWorldja; } World worldja = WorldManager.FindWorldExact("PW_" + player.Name + "_" + wNumberja); if (exceptionja == null) { CdMyWorld.PrintUsage(player); break; } if (exceptionja.Equals("-*")) { PlayerInfo[] oldWhitelist = worldja.AccessSecurity.ExceptionList.Included.ToArray(); worldja.AccessSecurity.ResetIncludedList(); player.Message("Access whitelist of {0}&S cleared: {1}", worldja.ClassyName, oldWhitelist.JoinToClassyString()); Logger.Log(LogType.UserActivity, "{0} {1} &scleared access whitelist of personal world {2}: {3}", player.Info.Rank.Name, player.Name, worldja.Name, oldWhitelist.JoinToString(pi => pi.Name)); worldja.AccessSecurity.Include(player.Info); goto saveWorldja; } // Clear blacklist if (exceptionja.Equals("+*")) { PlayerInfo[] oldBlacklist = worldja.AccessSecurity.ExceptionList.Excluded.ToArray(); worldja.AccessSecurity.ResetExcludedList(); player.Message("Access blacklist of {0}&S cleared: {1}", worldja.ClassyName, oldBlacklist.JoinToClassyString()); Logger.Log(LogType.UserActivity, "{0} {1} &scleared access blacklist of personal world {2}: {3}", player.Info.Rank.Name, player.Name, worldja.Name, oldBlacklist.JoinToString(pi => pi.Name)); goto saveWorldja; } // Whitelisting individuals if (exceptionja.StartsWith("+")) { PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches(player, exceptionja.Substring(1), SearchOptions.Default); if (info == null) goto saveWorldja; // prevent players from whitelisting themselves to bypass protection if (player.Info == info) { goto saveWorldja; } if (worldja.AccessSecurity.Check(info)) { player.Message("{0}&S is already allowed to access {1}", info.ClassyName, worldja.ClassyName); goto saveWorldja; } Player target = info.PlayerObject; if (target == player) target = null; // to avoid duplicate messages switch (worldja.AccessSecurity.Include(info)) { case PermissionOverride.Deny: if (worldja.AccessSecurity.Check(info)) { player.Message("{0}&S is no longer barred from accessing {1}", info.ClassyName, worldja.ClassyName); if (target != null) { target.Message( "You can now access personal world {0}&S (removed from blacklist by {1}&S).", worldja.ClassyName, player.ClassyName); } } else { player.Message( "{0}&S was removed from the access blacklist of {1}&S. " + "Player is still NOT allowed to join.", info.ClassyName, worldja.ClassyName); if (target != null) { target.Message( "You were removed from the access blacklist of world {0}&S by {1}&S. " + "You are still NOT allowed to join.", worldja.ClassyName, player.ClassyName); } } Logger.Log(LogType.UserActivity, "{0} removed {1} from the access blacklist of {2}", player.Name, info.Name, worldja.Name); changesWereMadeja = true; break; case PermissionOverride.None: player.Message("{0}&S is now allowed to access {1}", info.ClassyName, worldja.ClassyName); if (target != null) { target.Message("You can now access personal world {0}&S (whitelisted by {1}&S).", worldja.ClassyName, player.ClassyName); } Logger.Log(LogType.UserActivity, "{0} added {1} to the access whitelist on personal world {2}", player.Name, info.Name, worldja.Name); changesWereMadeja = true; break; case PermissionOverride.Allow: player.Message("{0}&S is already on the access whitelist of {1}", info.ClassyName, worldja.ClassyName); break; } // Blacklisting individuals } else if (exceptionja.StartsWith("-")) { PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches(player, exceptionja.Substring(1), SearchOptions.Default); if (info == null) goto saveWorldja; if (!worldja.AccessSecurity.Check(info)) { player.Message("{0}&S is already barred from accessing {1}", info.ClassyName, worldja.ClassyName); goto saveWorldja; } Player target = info.PlayerObject; if (target == player) target = null; // to avoid duplicate messages switch (worldja.AccessSecurity.Exclude(info)) { case PermissionOverride.Deny: player.Message("{0}&S is already on access blacklist of {1}", info.ClassyName, worldja.ClassyName); break; case PermissionOverride.None: player.Message("{0}&S is now barred from accessing {1}", info.ClassyName, worldja.ClassyName); if (target != null) { target.Message("&WYou were barred by {0}&W from accessing personal world {1}", player.ClassyName, worldja.ClassyName); } Logger.Log(LogType.UserActivity, "{0} added {1} to the access blacklist on personal world {2}", player.Name, info.Name, worldja.Name); changesWereMadeja = true; break; case PermissionOverride.Allow: if (worldja.AccessSecurity.Check(info)) { player.Message( "{0}&S is no longer on the access whitelist of {1}&S. " + "Player is still allowed to join.", info.ClassyName, worldja.ClassyName); if (target != null) { target.Message( "You were removed from the access whitelist of personal world {0}&S by {1}&S. " + "You are still allowed to join.", worldja.ClassyName, player.ClassyName); } } else { player.Message("{0}&S is no longer allowed to access {1}", info.ClassyName, worldja.ClassyName); if (target != null) { target.Message( "&WYou can no longer access personal world {0}&W (removed from whitelist by {1}&W).", worldja.ClassyName, player.ClassyName); } } Logger.Log(LogType.UserActivity, "{0} removed {1} from the access whitelist on personal world {2}", player.Name, info.Name, worldja.Name); changesWereMadeja = true; break; } } saveWorldja: if (changesWereMadeja) { worldja = WorldManager.FindWorldExact("PW_" + player.Name + "_" + wNumberja); var playersWhoCantStay = worldja.Players.Where(p => !p.CanJoin(worldja)); foreach (Player p in playersWhoCantStay) { p.Message("&WYou are no longer allowed to join world {0}", worldja.ClassyName); p.JoinWorld(WorldManager.FindMainWorld(p), WorldChangeReason.PermissionChanged); } WorldManager.SaveWorldList(); } break; #endregion #region List case "l": case "list": World[] worldsl = WorldManager.Worlds.Where(w => w.Name.StartsWith("PW_" + player.Name + "_")).ToArray(); World[] otherworldsl = WorldManager.Worlds.Where( w => w.Name.StartsWith("PW_") && w.AccessSecurity.ExceptionList.Included.Contains(player.Info) && !w.Name.StartsWith("PW_" + player.Name + "_")).ToArray(); if (worldsl.Any()) { player.Message("Your personal worlds: {0}", worldsl.JoinToClassyString()); } if (otherworldsl.Any()) { player.Message("Player personal worlds you have access to: {0}", otherworldsl.JoinToClassyString()); } if (!worldsl.Any() && !otherworldsl.Any()) { player.Message("You do not have access to any personal worlds."); } break; #endregion default: CdMyWorld.PrintUsage(player); break; } }
static void WorldBringHandler( Player player, Command cmd ) { string playerName = cmd.Next(); string worldName = cmd.Next(); if( playerName == null || worldName == null ) { CdBring.PrintUsage( player ); return; } Player target = Server.FindPlayerOrPrintMatches( player, playerName, false, true ); World world = WorldManager.FindWorldOrPrintMatches( player, worldName ); if( target == null || world == null ) return; if( target == player ) { player.Message( "&WYou cannot &H/WBring&W yourself." ); return; } if( !player.Can( Permission.Bring, target.Info.Rank ) ) { player.Message( "You may only bring players ranked {0}&S or lower.", player.Info.Rank.GetLimit( Permission.Bring ).ClassyName ); player.Message( "{0}&S is ranked {1}", target.ClassyName, target.Info.Rank.ClassyName ); return; } if( world == target.World ) { player.Message( "Player {0}&S is already in world {1}", target.ClassyName, world.ClassyName ); return; } bool overridePermission = false; if( world.AccessSecurity.CheckDetailed( target.Info ) == SecurityCheckResult.RankTooLow && player.CanJoin( world ) ) { if( cmd.IsConfirmed ) { overridePermission = true; } else { player.Confirm( cmd, "Player {0}&S is ranked too low to join {1}&S. Override world permissions?", target.ClassyName, world.ClassyName ); return; } } BringPlayerToWorld( player, target, world, overridePermission, false ); }