private Optional<Locale> loadFromFile(File localeFile) { try { return Optional.of(Locale.fromFile(localeFile)); } catch (IOException e) { logger.warn("Failed to read locale file at " + localeFile.getAbsolutePath() + ", " + e.toString()); logger.warn("Using Default Locale as a fallback (EN)"); } return Optional.empty(); }
private void cleanFolder() { long now = System.currentTimeMillis(); for (File file : Objects.requireNonNull(folder.listFiles())) { long forDaysMs = TimeUnit.DAYS.toMillis(config.get(PluginSettings.KEEP_LOGS_DAYS)); if (now - file.lastModified() > (forDaysMs > 0 ? forDaysMs : TimeUnit.DAYS.toMillis(1L))) { try { Files.delete(file.toPath()); } catch (IOException e) { logger.warn("Could not delete log file at: " + file.getAbsolutePath() + ", " + e.getMessage()); } } } } }
private Optional<Locale> loadSettingLocale() { try { String setting = config.get(PluginSettings.LOCALE); if (!"default".equalsIgnoreCase(setting)) { return Optional.of(Locale.forLangCodeString(plugin, setting)); } } catch (IOException e) { logger.warn("Failed to read locale from jar: " + config.get(PluginSettings.LOCALE) + ", " + e.toString()); logger.warn("Using Default Locale as a fallback (EN)"); } return Optional.empty(); }
} catch (Exception e) { if (inDevMode) { logger.warn("THIS ERROR IS ONLY LOGGED IN DEV MODE:"); errorHandler.log(L.WARN, this.getClass(), e);
@Override public void enable() throws EnableException { this.port = config.get(WebserverSettings.PORT); initServer(); if (!isEnabled()) { if (Check.isBungeeAvailable() || Check.isVelocityAvailable()) { throw new EnableException(locale.getString(PluginLang.ENABLE_FAIL_NO_WEB_SERVER_BUNGEE)); } if (config.isTrue(WebserverSettings.DISABLED)) { logger.warn(locale.getString(PluginLang.ENABLE_NOTIFY_WEB_SERVER_DISABLED)); } else { logger.error(locale.getString(PluginLang.WEB_SERVER_FAIL_PORT_BIND, port)); } } requestHandler.getResponseHandler().registerPages(); }