fCraft.PlayerDB.FindOrCreateInfoForPlayer C# (CSharp) Method

FindOrCreateInfoForPlayer() private method

private FindOrCreateInfoForPlayer ( [ name, [ lastIP ) : PlayerInfo
name [
lastIP [
return PlayerInfo
        public static PlayerInfo FindOrCreateInfoForPlayer( [NotNull] string name, [NotNull] IPAddress lastIP ) {
            if( name == null ) throw new ArgumentNullException( "name" );
            if( lastIP == null ) throw new ArgumentNullException( "lastIP" );
            CheckIfLoaded();
            using( GetUpgradableReadLock() ) {
                PlayerInfo info = provider.FindExact( name );
                if( info == null ) {
                    using( GetWriteLock() ) {
                        var e = new PlayerInfoBeingCreatedEventArgs( name, lastIP, RankManager.DefaultRank, false );
                        PlayerInfo.RaiseBeingCreatedEvent( e );
                        if( e.Cancel ) throw new OperationCanceledException( "Canceled by a plugin." );

                        info = provider.AddPlayer( name, e.StartingRank, RankChangeType.Default, lastIP );
                        info.RaisePropertyChangedEvents = true;
                        List.Add( info );
                        PlayerInfo.RaiseCreatedEvent( info, false );
                    }
                }

                return info;
            }
        }

Same methods

PlayerDB::FindOrCreateInfoForPlayer ( string name, IPAddress lastIP ) : PlayerInfo

Usage Example

Example #1
0
 // Normal constructor
 internal Player(World world, string name, Session session, Position position)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     if (session == null)
     {
         throw new ArgumentNullException("session");
     }
     World        = world;
     Session      = session;
     Position     = position;
     Info         = PlayerDB.FindOrCreateInfoForPlayer(name, session.IP);
     spamBlockLog = new Queue <DateTime>(Info.Rank.AntiGriefBlocks);
     ResetAllBinds();
 }