use of io.xol.chunkstories.gui.layer.config.ModsSelection.ModsScrollableContainer.ModItem in project chunkstories by Hugobros3.
the class ModsSelection method buildModsList.
private void buildModsList() {
modsContainer.elements.clear();
Collection<String> currentlyEnabledMods = Arrays.asList(Client.getInstance().getContent().modsManager().getEnabledModsString());
Set<String> uniqueMods = new HashSet<String>();
// First put in already loaded mods
for (Mod mod : Client.getInstance().getContent().modsManager().getCurrentlyLoadedMods()) {
// Should use md5 hash instead ;)
if (uniqueMods.add(mod.getModInfo().getName().toLowerCase()))
modsContainer.elements.add(modsContainer.new ModItem(mod, true));
}
// Then look for mods in folder fashion
for (File f : new File(GameDirectory.getGameFolderPath() + "/mods/").listFiles()) {
if (f.isDirectory()) {
File txt = new File(f.getAbsolutePath() + "/mod.txt");
if (txt.exists()) {
try {
ModFolder mod = new ModFolder(f);
// Should use md5 hash instead ;)
if (uniqueMods.add(mod.getModInfo().getName().toLowerCase()))
modsContainer.elements.add(modsContainer.new ModItem(mod, currentlyEnabledMods.contains(mod.getModInfo().getName())));
System.out.println("mod:" + mod.getModInfo().getName() + " // " + currentlyEnabledMods.contains(mod.getModInfo().getName()));
} catch (ModLoadFailureException e) {
e.printStackTrace();
}
}
}
}
// First look for mods in folder fashion
for (File f : new File(GameDirectory.getGameFolderPath() + "/mods/").listFiles()) {
if (f.getName().endsWith(".zip")) {
try {
ModZip mod = new ModZip(f);
// Should use md5 hash instead ;)
if (uniqueMods.add(mod.getModInfo().getName().toLowerCase()))
modsContainer.elements.add(modsContainer.new ModItem(mod, currentlyEnabledMods.contains(mod.getModInfo().getName())));
} catch (ModLoadFailureException e) {
e.printStackTrace();
}
}
}
}
Aggregations