diff options
author | snowleo <schneeleo@gmail.com> | 2011-10-27 18:45:15 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-10-27 18:45:27 +0200 |
commit | 6c479fceedcbc4f44c740fa663a411ad09dde8ff (patch) | |
tree | af6d5f055e8168dba7fa54c9f5d9cae054d9b366 | |
parent | 04de66bc8aaa018b47a3193e37f8e34d1105f615 (diff) | |
download | Essentials-6c479fceedcbc4f44c740fa663a411ad09dde8ff.tar Essentials-6c479fceedcbc4f44c740fa663a411ad09dde8ff.tar.gz Essentials-6c479fceedcbc4f44c740fa663a411ad09dde8ff.tar.lz Essentials-6c479fceedcbc4f44c740fa663a411ad09dde8ff.tar.xz Essentials-6c479fceedcbc4f44c740fa663a411ad09dde8ff.zip |
Removing never used ErrorHandler and UpdateTimer from Essentials Core, they are now in EssentialsUpdate
5 files changed, 0 insertions, 247 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 27543dae3..1ad9a6893 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -33,7 +33,6 @@ import com.earth2me.essentials.register.payment.Methods; import com.earth2me.essentials.signs.SignBlockListener; import com.earth2me.essentials.signs.SignEntityListener; import com.earth2me.essentials.signs.SignPlayerListener; -import java.math.BigInteger; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.bukkit.command.PluginCommand; @@ -58,10 +57,7 @@ public class Essentials extends JavaPlugin implements IEssentials private transient List<IConf> confList; private transient Backup backup; private transient ItemDb itemDb; - private transient EssentialsUpdateTimer updateTimer; private transient final Methods paymentMethod = new Methods(); - private transient final static boolean enableErrorLogging = false; - private transient final EssentialsErrorHandler errorHandler = new EssentialsErrorHandler(); private transient PermissionsHandler permissionsHandler; private transient UserMap userMap; @@ -99,10 +95,6 @@ public class Essentials extends JavaPlugin implements IEssentials { LOGGER.log(Level.SEVERE, "Java version not supported! Please install Java 1.6. You have " + System.getProperty("java.version")); } - if (enableErrorLogging) - { - LOGGER.addHandler(errorHandler); - } final EssentialsUpgrade upgrade = new EssentialsUpgrade(this); upgrade.beforeSettings(); confList = new ArrayList<IConf>(); @@ -207,11 +199,6 @@ public class Essentials extends JavaPlugin implements IEssentials final EssentialsTimer timer = new EssentialsTimer(this); getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100); Economy.setEss(this); - if (getSettings().isUpdateEnabled()) - { - updateTimer = new EssentialsUpdateTimer(this); - getScheduler().scheduleAsyncRepeatingTask(this, updateTimer, 20 * 60 * 10, 20 * 3600 * 6); - } LOGGER.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), Util.joinList(this.getDescription().getAuthors()))); } @@ -219,7 +206,6 @@ public class Essentials extends JavaPlugin implements IEssentials public void onDisable() { Trade.closeLog(); - LOGGER.removeHandler(errorHandler); } @Override @@ -479,14 +465,6 @@ public class Essentials extends JavaPlugin implements IEssentials { LOGGER.log(logRecord); } - else - { - if (enableErrorLogging) - { - errorHandler.publish(logRecord); - errorHandler.flush(); - } - } } @Override @@ -629,11 +607,6 @@ public class Essentials extends JavaPlugin implements IEssentials return players.length; } - public Map<BigInteger, String> getErrors() - { - return errorHandler.getErrors(); - } - @Override public int scheduleAsyncDelayedTask(final Runnable run) { diff --git a/Essentials/src/com/earth2me/essentials/EssentialsErrorHandler.java b/Essentials/src/com/earth2me/essentials/EssentialsErrorHandler.java deleted file mode 100644 index 68dc5fbce..000000000 --- a/Essentials/src/com/earth2me/essentials/EssentialsErrorHandler.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.earth2me.essentials; - -import java.math.BigInteger; -import java.security.MessageDigest; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogRecord; - - -class EssentialsErrorHandler extends Handler -{ - private final Map<BigInteger, String> errors = new HashMap<BigInteger, String>(); - private final List<LogRecord> records = new LinkedList<LogRecord>(); - - public EssentialsErrorHandler() - { - } - - @Override - public void publish(LogRecord lr) - { - if (lr.getThrown() == null || lr.getLevel().intValue() < Level.WARNING.intValue()) - { - return; - } - synchronized (records) - { - records.add(lr); - } - } - - @Override - public void flush() - { - synchronized (records) - { - sortRecords(); - } - } - - @Override - public void close() throws SecurityException - { - synchronized (records) - { - sortRecords(); - } - } - - private void sortRecords() - { - for (LogRecord lr : records) - { - try - { - if (lr.getThrown() == null) - { - return; - } - Throwable tr = lr.getThrown(); - StackTraceElement[] elements = tr.getStackTrace(); - if (elements == null || elements.length <= 0) - { - return; - } - boolean essentialsFound = false; - for (StackTraceElement stackTraceElement : elements) - { - if (stackTraceElement.getClassName().contains("com.earth2me.essentials")) - { - essentialsFound = true; - break; - } - } - if (!essentialsFound && tr.getCause() != null) - { - Throwable cause = tr.getCause(); - StackTraceElement[] elements2 = cause.getStackTrace(); - if (elements2 != null) - { - for (StackTraceElement stackTraceElement : elements2) - { - if (stackTraceElement.getClassName().contains("com.earth2me.essentials")) - { - essentialsFound = true; - break; - } - } - } - } - StringBuilder sb = new StringBuilder(); - sb.append("[").append(lr.getLevel().getName()).append("] ").append(lr.getMessage()).append("\n"); - sb.append(tr.getMessage()).append("\n"); - for (StackTraceElement stackTraceElement : tr.getStackTrace()) - { - sb.append(stackTraceElement.toString()).append("\n"); - } - if (tr.getCause() != null && tr.getCause().getStackTrace() != null) - { - sb.append(tr.getCause().getMessage()).append("\n"); - for (StackTraceElement stackTraceElement : tr.getCause().getStackTrace()) - { - sb.append(stackTraceElement.toString()).append("\n"); - } - } - String errorReport = sb.toString(); - byte[] bytesOfMessage = errorReport.getBytes("UTF-8"); - MessageDigest md = MessageDigest.getInstance("MD5"); - BigInteger bi = new BigInteger(md.digest(bytesOfMessage)); - errors.put(bi, errorReport); - } - catch (Throwable t) - { - //Ignore all exceptions inside the exception handler - } - } - records.clear(); - } - - Map<BigInteger, String> getErrors() - { - return errors; - } -} diff --git a/Essentials/src/com/earth2me/essentials/EssentialsUpdateTimer.java b/Essentials/src/com/earth2me/essentials/EssentialsUpdateTimer.java deleted file mode 100644 index 6f7579d4e..000000000 --- a/Essentials/src/com/earth2me/essentials/EssentialsUpdateTimer.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.earth2me.essentials; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.bukkit.entity.Player; - - -class EssentialsUpdateTimer implements Runnable -{ - private transient URL url; - private final transient IEssentials ess; - private static final Logger LOGGER = Logger.getLogger("Minecraft"); - private final transient Pattern pattern = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*"); - - public EssentialsUpdateTimer(final IEssentials ess) - { - this.ess = ess; - try - { - url = new URL("http://essentialsupdate.appspot.com/check"); - } - catch (MalformedURLException ex) - { - LOGGER.log(Level.SEVERE, "Invalid url!", ex); - } - } - - @Override - public void run() - { - try - { - final StringBuilder builder = new StringBuilder(); - String bukkitVersion = ess.getServer().getVersion(); - final Matcher versionMatch = pattern.matcher(bukkitVersion); - if (versionMatch.matches()) - { - bukkitVersion = versionMatch.group(4); - } - builder.append("v=").append(URLEncoder.encode(ess.getDescription().getVersion(), "UTF-8")); - builder.append("&b=").append(URLEncoder.encode(bukkitVersion, "UTF-8")); - final URLConnection conn = url.openConnection(); - conn.setConnectTimeout(10000); - conn.setDoOutput(true); - conn.connect(); - final OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream()); - writer.write(builder.toString()); - writer.flush(); - final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); - final String ret = reader.readLine(); - writer.close(); - reader.close(); - if (!ret.isEmpty() && !ret.equalsIgnoreCase("OK")) - { - LOGGER.log(Level.INFO, "Essentials Update-Check: " + ret); - if (ret.startsWith("New Version")) - { - for (Player player : ess.getServer().getOnlinePlayers()) - { - final User user = ess.getUser(player); - if (user.isAuthorized("essentials.admin.notices.update")) - { - user.sendMessage(ret); - } - } - } - } - } - catch (IOException ex) - { - LOGGER.log(Level.SEVERE, "Failed to open connection", ex); - } - } -} diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index fa36ecc9f..7ffa0c138 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -129,8 +129,6 @@ public interface ISettings extends IConf boolean disableSuffix(); - boolean isUpdateEnabled(); - long getAutoAfk(); long getAutoAfkKick(); diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index 954e52542..ca076c272 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -510,12 +510,6 @@ public class Settings implements ISettings } @Override - public boolean isUpdateEnabled() - { - return config.getBoolean("update-check", false); - } - - @Override public long getAutoAfk() { return config.getLong("auto-afk", 300); |