Log the plugin version too.
Dieser Commit ist enthalten in:
Ursprung
c2209138fe
Commit
cdc5740f85
@ -90,7 +90,7 @@ public class ProtocolLibrary extends JavaPlugin {
|
|||||||
logger = getLoggerSafely();
|
logger = getLoggerSafely();
|
||||||
|
|
||||||
// Add global parameters
|
// Add global parameters
|
||||||
DetailedErrorReporter reporter = new DetailedErrorReporter();
|
DetailedErrorReporter reporter = new DetailedErrorReporter(this);
|
||||||
updater = new Updater(this, logger, "protocollib", getFile(), "protocol.info");
|
updater = new Updater(this, logger, "protocollib", getFile(), "protocol.info");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -2,6 +2,7 @@ package com.comphenix.protocol.error;
|
|||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -41,6 +42,8 @@ public class DetailedErrorReporter implements ErrorReporter {
|
|||||||
protected int maxErrorCount;
|
protected int maxErrorCount;
|
||||||
protected Logger logger;
|
protected Logger logger;
|
||||||
|
|
||||||
|
protected WeakReference<Plugin> pluginReference;
|
||||||
|
|
||||||
// Whether or not Apache Commons is not present
|
// Whether or not Apache Commons is not present
|
||||||
protected boolean apacheCommonsMissing;
|
protected boolean apacheCommonsMissing;
|
||||||
|
|
||||||
@ -50,17 +53,18 @@ public class DetailedErrorReporter implements ErrorReporter {
|
|||||||
/**
|
/**
|
||||||
* Create a default error reporting system.
|
* Create a default error reporting system.
|
||||||
*/
|
*/
|
||||||
public DetailedErrorReporter() {
|
public DetailedErrorReporter(Plugin plugin) {
|
||||||
this(DEFAULT_PREFIX, DEFAULT_SUPPORT_URL);
|
this(plugin, DEFAULT_PREFIX, DEFAULT_SUPPORT_URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a central error reporting system.
|
* Create a central error reporting system.
|
||||||
|
* @param plugin - the plugin owner.
|
||||||
* @param prefix - default line prefix.
|
* @param prefix - default line prefix.
|
||||||
* @param supportURL - URL to report the error.
|
* @param supportURL - URL to report the error.
|
||||||
*/
|
*/
|
||||||
public DetailedErrorReporter(String prefix, String supportURL) {
|
public DetailedErrorReporter(Plugin plugin, String prefix, String supportURL) {
|
||||||
this(prefix, supportURL, DEFAULT_MAX_ERROR_COUNT, getBukkitLogger());
|
this(plugin, prefix, supportURL, DEFAULT_MAX_ERROR_COUNT, getBukkitLogger());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to get the logger.
|
// Attempt to get the logger.
|
||||||
@ -74,12 +78,17 @@ public class DetailedErrorReporter implements ErrorReporter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a central error reporting system.
|
* Create a central error reporting system.
|
||||||
|
* @param plugin - the plugin owner.
|
||||||
* @param prefix - default line prefix.
|
* @param prefix - default line prefix.
|
||||||
* @param supportURL - URL to report the error.
|
* @param supportURL - URL to report the error.
|
||||||
* @param maxErrorCount - number of errors to print before giving up.
|
* @param maxErrorCount - number of errors to print before giving up.
|
||||||
* @param logger - current logger.
|
* @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.prefix = prefix;
|
||||||
this.supportURL = supportURL;
|
this.supportURL = supportURL;
|
||||||
this.maxErrorCount = maxErrorCount;
|
this.maxErrorCount = maxErrorCount;
|
||||||
@ -157,6 +166,13 @@ public class DetailedErrorReporter implements ErrorReporter {
|
|||||||
writer.println("Sender:");
|
writer.println("Sender:");
|
||||||
writer.println(addPrefix(getStringDescription(sender), SECOND_LEVEL_PREFIX));
|
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
|
// Add the server version too
|
||||||
if (Bukkit.getServer() != null) {
|
if (Bukkit.getServer() != null) {
|
||||||
writer.println("Server:");
|
writer.println("Server:");
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren