88using System . Collections . Generic ;
99using Rocket . API . Collections ;
1010using Rocket . API ;
11- using GlobalBan ;
1211
1312namespace PlayerInfoLibrary
1413{
@@ -24,9 +23,8 @@ protected override void Load()
2423 {
2524 Instance = this ;
2625 Database = new DatabaseManager ( ) ;
27- U . Events . OnPlayerConnected += Events_OnPlayerConnected ;
2826 U . Events . OnPlayerDisconnected += Events_OnPlayerDisconnected ;
29- // U.Events.OnBeforePlayerConnected += Events_OnBeforePlayerConnected;
27+ U . Events . OnBeforePlayerConnected += Events_OnBeforePlayerConnected ;
3028 if ( Instance . Configuration . Instance . KeepaliveInterval <= 0 )
3129 {
3230 Logger . LogWarning ( "Error: Keep alive config option must be above 0." ) ;
@@ -48,9 +46,8 @@ protected override void Load()
4846
4947 protected override void Unload ( )
5048 {
51- U . Events . OnPlayerConnected -= Events_OnPlayerConnected ;
5249 U . Events . OnPlayerDisconnected -= Events_OnPlayerDisconnected ;
53- // U.Events.OnBeforePlayerConnected -= Events_OnBeforePlayerConnected;
50+ U . Events . OnBeforePlayerConnected -= Events_OnBeforePlayerConnected ;
5451
5552 Database . Unload ( ) ;
5653 Database = null ;
@@ -81,40 +78,6 @@ private void Events_OnBeforePlayerConnected(UnturnedPlayer player)
8178 }
8279 }
8380
84- private void Events_OnPlayerConnected ( UnturnedPlayer player )
85- {
86- if ( player != null )
87- {
88- if ( LoginTime . ContainsKey ( player . CSteamID ) )
89- LoginTime . Remove ( player . CSteamID ) ;
90- LoginTime . Add ( player . CSteamID , DateTime . Now ) ;
91- PlayerData pData = Database . QueryById ( player . CSteamID , false ) ;
92- int totalTime = pData . TotalPlayime ;
93- DateTime loginTime = PlayerInfoLib . LoginTime [ player . CSteamID ] ;
94- pData = new PlayerData ( player . CSteamID , player . SteamName , player . CharacterName , player . CSteamID . GetIP ( ) , player . CSteamID . GetHWID ( ) , loginTime , Database . InstanceID , Provider . serverName , Database . InstanceID , loginTime , false , false , totalTime ) ;
95- Database . SaveToDB ( pData ) ;
96- // Recheck the ip address in the component, the ip isn't always fully set by the time this event is called.
97- PlayerInfoLibPComponent pc = player . GetComponent < PlayerInfoLibPComponent > ( ) ;
98- pc . Start ( pData ) ;
99- }
100-
101- PlayerInfoLib . ExecuteDependencyCode ( "GlobalBan" , ( IRocketPlugin plugin ) =>
102- {
103- if ( GlobalBan . GlobalBan . Instance . State == PluginState . Loaded )
104- {
105- if ( GlobalBan . GlobalBan . CheckIfBanned ( player ) )
106- {
107- if ( GlobalBan . GlobalBan . Instance . BannedReason . TryGetValue ( player , out string reason ) )
108- {
109- Provider . kick ( player . CSteamID , reason ) ;
110- GlobalBan . GlobalBan . Instance . BannedReason . Remove ( player ) ;
111-
112- }
113- }
114- }
115- } ) ;
116- }
117-
11881 private void Events_OnPlayerDisconnected ( UnturnedPlayer player )
11982 {
12083 if ( player != null )
0 commit comments