11package com .nextplugins .tasks ;
22
3+ import com .google .common .base .Stopwatch ;
34import com .nextplugins .tasks .command .registry .CommandRegistry ;
45import com .nextplugins .tasks .configuration .registry .ConfigurationRegistry ;
56import com .nextplugins .tasks .job .JobLoader ;
67import com .nextplugins .tasks .manager .TaskManager ;
78import com .nextplugins .tasks .metric .MetricsProvider ;
89import com .nextplugins .tasks .parser .TimeExpressionParser ;
910import lombok .Getter ;
11+ import lombok .val ;
1012import me .bristermitten .pdm .PluginDependencyManager ;
1113import org .bukkit .Bukkit ;
1214import org .bukkit .plugin .java .JavaPlugin ;
1315
16+ import java .util .logging .Level ;
17+
1418public final class NextTasks extends JavaPlugin {
1519
16- @ Getter private final TaskManager taskManager = new TaskManager ();
20+ @ Getter
21+ private final TaskManager taskManager = new TaskManager ();
1722 private final JobLoader jobLoader = new JobLoader (taskManager );
1823
1924 public static NextTasks getInstance () {
@@ -23,27 +28,51 @@ public static NextTasks getInstance() {
2328 @ Override
2429 public void onEnable () {
2530 saveDefaultConfig ();
26- PluginDependencyManager .of (this ).loadAllDependencies ().thenRun (() -> {
27- try {
28- ConfigurationRegistry .of (this ).register ();
31+ getLogger ().info ("Baixando e carregando dependências necessárias..." );
32+
33+ val downloadTime = Stopwatch .createStarted ();
34+
35+ PluginDependencyManager .of (this )
36+ .loadAllDependencies ()
37+ .exceptionally (throwable -> {
38+
39+ throwable .printStackTrace ();
2940
30- taskManager .loadTasks ();
41+ getLogger ().severe ("Ocorreu um erro durante a inicialização do plugin!" );
42+ Bukkit .getPluginManager ().disablePlugin (this );
3143
32- new TimeExpressionParser ( taskManager ). parse () ;
44+ return null ;
3345
34- jobLoader .executeAllJobs ();
46+ })
47+ .join ();
48+
49+ downloadTime .stop ();
50+
51+ getLogger ().log (Level .INFO , "Dependências carregadas com sucesso! ({0})" , downloadTime );
52+ getLogger ().info ("Iniciando carregamento do plugin." );
53+
54+ val loadTime = Stopwatch .createStarted ();
55+ try {
56+ ConfigurationRegistry .of (this ).register ();
3557
36- CommandRegistry . of ( this ). register ();
58+ taskManager . loadTasks ();
3759
38- MetricsProvider . of ( this ). configure ();
60+ new TimeExpressionParser ( taskManager ). parse ();
3961
40- getLogger ().info ("Plugin inicializado com sucesso." );
41- } catch (Throwable t ) {
42- t .printStackTrace ();
43- getLogger ().severe ("Ocorreu um erro durante a inicialização do plugin!" );
44- Bukkit .getPluginManager ().disablePlugin (this );
45- }
46- });
62+ jobLoader .executeAllJobs ();
63+
64+ CommandRegistry .of (this ).register ();
65+
66+ MetricsProvider .of (this ).configure ();
67+
68+ loadTime .stop ();
69+ getLogger ().log (Level .INFO , "Plugin inicializado com sucesso. ({0})" , loadTime );
70+
71+ } catch (Throwable t ) {
72+ t .printStackTrace ();
73+ getLogger ().severe ("Ocorreu um erro durante a inicialização do plugin!" );
74+ Bukkit .getPluginManager ().disablePlugin (this );
75+ }
4776 }
4877
4978 @ Override
0 commit comments