Esempio n. 1
0
        public static PlayerInfo AddFakeEntry( string name, RankChangeType rankChangeType ) {
            if( name == null ) throw new ArgumentNullException( "name" );

            PlayerInfo info;
            lock( AddLocker ) {
                info = Trie.Get( name );
                if( info != null ) throw new ArgumentException( "A PlayerDB entry already exists for this name." );

                var e = new PlayerInfoCreatingEventArgs( name, IPAddress.None, RankManager.DefaultRank, true );
                Server.RaisePlayerInfoCreatingEvent( e );
                if( e.Cancel ) throw new OperationCanceledException( "Cancelled by a plugin." );

                info = new PlayerInfo( name, e.StartingRank, false, rankChangeType );

                List.Add( info );
                Trie.Add( info.Name, info );
                UpdateCache();
            }
            Server.RaisePlayerInfoCreatedEvent( info, false );
            return info;
        }
Esempio n. 2
0
 internal static void RaisePlayerInfoCreatingEvent( PlayerInfoCreatingEventArgs e ) {
     var h = PlayerInfoCreating;
     if( h != null ) h( null, e );
 }
Esempio n. 3
0
        public static PlayerInfo FindOrCreateInfoForPlayer( string name, IPAddress lastIP ) {
            if( name == null ) throw new ArgumentNullException( "name" );
            PlayerInfo info;

            // this flag is used to avoid executing PlayerInfoCreated event in the lock
            bool raiseCreatedEvent = false;

            lock( AddLocker ) {
                info = Trie.Get( name );
                if( info == null ) {
                    var e = new PlayerInfoCreatingEventArgs( name, lastIP, RankManager.DefaultRank, false );
                    Server.RaisePlayerInfoCreatingEvent( e );
                    if( e.Cancel ) throw new OperationCanceledException( "Cancelled by a plugin." );

                    info = new PlayerInfo( name, lastIP, e.StartingRank );
                    Trie.Add( name, info );
                    List.Add( info );
                    UpdateCache();

                    raiseCreatedEvent = true;
                }
            }

            if( raiseCreatedEvent ) {
                Server.RaisePlayerInfoCreatedEvent( info, false );
            }
            return info;
        }