final Map<String, BasicModuleScript> pathMap = new LinkedHashMap<String, BasicModuleScript>();
final List<IBasicModuleScript> newModules = new ArrayList<IBasicModuleScript>();
for(IBasicModuleScript m: currentModules) {
if(m instanceof BasicModuleScript) {
BasicModuleScript bms = (BasicModuleScript) m;
pathMap.put(bms.getModule().getScriptFile().getPath(), bms);
}
}
for(ScriptedModule sm: scriptLoader.getAllModulesByType(ModuleScriptType.BASIC_MODULE)) {
String path = sm.getScriptFile().getPath();
if(pathMap.containsKey(path)) {
BasicModuleScript old = pathMap.get(path);
newModules.add(new BasicModuleScript(sm, old.isEnabled(), old.getRunningTimeProfile()));
} else {
newModules.add(new BasicModuleScript(sm));
}
}
return newModules;
}