diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/error/DetailedErrorReporter.java b/ProtocolLib/src/main/java/com/comphenix/protocol/error/DetailedErrorReporter.java index 80ba3d37..ce3574a8 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/error/DetailedErrorReporter.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/error/DetailedErrorReporter.java @@ -141,6 +141,13 @@ public class DetailedErrorReporter implements ErrorReporter { reportMinimalNoSpam(sender, methodName, error); } + /** + * Report a problem with a given method and plugin, ensuring that we don't exceed the maximum number of error reports. + * @param sender - the component that observed this exception. + * @param methodName - the method name. + * @param error - the error itself. + * @return TRUE if the error was printed, FALSE if it was suppressed. + */ public boolean reportMinimalNoSpam(Plugin sender, String methodName, Throwable error) { String pluginName = PacketAdapter.getPluginName(sender); AtomicInteger counter = warningCount.get(pluginName); @@ -368,63 +375,125 @@ public class DetailedErrorReporter implements ErrorReporter { return test instanceof String || Primitives.isWrapperType(test.getClass()); } + /** + * Retrieve the current number of errors printed through {@link #reportDetailed(Object, Report)}. + * @return Number of errors printed. + */ public int getErrorCount() { return internalErrorCount.get(); } + /** + * Set the number of errors printed. + * @param errorCount - new number of errors printed. + */ public void setErrorCount(int errorCount) { internalErrorCount.set(errorCount); } + /** + * Retrieve the maximum number of errors we can print before we begin suppressing errors. + * @return Maximum number of errors. + */ public int getMaxErrorCount() { return maxErrorCount; } + /** + * Set the maximum number of errors we can print before we begin suppressing errors. + * @param maxErrorCount - new max count. + */ public void setMaxErrorCount(int maxErrorCount) { this.maxErrorCount = maxErrorCount; } /** * Adds the given global parameter. It will be included in every error report. + *
+ * Both key and value must be non-null.
* @param key - name of parameter.
* @param value - the global parameter itself.
*/
public void addGlobalParameter(String key, Object value) {
+ if (key == null)
+ throw new IllegalArgumentException("key cannot be NULL.");
+ if (value == null)
+ throw new IllegalArgumentException("value cannot be NULL.");
+
globalParameters.put(key, value);
}
+ /**
+ * Retrieve a global parameter by its key.
+ * @param key - key of the parameter to retrieve.
+ * @return The value of the global parameter, or NULL if not found.
+ */
public Object getGlobalParameter(String key) {
+ if (key == null)
+ throw new IllegalArgumentException("key cannot be NULL.");
+
return globalParameters.get(key);
}
+ /**
+ * Reset all global parameters.
+ */
public void clearGlobalParameters() {
globalParameters.clear();
}
+ /**
+ * Retrieve a set of every registered global parameter.
+ * @return Set of all registered global parameters.
+ */
public Set