fCraft.WorldCommands.BlockInfoSchedulerCallback C# (CSharp) Method

BlockInfoSchedulerCallback() static private method

static private BlockInfoSchedulerCallback ( SchedulerTask task ) : void
task SchedulerTask
return void
        static void BlockInfoSchedulerCallback( SchedulerTask task ) {
            BlockInfoLookupArgs args = (BlockInfoLookupArgs)task.UserState;
            if( !args.World.BlockDB.IsEnabled ) {
                args.Player.Message( "&WBlockDB is disabled in this world." );
                return;
            }
            BlockDBEntry[] results = args.World.BlockDB.Lookup( args.Coordinate );
            if( results.Length > 0 ) {
                int startIndex = Math.Max( 0, results.Length - MaxBlockChangesToList );
                for( int i = startIndex; i < results.Length; i++ ) {
                    BlockDBEntry entry = results[i];
                    string date = DateTime.UtcNow.Subtract( DateTimeUtil.ToDateTime( entry.Timestamp ) ).ToMiniString();

                    PlayerInfo info = PlayerDB.FindPlayerInfoByID( entry.PlayerID );
                    string playerName;
                    if( info == null ) {
                        playerName = "?";
                    } else {
                        Player target = info.PlayerObject;
                        if( target != null && args.Player.CanSee( target ) ) {
                            playerName = info.ClassyName;
                        } else {
                            playerName = info.ClassyName + "&S (offline)";
                        }
                    }
                    string contextString;
                    if( entry.Context == BlockChangeContext.Manual ) {
                        contextString = "";
                    } else if( (entry.Context & BlockChangeContext.Drawn) == BlockChangeContext.Drawn &&
                        entry.Context != BlockChangeContext.Drawn ) {
                        contextString = " (" + (entry.Context & ~BlockChangeContext.Drawn) + ")";
                    } else {
                        contextString = " (" + entry.Context + ")";
                    }

                    if( entry.OldBlock == (byte)Block.Air ) {
                        args.Player.Message( "&S  {0} ago: {1}&S placed {2}{3}",
                                             date, playerName, entry.NewBlock, contextString );
                    } else if( entry.NewBlock == (byte)Block.Air ) {
                        args.Player.Message( "&S  {0} ago: {1}&S deleted {2}{3}",
                                             date, playerName, entry.OldBlock, contextString );
                    } else {
                        args.Player.Message( "&S  {0} ago: {1}&S replaced {2} with {3}{4}",
                                             date, playerName, entry.OldBlock, entry.NewBlock, contextString );
                    }
                }
            } else {
                args.Player.Message( "BlockInfo: No results for {0}",
                                     args.Coordinate );
            }
        }

Same methods

WorldCommands::BlockInfoSchedulerCallback ( [ task ) : void