Schedule a new sync thread based on thread compare rather than the async setting

(Fixes #1151)
This commit is contained in:
games647 2017-03-29 09:45:39 +02:00
parent cb0cf6bb5a
commit 4e364c13a3
No known key found for this signature in database
GPG Key ID: E9E962F08F621538

View File

@ -74,17 +74,17 @@ public class BukkitService implements SettingsDependent {
}
/**
* Schedules a synchronous task if async tasks are enabled; if not, it runs the task immediately.
* Schedules a synchronous task if we are currently on a async thread; if not, it runs the task immediately.
* Use this when {@link #runTaskOptionallyAsync(Runnable) optionally asynchronous tasks} have to
* run something synchronously.
*
* @param task the task to be run
*/
public void scheduleSyncTaskFromOptionallyAsyncTask(Runnable task) {
if (useAsyncTasks) {
scheduleSyncDelayedTask(task);
} else {
if (Bukkit.isPrimaryThread()) {
task.run();
} else {
scheduleSyncDelayedTask(task);
}
}