Add packet information to the default packet error reporter.
Dieser Commit ist enthalten in:
Ursprung
7ca3e916a5
Commit
83f5a7e5b7
@ -95,6 +95,21 @@ public class DetailedErrorReporter implements ErrorReporter {
|
|||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reportMinimal(Plugin sender, String methodName, Throwable error, Object... parameters) {
|
||||||
|
reportMinimal(sender, methodName, error);
|
||||||
|
|
||||||
|
// Print parameters, if they are given
|
||||||
|
if (parameters != null && parameters.length > 0) {
|
||||||
|
logger.log(Level.SEVERE, " Parameters:");
|
||||||
|
|
||||||
|
// Print each parameter
|
||||||
|
for (Object parameter : parameters) {
|
||||||
|
logger.log(Level.SEVERE, " " + getStringDescription(parameter));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reportMinimal(Plugin sender, String methodName, Throwable error) {
|
public void reportMinimal(Plugin sender, String methodName, Throwable error) {
|
||||||
logger.log(Level.SEVERE, "[" + PLUGIN_NAME + "] Unhandled exception occured in " + methodName + " for " +
|
logger.log(Level.SEVERE, "[" + PLUGIN_NAME + "] Unhandled exception occured in " + methodName + " for " +
|
||||||
|
@ -12,6 +12,15 @@ public interface ErrorReporter {
|
|||||||
*/
|
*/
|
||||||
public abstract void reportMinimal(Plugin sender, String methodName, Throwable error);
|
public abstract void reportMinimal(Plugin sender, String methodName, Throwable error);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints a small minimal error report about an exception from another plugin.
|
||||||
|
* @param sender - the other plugin.
|
||||||
|
* @param methodName - name of the caller method.
|
||||||
|
* @param error - the exception itself.
|
||||||
|
* @param parameters - any relevant parameters to print.
|
||||||
|
*/
|
||||||
|
public abstract void reportMinimal(Plugin sender, String methodName, Throwable error, Object... parameters);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints a warning message from the current plugin.
|
* Prints a warning message from the current plugin.
|
||||||
* @param sender - the object containing the caller method.
|
* @param sender - the object containing the caller method.
|
||||||
|
@ -246,20 +246,23 @@ class EntityUtilities {
|
|||||||
public static Entity getEntityFromID(World world, int entityID) throws FieldAccessException {
|
public static Entity getEntityFromID(World world, int entityID) throws FieldAccessException {
|
||||||
try {
|
try {
|
||||||
Object trackerEntry = getEntityTrackerEntry(world, entityID);
|
Object trackerEntry = getEntityTrackerEntry(world, entityID);
|
||||||
|
Object tracker = null;
|
||||||
if (trackerField == null)
|
|
||||||
trackerField = trackerEntry.getClass().getField("tracker");
|
|
||||||
Object tracker = FieldUtils.readField(trackerField, trackerEntry, true);
|
|
||||||
|
|
||||||
// Handle NULL cases
|
// Handle NULL cases
|
||||||
if (trackerEntry != null && tracker != null) {
|
if (trackerEntry != null) {
|
||||||
return (Entity) MinecraftReflection.getBukkitEntity(tracker);
|
if (trackerField == null)
|
||||||
} else {
|
trackerField = trackerEntry.getClass().getField("tracker");
|
||||||
return null;
|
tracker = FieldUtils.readField(trackerField, trackerEntry, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the tracker is NULL, we'll just assume this entity doesn't exist
|
||||||
|
if (tracker != null)
|
||||||
|
return (Entity) MinecraftReflection.getBukkitEntity(tracker);
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new FieldAccessException("Cannot find entity from ID.", e);
|
throw new FieldAccessException("Cannot find entity from ID " + entityID + ".", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,8 @@ public final class SortedPacketListenerList extends AbstractConcurrentListenerMu
|
|||||||
element.getListener().onPacketReceiving(event);
|
element.getListener().onPacketReceiving(event);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
// Minecraft doesn't want your Exception.
|
// Minecraft doesn't want your Exception.
|
||||||
reporter.reportMinimal(element.getListener().getPlugin(), "onPacketReceiving()", e);
|
reporter.reportMinimal(element.getListener().getPlugin(), "onPacketReceiving(PacketEvent)", e,
|
||||||
|
event.getPacket().getHandle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -69,7 +70,8 @@ public final class SortedPacketListenerList extends AbstractConcurrentListenerMu
|
|||||||
element.getListener().onPacketSending(event);
|
element.getListener().onPacketSending(event);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
// Minecraft doesn't want your Exception.
|
// Minecraft doesn't want your Exception.
|
||||||
reporter.reportMinimal(element.getListener().getPlugin(), "onPacketSending()", e);
|
reporter.reportMinimal(element.getListener().getPlugin(), "onPacketSending(PacketEvent)", e,
|
||||||
|
event.getPacket().getHandle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren