Added 'remove library files'

This commit is contained in:
huangyuhui
2016-02-10 16:36:02 +08:00
parent c67e7c0d3a
commit 8b1ff94c5f
10 changed files with 29 additions and 11 deletions

View File

@@ -28,6 +28,7 @@ import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import org.jackhuang.hellominecraft.launcher.core.version.AssetIndexDownloadInfo;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
import org.jackhuang.hellominecraft.util.MessageBox;
import org.jackhuang.hellominecraft.util.code.DigestUtils;
import org.jackhuang.hellominecraft.util.func.Function;
import org.jackhuang.hellominecraft.util.logging.HMCLog;
import org.jackhuang.hellominecraft.util.tasks.Task;
@@ -127,11 +128,12 @@ public class MinecraftAssetService extends IMinecraftAssetService {
File objectDir = new File(assetsDir, "objects");
File indexFile = new File(indexDir, assetIndex.getId() + ".json");
if (!assetsDir.exists() && !indexFile.isFile())
if (!assetsDir.exists() || !indexFile.isFile())
return false;
try {
AssetsIndex index = (AssetsIndex) C.GSON.fromJson(FileUtils.readFileToString(indexFile, "UTF-8"), AssetsIndex.class);
String assetIndexContent = FileUtils.readFileToString(indexFile, "UTF-8");
AssetsIndex index = (AssetsIndex) C.GSON.fromJson(assetIndexContent, AssetsIndex.class);
if (index == null)
return false;
@@ -158,7 +160,8 @@ public class MinecraftAssetService extends IMinecraftAssetService {
}
try {
AssetsIndex index = (AssetsIndex) C.GSON.fromJson(FileUtils.readFileToString(indexFile, "UTF-8"), AssetsIndex.class);
String assetIndexContent = FileUtils.readFileToString(indexFile, "UTF-8");
AssetsIndex index = (AssetsIndex) C.GSON.fromJson(assetIndexContent, AssetsIndex.class);
if (index == null)
return assetsDir;

View File

@@ -59,6 +59,7 @@ import org.jackhuang.hellominecraft.util.OverridableSwingWorker;
import org.jackhuang.hellominecraft.util.version.MinecraftVersionRequest;
import org.jackhuang.hellominecraft.util.system.OS;
import org.jackhuang.hellominecraft.util.StrUtils;
import org.jackhuang.hellominecraft.util.system.FileUtils;
import org.jackhuang.hellominecraft.util.system.IOUtils;
import org.jackhuang.hellominecraft.util.ui.SwingUtils;
import org.jackhuang.hellominecraft.util.system.Java;
@@ -171,6 +172,12 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
getProfile().service().asset().refreshAssetsIndex(mcVersion);
});
ppmManage.add(itm);
itm = new JMenuItem(C.i18n("versions.mamage.remove_libraries"));
itm.addActionListener((e) -> {
if (mcVersion != null)
FileUtils.deleteDirectoryQuietly(new File(getProfile().service().baseDirectory(), "libraries"));
});
ppmManage.add(itm);
}
void initExternalModsTable() {