Catch IllegalPluginAccessExcption with scheduling logging tasks.

While we can/could control which stream to log to within onDisable, we
should still assume that an asynchronous task could be using the logging
system. Since we don't have a clean entry to onDisable, we have to catch
the exception.
This commit is contained in:
asofold 2015-02-04 21:29:29 +01:00
parent 71513f2d0c
commit c1c7e83bde

View File

@ -1,6 +1,7 @@
package fr.neatmonster.nocheatplus.logging.details;
import org.bukkit.Bukkit;
import org.bukkit.plugin.IllegalPluginAccessException;
import org.bukkit.plugin.Plugin;
import fr.neatmonster.nocheatplus.components.TickListener;
@ -47,7 +48,11 @@ public class BukkitLogNodeDispatcher extends AbstractLogNodeDispatcher { // TODO
synchronized (queueAsynchronous) {
if (taskAsynchronousID == -1) {
// Deadlocking should not be possible.
taskAsynchronousID = Bukkit.getScheduler().runTaskAsynchronously(plugin, taskAsynchronous).getTaskId();
try {
taskAsynchronousID = Bukkit.getScheduler().runTaskAsynchronously(plugin, taskAsynchronous).getTaskId();
} catch (IllegalPluginAccessException ex) {
// (Should be during onDisable, ignore for now.)
}
// TODO: Re-check task id here.
}
}