Provides data for PlayerInfo.BeingCreated event. Cancelable. Allows changing StartingRank.
Inheritance: System.EventArgs, ICancelableEvent
示例#1
0
        public static PlayerInfo AddUnrecognizedPlayer( [NotNull] string name, RankChangeType rankChangeType ) {
            if( name == null ) throw new ArgumentNullException( "name" );
            CheckIfLoaded();

            PlayerInfo newInfo;
            using( GetWriteLock() ) {
                newInfo = provider.FindExact( name );
                if( newInfo != null ) {
                    throw new ArgumentException( "A PlayerDB entry already exists for this name.", "name" );
                }

                var e = new PlayerInfoBeingCreatedEventArgs( name, IPAddress.None, RankManager.DefaultRank, true );
                PlayerInfo.RaiseBeingCreatedEvent( e );
                if( e.Cancel ) {
                    throw new OperationCanceledException( "Canceled by a plugin." );
                }

                newInfo = provider.AddUnrecognizedPlayer( name, e.StartingRank, rankChangeType );
                newInfo.RaisePropertyChangedEvents = true;

                List.Add( newInfo );
            }
            PlayerInfo.RaiseCreatedEvent( newInfo, false );
            return newInfo;
        }
示例#2
0
        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;
            }
        }