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 * Use this when {@link #runTaskOptionallyAsync(Runnable) optionally asynchronous tasks} have to
* run something synchronously. * run something synchronously.
* *
* @param task the task to be run * @param task the task to be run
*/ */
public void scheduleSyncTaskFromOptionallyAsyncTask(Runnable task) { public void scheduleSyncTaskFromOptionallyAsyncTask(Runnable task) {
if (useAsyncTasks) { if (Bukkit.isPrimaryThread()) {
scheduleSyncDelayedTask(task);
} else {
task.run(); task.run();
} else {
scheduleSyncDelayedTask(task);
} }
} }