/** * @param listeners Reload Listeners as well? * @param silent If silent is true, no notice of the reload will appear in the console. */ public void reload(boolean listeners, boolean silent) { if (listeners) Assigner.unregisterAll(); this.reloadConfig(); config = this.getConfigx(); load(); TRThread.reload(); // Stop TMetrics if the user disabled it in the config and reloaded. if (!config.getBoolean(ConfigFile.General, "UseTMetrics", true)) { tmetrics.stop(); } if (listeners) { Assigner.assign(); if (linkEEPatch()) Assigner.assignEEPatch(); } if (!silent) log.info("TekkitRestrict Reloaded!"); }
@Override public void onDisable() { disable = true; tmetrics.stop(); ttt.disableItemThread.interrupt(); ttt.entityRemoveThread.interrupt(); ttt.gemArmorThread.interrupt(); ttt.worldScrubThread.interrupt(); ttt.saveThread.interrupt(); // ttt.limitFlyThread.interrupt(); try { Thread.sleep(1500); } catch (InterruptedException e) { } // Sleep for 1.5 seconds to allow the savethread to save. TRLogger.saveLogs(); TRLogFilter.disable(); Log.deinit(); FileLog.closeAll(); log.info("TekkitRestrict v " + version.fullVer + " disabled!"); }
@Override public void onEnable() { ttt = new TRThread(); try { Assigner.assign(); // Register the required listeners } catch (Exception ex) { Warning.load("A severe error occurred: Unable to start listeners!", true); Log.Exception(ex, true); } TRSafeZone.init(); TRLimiter.init(); getCommand("tekkitrestrict").setExecutor(new TRCommandTR()); getCommand("openalc").setExecutor(new TRCommandAlc()); getCommand("tpic").setExecutor(new TRCommandTPIC()); getCommand("checklimits").setExecutor(new TRCommandCheck()); // determine if EE2 is enabled by using pluginmanager PluginManager pm = this.getServer().getPluginManager(); tekkitrestrict.EEEnabled = pm.isPluginEnabled("mod_EE"); try { if (pm.isPluginEnabled("PermissionsEx")) { TRPermHandler.permEx = ru.tehkode.permissions.bukkit.PermissionsEx.getPermissionManager(); log.info("PEX is enabled!"); } } catch (Exception ex) { log.info("Linking with Pex Failed!"); // Was not able to load permissionsEx } try { ttt.init(); } catch (Exception ex) { Warning.loadWarnings.add("An error occurred: Unable to start threads!"); Log.Exception(ex, true); } try { initHeartBeat(); } catch (Exception ex) { Warning.load("An error occurred: Unable to initiate Limiter Manager correctly!", false); Log.Exception(ex, false); } if (linkEEPatch()) { boolean success = true; try { Assigner.assignEEPatch(); } catch (Exception ex) { success = false; } if (success) log.info("Linked with EEPatch for extended functionality!"); else Warning.other("Linking with EEPatch Failed!", true); } else { log.info("EEPatch is not available. Extended EE integration disabled."); } Bukkit.getScheduler() .scheduleAsyncDelayedTask( this, new Runnable() { public void run() { if (config.getBoolean2(ConfigFile.General, "Auto-Update", true)) { // updater = new Updater_Old(this, "tekkit-restrict", this.getFile(), // Updater_Old.UpdateType.DEFAULT, true); updater2 = new Updater( tekkitrestrict.this, 44061, tekkitrestrict.this.getFile(), Updater.UpdateType.DEFAULT, true); } else if (config.getBoolean2( ConfigFile.General, "CheckForUpdateOnStartup", true)) { // updater = new Updater_Old(this, "tekkit-restrict", this.getFile(), // Updater_Old.UpdateType.NO_DOWNLOAD, true); updater2 = new Updater( tekkitrestrict.this, 44061, tekkitrestrict.this.getFile(), Updater.UpdateType.NO_DOWNLOAD, true); // if (updater.getResult() == UpdateResult.UPDATE_AVAILABLE) // log.info(ChatColor.GREEN + "There is an update available: " + // updater.getLatestVersionString() + ". Use /tr admin update ingame to update."); if (updater2.getResult() == Updater.UpdateResult.UPDATE_AVAILABLE) log.info( ChatColor.GREEN + "There is an update available: " + updater2.getLatestName() + ". Use /tr admin update ingame to update."); } } }); // ##################### Log Filter #################### if (config.getBoolean2(ConfigFile.Logging, "FilterLogs", true) || config.getBoolean2(ConfigFile.Logging, "SplitLogs", true)) { Enumeration<String> cc = LogManager.getLogManager().getLoggerNames(); filter = new TRLogFilter(); while (cc.hasMoreElements()) { Logger.getLogger(cc.nextElement()).setFilter(filter); } } // ##################################################### initMetrics(); tmetrics = new TMetrics(this, config.getBoolean2(ConfigFile.General, "ShowTMetricsWarnings", true)); if (config.getBoolean2(ConfigFile.General, "UseTMetrics", true)) { tmetrics.start(); } Bukkit.getScheduler() .scheduleSyncDelayedTask( this, new Runnable() { @Override public void run() { if (!Warning.loadWarnings.isEmpty()) { log.warning("There were some warnings while loading TekkitRestrict!"); log.warning( "Use /tr warnings load to view them again (in case you missed them)."); } else if (!Warning.dbWarnings.isEmpty()) { log.warning("There were some database warnings while loading TekkitRestrict!"); log.warning("Use /tr warnings db to view them again (in case you missed them)."); } } }); log.info("TekkitRestrict v" + version.fullVer + " Enabled!"); }