Load order fix
This commit is contained in:
@@ -728,8 +728,10 @@ public class Mods implements Loadable{
|
|||||||
Seq<LoadRun> runs = new Seq<>();
|
Seq<LoadRun> runs = new Seq<>();
|
||||||
|
|
||||||
for(LoadedMod mod : orderedMods()){
|
for(LoadedMod mod : orderedMods()){
|
||||||
ObjectMap<String, LoadRun> currentRun = new ObjectMap<>();
|
Seq<LoadRun> unorderedContent = new Seq<>();
|
||||||
|
ObjectMap<String, LoadRun> orderedContent = new ObjectMap<>();
|
||||||
String[] contentOrder = mod.meta.contentOrder;
|
String[] contentOrder = mod.meta.contentOrder;
|
||||||
|
ObjectSet<String> orderSet = contentOrder == null ? null : ObjectSet.with(contentOrder);
|
||||||
|
|
||||||
if(mod.root.child("content").exists()){
|
if(mod.root.child("content").exists()){
|
||||||
Fi contentRoot = mod.root.child("content");
|
Fi contentRoot = mod.root.child("content");
|
||||||
@@ -738,30 +740,32 @@ public class Mods implements Loadable{
|
|||||||
Fi folder = contentRoot.child(lower + (lower.endsWith("s") ? "" : "s"));
|
Fi folder = contentRoot.child(lower + (lower.endsWith("s") ? "" : "s"));
|
||||||
if(folder.exists()){
|
if(folder.exists()){
|
||||||
for(Fi file : folder.findAll(f -> f.extension().equals("json") || f.extension().equals("hjson"))){
|
for(Fi file : folder.findAll(f -> f.extension().equals("json") || f.extension().equals("hjson"))){
|
||||||
if(contentOrder == null){
|
|
||||||
runs.add(new LoadRun(type, file, mod));
|
//if this is part of the ordered content, put it aside to be dealt with later
|
||||||
|
if(orderSet != null && orderSet.contains(file.nameWithoutExtension())){
|
||||||
|
orderedContent.put(file.nameWithoutExtension(), new LoadRun(type, file, mod));
|
||||||
}else{
|
}else{
|
||||||
currentRun.put(file.nameWithoutExtension(), new LoadRun(type, file, mod));
|
unorderedContent.add(new LoadRun(type, file, mod));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Seq<String> left = currentRun.keys().toSeq();
|
//ordered content will be loaded first, if it exists
|
||||||
if(contentOrder != null){
|
if(contentOrder != null){
|
||||||
for (String contentName : contentOrder){
|
for(String contentName : contentOrder){
|
||||||
LoadRun run = currentRun.get(contentName);
|
LoadRun run = orderedContent.get(contentName);
|
||||||
if(run != null){
|
if(run != null){
|
||||||
runs.add(run);
|
runs.add(run);
|
||||||
left.remove(contentName);
|
|
||||||
}else{
|
}else{
|
||||||
Log.warn("Cannot find content defined in contentOrder: @", contentName);
|
Log.warn("Cannot find content defined in contentOrder: @", contentName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runs.addAll(left.map(name -> currentRun.get(name)).sort());
|
//unordered content is sorted alphabetically per mod
|
||||||
|
runs.addAll(unorderedContent.sort());
|
||||||
}
|
}
|
||||||
|
|
||||||
for(LoadRun l : runs){
|
for(LoadRun l : runs){
|
||||||
|
|||||||
Reference in New Issue
Block a user