public static World AddWorld( Player player, string name, Map map, bool neverUnload ) { if( name == null ) throw new ArgumentNullException( "name" ); if( !World.IsValidName( name ) ) { throw new WorldOpException( name, WorldOpExceptionCode.InvalidWorldName ); } lock( WorldListLock ) { if( Worlds.ContainsKey( name.ToLower() ) ) { throw new WorldOpException( name, WorldOpExceptionCode.DuplicateWorldName ); } if( RaiseWorldCreatingEvent( player, name, map ) ) { throw new WorldOpException( name, WorldOpExceptionCode.PluginDenied ); } World newWorld = new World( name, neverUnload ); if( map != null ) { newWorld.Map = map; map.World = newWorld; /* string accessSecurityString = map.GetMeta( "security", "access" ); if( accessSecurityString != null ) { try { newWorld.AccessSecurity = new SecurityController( XElement.Parse( accessSecurityString ) ); } catch( XmlException ex ) { Logger.Log( "WorldManager.AddWorld: Error loading stored access permissions: {0}", LogType.Error, ex ); } } string buildSecurityString = map.GetMeta( "security", "build" ); if( buildSecurityString != null ) { try { newWorld.BuildSecurity = new SecurityController( XElement.Parse( buildSecurityString ) ); } catch( XmlException ex ) { Logger.Log( "WorldManager.AddWorld: Error loading stored build permissions: {0}", LogType.Error, ex ); } } */ // if a map is given if( neverUnload ) { newWorld.StartTasks(); }else{ newWorld.UnloadMap( false ); } } else if( neverUnload ){ newWorld.LoadMap(); map = newWorld.Map; } Worlds.Add( name.ToLower(), newWorld ); UpdateWorldList(); RaiseWorldCreatedEvent( player, newWorld ); return newWorld; } }
public static World AddWorld(Player player, string name, Map map, bool neverUnload) { if (name == null) { throw new ArgumentNullException("name"); } if (!World.IsValidName(name)) { throw new WorldOpException(name, WorldOpExceptionCode.InvalidWorldName); } lock ( WorldListLock ) { if (Worlds.ContainsKey(name.ToLower())) { throw new WorldOpException(name, WorldOpExceptionCode.DuplicateWorldName); } if (RaiseWorldCreatingEvent(player, name, map)) { throw new WorldOpException(name, WorldOpExceptionCode.PluginDenied); } World newWorld = new World(name, neverUnload); if (map != null) { newWorld.Map = map; map.World = newWorld; /* * string accessSecurityString = map.GetMeta( "security", "access" ); * if( accessSecurityString != null ) { * try { * newWorld.AccessSecurity = new SecurityController( XElement.Parse( accessSecurityString ) ); * } catch( XmlException ex ) { * Logger.Log( "WorldManager.AddWorld: Error loading stored access permissions: {0}", LogType.Error, ex ); * } * } * * string buildSecurityString = map.GetMeta( "security", "build" ); * if( buildSecurityString != null ) { * try { * newWorld.BuildSecurity = new SecurityController( XElement.Parse( buildSecurityString ) ); * } catch( XmlException ex ) { * Logger.Log( "WorldManager.AddWorld: Error loading stored build permissions: {0}", LogType.Error, ex ); * } * } */ // if a map is given if (neverUnload) { newWorld.StartTasks(); } else { newWorld.UnloadMap(false); } } else if (neverUnload) { newWorld.LoadMap(); map = newWorld.Map; } Worlds.Add(name.ToLower(), newWorld); UpdateWorldList(); RaiseWorldCreatedEvent(player, newWorld); return(newWorld); } }