11using EffectDisplay . EventHandler ;
22using EffectDisplay . Features ;
33using Exiled . API . Features ;
4- using Exiled . API . Features . Core . UserSettings ;
5- using Exiled . Loader ;
64
7- using MEC ;
85using System ;
96using System . IO ;
10- using System . Linq ;
117using System . Threading . Tasks ;
128
13- using UnityEngine ;
14-
159namespace EffectDisplay
1610{
1711 public class Plugin : Plugin < Configs >
@@ -20,7 +14,7 @@ public class Plugin : Plugin<Configs>
2014
2115 public override string Name { get ; } = "EffectDisplay" ;
2216
23- public override Version Version { get ; } = new Version ( 2 , 6 , 0 ) ;
17+ public override Version Version { get ; } = new Version ( 2 , 8 , 0 ) ;
2418
2519 public override Version RequiredExiledVersion { get ; } = new Version ( 9 , 0 , 0 ) ;
2620
@@ -41,23 +35,20 @@ public override void OnEnabled()
4135 DBCondition ( ) ;
4236 Instance = this ;
4337 iUpdater = new GithubUpdater ( "NOTIF-API" , "EffectDisplay" ) ;
44- // if not delayed exception called
45- Timing . CallDelayed ( 0.5f , ( ) => {
46- data = new DataBase ( ) ;
47- } ) ;
38+ data = new DataBase ( ) ;
4839 Event = new PlayerEvent ( ) ;
4940 SubscribeEvents ( ) ;
5041 base . OnEnabled ( ) ;
51- // for no stack when enabling
42+ // Background update task.
5243 Task . Run ( ( ) =>
5344 {
5445 Version latest = iUpdater . Version ;
5546 if ( latest == null || latest == new Version ( 0 , 0 , 0 ) ) return ;
47+ Log . Debug ( $ "Current version: [{ this . Version . ToString ( ) } ] latest version detected is { latest . ToString ( ) } ") ;
5648 if ( Version >= latest ) return ;
5749 Log . Warn ( "New version of EffectDisplay plugin found" ) ;
5850 } ) ;
5951 }
60-
6152 public override void OnDisabled ( )
6253 {
6354 iUpdater = null ;
@@ -74,39 +65,21 @@ protected void SubscribeEvents()
7465 {
7566 Log . Debug ( $ "{ nameof ( SubscribeEvents ) } : Subscribe to the event.") ;
7667 Exiled . Events . Handlers . Player . Verified += Event . OnVerefied ;
77- Exiled . Events . Handlers . Server . WaitingForPlayers += OnWaitingForPlayers ;
78- }
79- /// <summary>
80- /// needed to check the presence of third-party plugins after they are fully loaded.
81- /// Also to notify about new updates.
82- /// </summary>
83- private void OnWaitingForPlayers ( )
84- {
85- if ( Config . ThirdParty )
86- {
87- if ( Loader . Plugins . Where ( x => x . Name == "HintServiceMeow" ) . FirstOrDefault ( ) != null )
88- {
89- HintServiceMeowDetected = true ;
90- Log . Info ( $ "{ nameof ( OnWaitingForPlayers ) } : A third-party provider has been detected. The Hint plugin will be adjusted to work with it automatically.") ;
91- Log . Info ( $ "{ nameof ( OnWaitingForPlayers ) } : When testing finded bug with broken chars displaying.") ;
92- }
93- }
9468 }
9569
9670 protected void UnsubscribeEvents ( )
9771 {
9872 Log . Debug ( $ "{ nameof ( UnsubscribeEvents ) } : Unsubscribe from events.") ;
9973 Exiled . Events . Handlers . Player . Verified -= Event . OnVerefied ;
100- Exiled . Events . Handlers . Server . WaitingForPlayers -= OnWaitingForPlayers ;
10174 }
10275 /// <summary>
10376 /// Checks whether the conditions for working with the database are satisfied and restores missing files if necessary
10477 /// </summary>
10578 private void DBCondition ( )
10679 {
107- if ( ! this . Config . IsDatabaseUse )
80+ if ( ! this . Config . DataBaseEnabled )
10881 {
109- Log . Warn ( $ "{ nameof ( DBCondition ) } : DB usage is disabled by configuration. ") ;
82+ Log . Warn ( $ "{ nameof ( DBCondition ) } : Database usage has been disabled in the plugin configuration! ") ;
11083 return ;
11184 }
11285 else
@@ -115,15 +88,15 @@ private void DBCondition()
11588 // if folder do not detected creating it with file
11689 if ( ! Directory . Exists ( this . Config . PathToDataBase ) )
11790 {
91+ Log . Warn ( $ "{ nameof ( DBCondition ) } : The directory with the database from EffectDisplay was not found, we are creating a directory and a file.") ;
11892 Directory . CreateDirectory ( this . Config . PathToDataBase ) ;
119- File . Create ( file_path ) ;
120- Log . Warn ( $ "{ nameof ( DBCondition ) } : The directory with the database file is missing.") ;
93+ File . Create ( file_path ) . Close ( ) ;
12194 return ;
12295 }
12396 if ( ! File . Exists ( file_path ) )
12497 {
125- Log . Warn ( $ "{ nameof ( DBCondition ) } : DB file is missing .") ;
126- File . Create ( file_path ) ;
98+ Log . Warn ( $ "{ nameof ( DBCondition ) } : The database file was not found .") ;
99+ File . Create ( file_path ) . Close ( ) ;
127100 }
128101 }
129102 }
0 commit comments