Fix rare error with certain delay trigger setups, for #1630

This commit is contained in:
mcmonkey 2018-12-13 01:31:14 -08:00
parent eea6e83e83
commit 8e9eb3d373
No known key found for this signature in database
GPG Key ID: 2F0F11928478A6F5

View File

@ -1,6 +1,8 @@
package net.citizensnpcs.npc.ai; package net.citizensnpcs.npc.ai;
import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -289,10 +291,14 @@ public class CitizensNavigator implements Navigator, Runnable {
if (!isNavigating()) if (!isNavigating())
return; return;
Iterator<NavigatorCallback> itr = localParams.callbacks().iterator(); Iterator<NavigatorCallback> itr = localParams.callbacks().iterator();
List<NavigatorCallback> callbacks = new ArrayList<NavigatorCallback>();
while (itr.hasNext()) { while (itr.hasNext()) {
itr.next().onCompletion(reason); callbacks.add(itr.next());
itr.remove(); itr.remove();
} }
for (NavigatorCallback callback : callbacks) {
callback.onCompletion(reason);
}
if (reason == null) { if (reason == null) {
stopNavigating(); stopNavigating();
return; return;