本文整理汇总了C#中fCraft.World.UpdatePlayerList方法的典型用法代码示例。如果您正苦于以下问题:C# World.UpdatePlayerList方法的具体用法?C# World.UpdatePlayerList怎么用?C# World.UpdatePlayerList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fCraft.World
的用法示例。
在下文中一共展示了World.UpdatePlayerList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddWorld
public static World AddWorld( string name, Map map, bool neverUnload )
{
lock( worldListLock ) {
if( worlds.ContainsKey( name ) ) return null;
if( !Player.IsValidName( name ) ) return null;
World newWorld = new World( name );
newWorld.neverUnload = neverUnload;
if( map != null ) {
// if a map is given
newWorld.map = map;
if( !neverUnload ) {
newWorld.UnloadMap();// UnloadMap also saves the map
} else {
newWorld.SaveMap( null );
}
} else {
// generate default map
if( neverUnload ) newWorld.LoadMap();
}
worlds.Add( name, newWorld );
newWorld.updateTaskId = AddTask( UpdateBlocks, Config.GetInt( ConfigKey.TickInterval ), newWorld );
if( Config.GetInt( ConfigKey.SaveInterval ) > 0 ) {
int saveInterval = Config.GetInt( ConfigKey.SaveInterval ) * 1000;
newWorld.saveTaskId = AddTask( SaveMap, saveInterval, newWorld, saveInterval );
}
if( Config.GetInt( ConfigKey.BackupInterval ) > 0 ) {
int backupInterval = Config.GetInt( ConfigKey.BackupInterval ) * 1000 * 60;
newWorld.backupTaskId = AddTask( AutoBackup, backupInterval, newWorld, (Config.GetBool( ConfigKey.BackupOnStartup ) ? 0 : backupInterval) );
}
newWorld.UpdatePlayerList();
return newWorld;
}
}
示例2: ReplaceWorld
public static bool ReplaceWorld( string name, World newWorld )
{
lock( worldListLock ) {
World oldWorld = FindWorld( name );
if( oldWorld == null ) return false;
newWorld.name = oldWorld.name;
if( oldWorld == mainWorld ) {
mainWorld = newWorld;
}
// initialize the player list cache
newWorld.UpdatePlayerList();
// swap worlds
worlds[name.ToLower()] = newWorld;
lock( taskListLock ) {
// removes tasks associated with the old world
tasks.Remove( oldWorld.updateTaskId );
tasks.Remove( oldWorld.saveTaskId );
tasks.Remove( oldWorld.backupTaskId );
// if the new world was previously associated with some tasks, remove the old one, and reregister
tasks.Remove( newWorld.updateTaskId );
tasks.Remove( newWorld.saveTaskId );
tasks.Remove( newWorld.backupTaskId );
UpdateTaskListCache();
}
// adds tasks to the new world
newWorld.updateTaskId = AddTask( UpdateBlocks, Config.GetInt( ConfigKey.TickInterval ), newWorld );
if( Config.GetInt( ConfigKey.SaveInterval ) > 0 ) {
int saveInterval = Config.GetInt( ConfigKey.SaveInterval ) * 1000;
newWorld.saveTaskId = AddTask( SaveMap, saveInterval, newWorld, saveInterval );
}
if( Config.GetInt( ConfigKey.BackupInterval ) > 0 ) {
int backupInterval = Config.GetInt( ConfigKey.BackupInterval ) * 1000 * 60;
newWorld.backupTaskId = AddTask( AutoBackup, backupInterval, newWorld, (Config.GetBool( ConfigKey.BackupOnStartup ) ? 0 : backupInterval) );
}
return true;
}
}