@Override public void addNewTPSEntry(long nanoTime, long now) { long diff = nanoTime - lastCheckNano; lastCheckNano = nanoTime; if (diff > nanoTime) { // First run's diff = nanoTime + 1, no calc possible. logger.debug("First run of TPSCountTimer Task."); return; } history.add(calculateTPS(now)); }
private Connection getConnectionFor(String dbFilePath) throws SQLException { try { return DriverManager.getConnection("jdbc:sqlite:" + dbFilePath + "?journal_mode=WAL"); } catch (SQLException ignored) { logger.info(locale.getString(PluginLang.DB_NOTIFY_SQLITE_WAL)); return DriverManager.getConnection("jdbc:sqlite:" + dbFilePath); } }
private void checkIfDefaultIP() throws EnableException { String ip = serverProperties.getIp(); if ("0.0.0.0".equals(ip)) { logger.error("IP setting still 0.0.0.0 - Configure AlternativeIP/IP that connects to the Proxy server."); logger.info("Player Analytics partially enabled (Use /planbungee to reload config)"); throw new EnableException("IP setting still 0.0.0.0 - Configure AlternativeIP/IP that connects to the Proxy server."); } }
@Override public void enable() { try { bridge.hook(this); } catch (Exception e) { errorHandler.log(L.ERROR, this.getClass(), e); logger.error("Plan Plugin Bridge not included in the plugin jar."); } }
public static PlanColorScheme create(PlanConfig config, PluginLogger logger) { try { String main = "§" + config.get(DisplaySettings.CMD_COLOR_MAIN).charAt(1); String secondary = "§" + config.get(DisplaySettings.CMD_COLOR_SECONDARY).charAt(1); String tertiary = "§" + config.get(DisplaySettings.CMD_COLOR_TERTIARY).charAt(1); return new PlanColorScheme(main, secondary, tertiary); } catch (Exception e) { logger.log(L.INFO_COLOR, "§cCustomization, Chat colors set-up wrong, using defaults."); return new PlanColorScheme("§2", "§7", "§f"); } }
private void checkIfDefaultIP() throws EnableException { String ip = serverProperties.getIp(); if ("0.0.0.0".equals(ip)) { logger.error("IP setting still 0.0.0.0 - Configure AlternativeIP/IP that connects to the Proxy server."); logger.info("Player Analytics partially enabled (Use /planbungee to reload config)"); throw new EnableException("IP setting still 0.0.0.0 - Configure AlternativeIP/IP that connects to the Proxy server."); } }
/** * Shuts down the server - Async thread is closed with shutdown boolean. */ @Override public void disable() { if (server != null) { shutdown(); logger.info(locale.getString(PluginLang.DISABLED_WEB_SERVER)); } enabled = false; }
private void resetWriteConfigSetting() { try { config.set(PluginSettings.WRITE_NEW_LOCALE, false); config.save(); } catch (IOException | IllegalStateException e) { logger.error("Failed set WriteNewLocaleFileOnEnable back to false"); errorHandler.log(L.WARN, this.getClass(), e); } }
@Override public void addNewTPSEntry(long nanoTime, long now) { long diff = nanoTime - lastCheckNano; lastCheckNano = nanoTime; if (diff > nanoTime) { // First run's diff = nanoTime + 1, no calc possible. logger.debug("First run of TPSCountTimer Task."); return; } history.add(calculateTPS(diff, now)); }
@Override public void onDisable() { if (system != null) system.disable(); logger.info(locale.getString(PluginLang.DISABLED)); }
private String getColor(ThemeVal variable) { String path = variable.getThemePath(); try { String value = themeConfig.getString(path); if (value.contains(".")) { return "url(\"" + value + "\")"; } else { return value; } } catch (Exception | NoSuchFieldError e) { logger.error("Something went wrong with getting variable " + variable.name() + " for: " + path); } return variable.getDefaultValue(); }
public Connection getNewConnection(File dbFile) throws SQLException { String dbFilePath = dbFile.getAbsolutePath(); Connection newConnection = getConnectionFor(dbFilePath); logger.debug("H2 " + dbName + ": Opened a new Connection"); newConnection.setAutoCommit(false); return newConnection; }
@Override public void onDisable() { if (system != null) { system.disable(); } logger.info(locale.getString(PluginLang.DISABLED)); }
@Override public void enable() { watcher = prepareFileWatcher(); watcher.start(); logger.debug("Server Settings folder FileWatcher started."); scheduleDBCheckTask(); }
@Override public void onDisable() { system.disable(); logger.info(locale.getString(PluginLang.DISABLED)); }
@Override public void close() { super.close(); stopConnectionPingTask(); if (connection != null) { logger.debug("H2DB " + dbName + ": Closed Connection"); MiscUtils.close(connection); } }
@Override protected void copyDefaults() throws IOException { super.copyDefaults(); if (firstInstall) { logger.info("§eWebServer and Geolocations disabled by default on Sponge servers. You can enable them in the config:"); logger.info("§e " + WebserverSettings.DISABLED.getPath()); logger.info("§e " + DataGatheringSettings.GEOLOCATIONS.getPath()); config.set(WebserverSettings.DISABLED, true); config.set(DataGatheringSettings.GEOLOCATIONS, false); config.save(); } } }
@Override public void close() { super.close(); stopConnectionPingTask(); if (connection != null) { logger.debug("SQLite " + dbName + ": Closed Connection"); MiscUtils.close(connection); } }
/** * Disables the plugin. */ @Override public void onDisable() { if (system != null) { system.disable(); } logger.info(locale != null ? locale.getString(PluginLang.DISABLED) : PluginLang.DISABLED.getDefault()); }
@Override public void enable() throws EnableException { serverSettingsFolder = createServerSettingsFolder(); watcher = prepareFileWatcher(); watcher.start(); logger.debug("Server Settings folder FileWatcher started."); scheduleDBCheckTask(); }