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 );
}
}