Fixed order of worlds in sidebar.
This commit is contained in:
parent
8e946bcba2
commit
e4628b2664
1 changed files with 20 additions and 1 deletions
|
|
@ -214,7 +214,26 @@ public class MapManager {
|
||||||
dynmapWorld.maps.add(map);
|
dynmapWorld.maps.add(map);
|
||||||
}
|
}
|
||||||
Log.info("Loaded " + dynmapWorld.maps.size() + " maps of world '" + worldName + "'.");
|
Log.info("Loaded " + dynmapWorld.maps.size() + " maps of world '" + worldName + "'.");
|
||||||
worlds.add(dynmapWorld);
|
|
||||||
|
// TODO: Make this less... weird...
|
||||||
|
// Insert the world on the same spot as in the configuration.
|
||||||
|
HashMap<String, Integer> indexLookup = new HashMap<String, Integer>();
|
||||||
|
List<ConfigurationNode> nodes = plug_in.configuration.getNodes("worlds");
|
||||||
|
for (int i = 0; i < nodes.size(); i++) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
worlds.add(insertIndex, dynmapWorld);
|
||||||
|
|
||||||
|
|
||||||
worldsLookup.put(w.getName(), dynmapWorld);
|
worldsLookup.put(w.getName(), dynmapWorld);
|
||||||
plug_in.events.trigger("worldactivated", dynmapWorld);
|
plug_in.events.trigger("worldactivated", dynmapWorld);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue