Archiviert
13
0

Log the plugin version too.

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2012-11-19 23:27:04 +01:00
Ursprung c2209138fe
Commit cdc5740f85
2 geänderte Dateien mit 22 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -90,7 +90,7 @@ public class ProtocolLibrary extends JavaPlugin {
logger = getLoggerSafely();
// Add global parameters
DetailedErrorReporter reporter = new DetailedErrorReporter();
DetailedErrorReporter reporter = new DetailedErrorReporter(this);
updater = new Updater(this, logger, "protocollib", getFile(), "protocol.info");
try {

Datei anzeigen

@ -2,6 +2,7 @@ package com.comphenix.protocol.error;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@ -40,6 +41,8 @@ public class DetailedErrorReporter implements ErrorReporter {
protected int errorCount;
protected int maxErrorCount;
protected Logger logger;
protected WeakReference<Plugin> pluginReference;
// Whether or not Apache Commons is not present
protected boolean apacheCommonsMissing;
@ -50,17 +53,18 @@ public class DetailedErrorReporter implements ErrorReporter {
/**
* Create a default error reporting system.
*/
public DetailedErrorReporter() {
this(DEFAULT_PREFIX, DEFAULT_SUPPORT_URL);
public DetailedErrorReporter(Plugin plugin) {
this(plugin, DEFAULT_PREFIX, DEFAULT_SUPPORT_URL);
}
/**
* Create a central error reporting system.
* @param plugin - the plugin owner.
* @param prefix - default line prefix.
* @param supportURL - URL to report the error.
*/
public DetailedErrorReporter(String prefix, String supportURL) {
this(prefix, supportURL, DEFAULT_MAX_ERROR_COUNT, getBukkitLogger());
public DetailedErrorReporter(Plugin plugin, String prefix, String supportURL) {
this(plugin, prefix, supportURL, DEFAULT_MAX_ERROR_COUNT, getBukkitLogger());
}
// Attempt to get the logger.
@ -74,12 +78,17 @@ public class DetailedErrorReporter implements ErrorReporter {
/**
* Create a central error reporting system.
* @param plugin - the plugin owner.
* @param prefix - default line prefix.
* @param supportURL - URL to report the error.
* @param maxErrorCount - number of errors to print before giving up.
* @param logger - current logger.
*/
public DetailedErrorReporter(String prefix, String supportURL, int maxErrorCount, Logger logger) {
public DetailedErrorReporter(Plugin plugin, String prefix, String supportURL, int maxErrorCount, Logger logger) {
if (plugin == null)
throw new IllegalArgumentException("Plugin cannot be NULL.");
this.pluginReference = new WeakReference<Plugin>(plugin);
this.prefix = prefix;
this.supportURL = supportURL;
this.maxErrorCount = maxErrorCount;
@ -157,6 +166,13 @@ public class DetailedErrorReporter implements ErrorReporter {
writer.println("Sender:");
writer.println(addPrefix(getStringDescription(sender), SECOND_LEVEL_PREFIX));
// And plugin
if (pluginReference.get() != null) {
Plugin plugin = pluginReference.get();
writer.println("Version:");
writer.println(addPrefix(plugin.toString() + "-" + plugin.getDescription().getVersion(), SECOND_LEVEL_PREFIX));
}
// Add the server version too
if (Bukkit.getServer() != null) {
writer.println("Server:");