Fixed NoSuchElementException on disable.

This commit is contained in:
aPunch 2012-03-11 18:33:58 -05:00
parent d1cb52cb0a
commit 111ea65551

View File

@ -3,7 +3,6 @@ package net.citizensnpcs;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Iterator;
import java.util.logging.Level; import java.util.logging.Level;
import net.citizensnpcs.Settings.Setting; import net.citizensnpcs.Settings.Setting;
@ -119,10 +118,9 @@ public class Citizens extends JavaPlugin {
// Don't bother with this part if MC versions are not compatible // Don't bother with this part if MC versions are not compatible
if (compatible) { if (compatible) {
save(); save();
Iterator<NPC> itr = npcManager.iterator(); while (npcManager.iterator().hasNext()) {
while (itr.hasNext()) { npcManager.iterator().next().despawn();
itr.next().despawn(); npcManager.iterator().remove();
itr.remove();
} }
npcManager = null; npcManager = null;
getServer().getScheduler().cancelTasks(this); getServer().getScheduler().cancelTasks(this);