Fix exception in world ordering code when world not in worlds list

This commit is contained in:
Mike Primm 2011-05-26 15:32:56 -05:00
parent bc6176f3e1
commit f9f615db2d

View File

@ -223,16 +223,20 @@ public class MapManager {
ConfigurationNode node = nodes.get(i);
indexLookup.put(node.getString("name"), i);
}
int worldIndex = indexLookup.get(worldName);
int insertIndex;
for(insertIndex = 0; insertIndex < worlds.size(); insertIndex++) {
Integer nextWorldIndex = indexLookup.get(worlds.get(insertIndex).world.getName());
if (nextWorldIndex == null || worldIndex < nextWorldIndex.intValue()) {
break;
}
Integer worldIndex = indexLookup.get(worldName);
if(worldIndex == null) {
worlds.add(dynmapWorld); /* Put at end if no world section */
}
else {
int insertIndex;
for(insertIndex = 0; insertIndex < worlds.size(); insertIndex++) {
Integer nextWorldIndex = indexLookup.get(worlds.get(insertIndex).world.getName());
if (nextWorldIndex == null || worldIndex < nextWorldIndex.intValue()) {
break;
}
}
worlds.add(insertIndex, dynmapWorld);
}
worlds.add(insertIndex, dynmapWorld);
worldsLookup.put(w.getName(), dynmapWorld);
plug_in.events.trigger("worldactivated", dynmapWorld);