33import com .earthpol .earthPolLib .logging .EnhancedLogger ;
44import com .earthpol .earthPolLib .logging .LogRetentionPolicy ;
55import com .earthpol .earthPolLib .logging .LogRetentionTask ;
6+ import com .earthpol .earthPolLib .translation .TranslationService ;
67import com .earthpol .foliacore .commands .*;
78import com .earthpol .foliacore .config .ConfigManager ;
89import com .earthpol .foliacore .config .ConfigNodes ;
1112import com .earthpol .foliacore .session .QuickLoginTracker ;
1213import com .earthpol .foliacore .util .ColorManager ;
1314import com .earthpol .foliacore .util .HonorPointsManager ;
15+ import com .earthpol .earthPolLib .translation .Translations ;
1416import com .earthpol .foliacore .util .PlayerDataManager ;
1517import com .earthpol .foliacore .util .UniqueCounter ;
1618import com .palmergames .bukkit .towny .TownyAPI ;
@@ -47,11 +49,14 @@ public final class FoliaCore extends JavaPlugin {
4749 private static Logger log = Bukkit .getLogger ();
4850 public static final String PREFIX = "" ;
4951 public static final String DISCORD = "https://discord.gg/epmc" ;
52+ private TranslationService translationService ;
5053
5154 public static FoliaCore getInstance () {
5255 return instance ;
5356 }
5457 public static ConfigManager getConfigManager () {return instance .cfgMgr ;}
58+ public static TranslationService translations () {return instance .translationService ;}
59+ public TranslationService getTranslationService () {return translationService ;}
5560 private HikariDataSource discordDataSource ;
5661
5762 //logging
@@ -86,9 +91,13 @@ public static File getPlayerDataFolder() {
8691 @ Override
8792 public void onEnable () {
8893 instance = this ;
94+ // Initialize logger early so bootstrap/config code can log safely.
95+ logger = EnhancedLogger .create (this , "FoliaCore" , false );
8996 cfgMgr = new ConfigManager (this );
9097 playerDataManager = new PlayerDataManager (instance );
9198 cfgMgr .loadAndMigrate ();
99+ translationService = new TranslationService (this , FoliaCore .class );
100+ translationService .load ();
92101
93102 isDebug = cfgMgr .getBoolean (ConfigNodes .DEBUG );
94103 prefix = cfgMgr .getString (ConfigNodes .MSG_PREFIX );
@@ -260,25 +269,25 @@ private void setupCommands() {
260269 getCommand ("premium" ).setExecutor (new PremiumCommand ());
261270 getCommand ("store" ).setExecutor (new PremiumCommand ());
262271 getCommand ("shop" ).setExecutor (new PremiumCommand ());
263- TransportationCommand transportationCommand = new TransportationCommand (cfgMgr );
272+ TransportationCommand transportationCommand = new TransportationCommand ();
264273 getCommand ("boat" ).setExecutor (transportationCommand );
265274 getCommand ("cart" ).setExecutor (transportationCommand );
266275 if (isLuckPermsOn ){
267276 getCommand ("staffmode" ).setExecutor (new StaffModeCommand (luckPerms ));
268277 }
269278 getCommand ("namemckit" ).setExecutor (new NameMCKitCommand (cfgMgr ));
270- getCommand ("docs" ).setExecutor (new ComponentCommand (clickableMessage ("online docs" , cfgMgr . getString ( ConfigNodes . MSG_DOCS ))));
271- getCommand ("guide" ).setExecutor (new ComponentCommand (clickableMessage ("online guide" , cfgMgr . getString ( ConfigNodes . MSG_GUIDE_LINK2 ))));
272- getCommand ("support" ).setExecutor (new ComponentCommand (clickableMessage (" support discord " , cfgMgr . getString ( ConfigNodes . MSG_SUPPORT ))));
273- getCommand ("wiki" ).setExecutor (new ComponentCommand (clickableMessage ("online wiki" , cfgMgr . getString ( ConfigNodes . MSG_WIKI ))));
274- getCommand ("recipes" ).setExecutor (new ComponentCommand (clickableMessage ("recipe page" , cfgMgr . getString ( ConfigNodes . MSG_RECIPE ))));
275- getCommand ("rules" ).setExecutor (new ComponentCommand (clickableMessage (" rules page " , cfgMgr . getString ( ConfigNodes . MSG_RULES_LINK2 ))));
276-
277- getCommand ("insights" ).setExecutor (new ComponentCommand (clickableMessage (" EarthPol Observatory" , "https://earthpol.org/" )));
278- getCommand ("shops" ).setExecutor (new ComponentCommand (clickableMessage (" EarthPol Observatory Shop Page" , "https://earthpol.org/ shops" )));
279- getCommand ("players" ).setExecutor (new ComponentCommand (clickableMessage (" EarthPol Observatory Players Page" , "https://earthpol.org/ players" )));
280- getCommand ("towns" ).setExecutor (new ComponentCommand (clickableMessage (" EarthPol Observatory Towns Page" , "https://earthpol.org/ towns" )));
281- getCommand ("nations" ).setExecutor (new ComponentCommand (clickableMessage (" EarthPol Observatory Nations Page" , "https://earthpol.org/ nations" )));
279+ getCommand ("docs" ).setExecutor (new ComponentCommand (sender -> clickableMessage (sender , "links. docs.description " , Translations . raw ( com . earthpol . foliacore . FoliaCore . translations (), sender , "links.docs.url" ))));
280+ getCommand ("guide" ).setExecutor (new ComponentCommand (sender -> clickableMessage (sender , "links. guide.description " , Translations . raw ( com . earthpol . foliacore . FoliaCore . translations (), sender , "links.guide.url" ))));
281+ getCommand ("support" ).setExecutor (new ComponentCommand (sender -> clickableMessage (sender , "links. support.description " , Translations . raw ( com . earthpol . foliacore . FoliaCore . translations (), sender , "links.support.url" ))));
282+ getCommand ("wiki" ).setExecutor (new ComponentCommand (sender -> clickableMessage (sender , "links. wiki.description " , Translations . raw ( com . earthpol . foliacore . FoliaCore . translations (), sender , "links.wiki.url" ))));
283+ getCommand ("recipes" ).setExecutor (new ComponentCommand (sender -> clickableMessage (sender , "links.recipes.description" , Translations . raw ( com . earthpol . foliacore . FoliaCore . translations (), sender , "links.recipes.url" ))));
284+ getCommand ("rules" ).setExecutor (new ComponentCommand (sender -> clickableMessage (sender , "links. rules.description " , Translations . raw ( com . earthpol . foliacore . FoliaCore . translations (), sender , "links.rules.url" ))));
285+
286+ getCommand ("insights" ).setExecutor (new ComponentCommand (sender -> clickableMessage (sender , "links.insights.description" , Translations . raw ( com . earthpol . foliacore . FoliaCore . translations (), sender , "links.insights.url" ) )));
287+ getCommand ("shops" ).setExecutor (new ComponentCommand (sender -> clickableMessage (sender , "links.shops.description" , Translations . raw ( com . earthpol . foliacore . FoliaCore . translations (), sender , "links. shops.url" ) )));
288+ getCommand ("players" ).setExecutor (new ComponentCommand (sender -> clickableMessage (sender , "links.players.description" , Translations . raw ( com . earthpol . foliacore . FoliaCore . translations (), sender , "links. players.url" ) )));
289+ getCommand ("towns" ).setExecutor (new ComponentCommand (sender -> clickableMessage (sender , "links.towns.description" , Translations . raw ( com . earthpol . foliacore . FoliaCore . translations (), sender , "links. towns.url" ) )));
290+ getCommand ("nations" ).setExecutor (new ComponentCommand (sender -> clickableMessage (sender , "links.nations.description" , Translations . raw ( com . earthpol . foliacore . FoliaCore . translations (), sender , "links. nations.url" ) )));
282291
283292 getCommand ("distance" ).setExecutor (new DistanceCommand ());
284293 getCommand ("distance" ).setTabCompleter (new DistanceCommand ());
@@ -300,8 +309,11 @@ private void setupCommands() {
300309 getCommand ("reactclaim" ).setExecutor (new ReactClaimCommand (this ));
301310 }
302311
303- private Component clickableMessage (String description , String url ) {
304- return Component .text ("Click here for a link to the " + description + "." , NamedTextColor .GREEN ).clickEvent (ClickEvent .openUrl (url )).hoverEvent (HoverEvent .showText (Component .text ("Click me to open!" , NamedTextColor .GREEN )));
312+ private Component clickableMessage (org .bukkit .command .CommandSender sender , String descriptionKey , String url ) {
313+ return Component .text (
314+ Translations .text (com .earthpol .foliacore .FoliaCore .translations (), sender , "links.command.body" , Translations .raw (com .earthpol .foliacore .FoliaCore .translations (), sender , descriptionKey )),
315+ NamedTextColor .GREEN
316+ ).clickEvent (ClickEvent .openUrl (url )).hoverEvent (HoverEvent .showText (Component .text (Translations .text (com .earthpol .foliacore .FoliaCore .translations (), sender , "links.command.hover" ), NamedTextColor .GREEN )));
305317 }
306318
307319 public ColorManager getColorManager () {
@@ -323,8 +335,13 @@ public PlayerDataManager getPlayerDataManager() {
323335
324336 @ Override
325337 public void onDisable () {
326- log ().debug (prefix + "Shutting down FoliaCore" );
327- log ().debug (prefix + "Saving Honor Point Data" );
338+ if (logger != null ) {
339+ log ().debug (prefix + "Shutting down FoliaCore" );
340+ log ().debug (prefix + "Saving Honor Point Data" );
341+ } else {
342+ getLogger ().info ("Shutting down FoliaCore" );
343+ getLogger ().info ("Saving Honor Point Data" );
344+ }
328345 if (honorMgr != null )
329346 honorMgr .saveAll ();
330347 if (discordDataSource != null ) {
0 commit comments