44import me .xginko .betterworldstats .config .Config ;
55import me .xginko .betterworldstats .config .LanguageCache ;
66import me .xginko .betterworldstats .hooks .BWSHook ;
7- import me .xginko .betterworldstats .utils .KyoriUtil ;
7+ import me .xginko .betterworldstats .utils .Util ;
8+ import net .kyori .adventure .identity .Identity ;
89import net .kyori .adventure .platform .bukkit .BukkitAudiences ;
910import net .kyori .adventure .text .Component ;
1011import net .kyori .adventure .text .logger .slf4j .ComponentLogger ;
@@ -36,41 +37,37 @@ public final class BetterWorldStats extends JavaPlugin {
3637 @ Override
3738 public void onEnable () {
3839 instance = this ;
39- audiences = BukkitAudiences .create (this );
40+ audiences = BukkitAudiences .create (instance );
4041 logger = ComponentLogger .logger (getLogger ().getName ());
41- bStats = new Metrics (this , 17204 );
42-
43- logger .info (Component .text (" " ).style (KyoriUtil .GUPPIE_GREEN_BOLD ));
44- logger .info (Component .text (" ___ _ _ " ).style (KyoriUtil .GUPPIE_GREEN_BOLD ));
45- logger .info (Component .text (" | _ ) ___| |_| |_ ___ _ _ " ).style (KyoriUtil .GUPPIE_GREEN_BOLD ));
46- logger .info (Component .text (" | _ \\ / -_) _| _/ -_) '_| " ).style (KyoriUtil .GUPPIE_GREEN_BOLD ));
47- logger .info (Component .text (" __|___/\\ ___|\\ __|\\ __\\ ___|_|_ _ _ " ).style (KyoriUtil .GUPPIE_GREEN_BOLD ));
48- logger .info (Component .text (" \\ \\ / /__ _ _| |__| / __| |_ __ _| |_ ___" ).style (KyoriUtil .GUPPIE_GREEN_BOLD ));
49- logger .info (Component .text (" \\ \\ /\\ / / _ \\ '_| / _` \\ __ \\ _/ _` | _(_-<" ).style (KyoriUtil .GUPPIE_GREEN_BOLD ));
50- logger .info (Component .text (" \\ _/\\ _/\\ ___/_| |_\\ __,_|___/\\ __\\ __,_|\\ __/__/" ).style (KyoriUtil .GUPPIE_GREEN_BOLD ));
51- logger .info (Component .text (" " ).style (KyoriUtil .GUPPIE_GREEN_BOLD ));
52-
53- try {
54- getDataFolder ().mkdirs ();
55- } catch (Throwable t ) {
56- logger .error ("Failed to create plugin folder!" , t );
57- getServer ().getPluginManager ().disablePlugin (this );
58- }
59-
60- logger .info ("Loading languages" );
42+ bStats = new Metrics (instance , 17204 );
43+
44+ logger .info (Component .text (" " ).style (Util .GUPPIE_GREEN_BOLD ));
45+ logger .info (Component .text (" ___ _ _ " ).style (Util .GUPPIE_GREEN_BOLD ));
46+ logger .info (Component .text (" | _ ) ___| |_| |_ ___ _ _ " ).style (Util .GUPPIE_GREEN_BOLD ));
47+ logger .info (Component .text (" | _ \\ / -_) _| _/ -_) '_| " ).style (Util .GUPPIE_GREEN_BOLD ));
48+ logger .info (Component .text (" __|___/\\ ___|\\ __|\\ __\\ ___|_|_ _ _ " ).style (Util .GUPPIE_GREEN_BOLD ));
49+ logger .info (Component .text (" \\ \\ / /__ _ _| |__| / __| |_ __ _| |_ ___" ).style (Util .GUPPIE_GREEN_BOLD ));
50+ logger .info (Component .text (" \\ \\ /\\ / / _ \\ '_| / _` \\ __ \\ _/ _` | _(_-<" ).style (Util .GUPPIE_GREEN_BOLD ));
51+ logger .info (Component .text (" \\ _/\\ _/\\ ___/_| |_\\ __,_|___/\\ __\\ __,_|\\ __/__/" ).style (Util .GUPPIE_GREEN_BOLD ));
52+ logger .info (Component .text (" " ).style (Util .GUPPIE_GREEN_BOLD ));
53+
54+ logger .info ("Loading translations" );
6155 reloadLang ();
56+
6257 logger .info ("Loading config" );
6358 reloadConfiguration ();
59+
6460 logger .info ("Registering commands" );
6561 BWSCmd .reloadCommands ();
62+
6663 logger .info ("Done." );
6764 }
6865
6966 @ Override
7067 public void onDisable () {
7168 BWSHook .HOOKS .forEach (BWSHook ::unHook );
7269 if (statistics != null ) {
73- statistics .shutdown ();
70+ statistics .disable ();
7471 statistics = null ;
7572 }
7673 if (audiences != null ) {
@@ -91,19 +88,19 @@ public void onDisable() {
9188 return instance ;
9289 }
9390
94- public static @ NotNull Statistics getStatistics () {
91+ public static @ NotNull Statistics statistics () {
9592 return statistics ;
9693 }
9794
98- public static @ NotNull BukkitAudiences getAudiences () {
95+ public static @ NotNull BukkitAudiences audiences () {
9996 return audiences ;
10097 }
10198
102- public static @ NotNull Config getConfiguration () {
99+ public static @ NotNull Config config () {
103100 return config ;
104101 }
105102
106- public static @ NotNull ComponentLogger getLog () {
103+ public static @ NotNull ComponentLogger logger () {
107104 return logger ;
108105 }
109106
@@ -112,7 +109,7 @@ public void onDisable() {
112109 }
113110
114111 public static @ NotNull LanguageCache getLang (CommandSender commandSender ) {
115- return getLang (KyoriUtil . getLocale (commandSender ));
112+ return getLang (audiences . sender (commandSender ). pointers (). get ( Identity . LOCALE ). orElse ( config . default_lang ));
116113 }
117114
118115 public static @ NotNull LanguageCache getLang (String lang ) {
@@ -129,7 +126,7 @@ public void reloadPlugin() {
129126 private void reloadConfiguration () {
130127 try {
131128 if (statistics != null )
132- statistics .shutdown ();
129+ statistics .disable ();
133130 config = new Config ();
134131 statistics = new Statistics ();
135132 BWSHook .reloadHooks ();
@@ -143,7 +140,7 @@ public void reloadLang() {
143140 languageCacheMap = new HashMap <>();
144141 try {
145142 for (String localeString : getAvailableTranslations ()) {
146- logger .info ("Found language file for " + localeString );
143+ logger .info ("Found language file for {}" , localeString );
147144 languageCacheMap .put (localeString , new LanguageCache (localeString ));
148145 }
149146 } catch (Throwable t ) {
@@ -153,7 +150,7 @@ public void reloadLang() {
153150 logger .error ("Unable to load translations. Disabling." );
154151 getServer ().getPluginManager ().disablePlugin (this );
155152 } else {
156- logger .info ("Loaded " + languageCacheMap .size () + " translations" );
153+ logger .info ("Loaded {} translations" , languageCacheMap .size ());
157154 }
158155 }
159156 }
0 commit comments