mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-10 20:37:30 -04:00
Now installer will set the url of base jar of Forge and LiteLoader.
This commit is contained in:
parent
c3008ec294
commit
e4335cf1f0
File diff suppressed because it is too large
Load Diff
@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.launcher.launch;
|
package org.jackhuang.hellominecraft.launcher.launch;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -33,7 +33,6 @@ import org.jackhuang.hellominecraft.C;
|
|||||||
import org.jackhuang.hellominecraft.HMCLog;
|
import org.jackhuang.hellominecraft.HMCLog;
|
||||||
import org.jackhuang.hellominecraft.tasks.Task;
|
import org.jackhuang.hellominecraft.tasks.Task;
|
||||||
import org.jackhuang.hellominecraft.tasks.download.NetException;
|
import org.jackhuang.hellominecraft.tasks.download.NetException;
|
||||||
import org.jackhuang.hellominecraft.utils.system.FileUtils;
|
|
||||||
import org.jackhuang.hellominecraft.utils.system.IOUtils;
|
import org.jackhuang.hellominecraft.utils.system.IOUtils;
|
||||||
import org.tukaani.xz.XZInputStream;
|
import org.tukaani.xz.XZInputStream;
|
||||||
|
|
||||||
@ -55,8 +54,8 @@ public class LibraryDownloadTask extends Task {
|
|||||||
public boolean executeTask() {
|
public boolean executeTask() {
|
||||||
try {
|
try {
|
||||||
File packFile = new File(job.path.getParentFile(), job.path.getName() + ".pack.xz");
|
File packFile = new File(job.path.getParentFile(), job.path.getName() + ".pack.xz");
|
||||||
if (job.url.contains("forge") && download(new URL(job.url + ".pack.xz"), packFile)) {
|
if (job.url.contains("typesafe") && download(new URL(job.url + ".pack.xz"), packFile)) {
|
||||||
unpackLibrary(job.path, FileUtils.toByteArray(packFile));
|
unpackLibrary(job.path, packFile);
|
||||||
packFile.delete();
|
packFile.delete();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -74,6 +73,7 @@ public class LibraryDownloadTask extends Task {
|
|||||||
int size = -1;
|
int size = -1;
|
||||||
|
|
||||||
boolean download(URL url, File filePath) {
|
boolean download(URL url, File filePath) {
|
||||||
|
HMCLog.log("Downloading: " + url + " to " + filePath);
|
||||||
size = -1;
|
size = -1;
|
||||||
int downloaded = 0;
|
int downloaded = 0;
|
||||||
for (int repeat = 0; repeat < 6; repeat++) {
|
for (int repeat = 0; repeat < 6; repeat++) {
|
||||||
@ -154,13 +154,13 @@ public class LibraryDownloadTask extends Task {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void unpackLibrary(File output, byte[] data)
|
public static void unpackLibrary(File output, File input)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
HMCLog.log("Unpacking " + output);
|
HMCLog.log("Unpacking " + output);
|
||||||
if (output.exists())
|
if (output.exists())
|
||||||
output.delete();
|
output.delete();
|
||||||
|
|
||||||
byte[] decompressed = IOUtils.readFully(new XZInputStream(new ByteArrayInputStream(data)));
|
byte[] decompressed = IOUtils.readFully(new XZInputStream(new FileInputStream(input)));
|
||||||
|
|
||||||
String end = new String(decompressed, decompressed.length - 4, 4);
|
String end = new String(decompressed, decompressed.length - 4, 4);
|
||||||
if (!end.equals("SIGN")) {
|
if (!end.equals("SIGN")) {
|
||||||
@ -183,7 +183,6 @@ public class LibraryDownloadTask extends Task {
|
|||||||
out.write(decompressed, 0, decompressed.length - len - 8);
|
out.write(decompressed, 0, decompressed.length - len - 8);
|
||||||
}
|
}
|
||||||
decompressed = null;
|
decompressed = null;
|
||||||
data = null;
|
|
||||||
System.gc();
|
System.gc();
|
||||||
|
|
||||||
try (FileOutputStream jarBytes = new FileOutputStream(output); JarOutputStream jos = new JarOutputStream(jarBytes)) {
|
try (FileOutputStream jarBytes = new FileOutputStream(output); JarOutputStream jos = new JarOutputStream(jarBytes)) {
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package org.jackhuang.hellominecraft.launcher.utils.installers.forge;
|
package org.jackhuang.hellominecraft.launcher.utils.installers.forge;
|
||||||
|
|
||||||
import org.jackhuang.hellominecraft.launcher.utils.installers.InstallProfile;
|
import org.jackhuang.hellominecraft.launcher.utils.installers.InstallProfile;
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.JsonSyntaxException;
|
import com.google.gson.JsonSyntaxException;
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -30,6 +29,7 @@ import org.jackhuang.hellominecraft.C;
|
|||||||
import org.jackhuang.hellominecraft.HMCLog;
|
import org.jackhuang.hellominecraft.HMCLog;
|
||||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftProvider;
|
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftProvider;
|
||||||
import org.jackhuang.hellominecraft.launcher.settings.Settings;
|
import org.jackhuang.hellominecraft.launcher.settings.Settings;
|
||||||
|
import org.jackhuang.hellominecraft.launcher.utils.installers.InstallerVersionList.InstallerVersion;
|
||||||
import org.jackhuang.hellominecraft.tasks.Task;
|
import org.jackhuang.hellominecraft.tasks.Task;
|
||||||
import org.jackhuang.hellominecraft.utils.system.FileUtils;
|
import org.jackhuang.hellominecraft.utils.system.FileUtils;
|
||||||
import org.jackhuang.hellominecraft.utils.NetUtils;
|
import org.jackhuang.hellominecraft.utils.NetUtils;
|
||||||
@ -45,11 +45,13 @@ public class ForgeInstaller extends Task {
|
|||||||
public File gameDir;
|
public File gameDir;
|
||||||
public File forgeInstaller;
|
public File forgeInstaller;
|
||||||
public IMinecraftProvider mp;
|
public IMinecraftProvider mp;
|
||||||
|
public InstallerVersion installerVersion;
|
||||||
|
|
||||||
public ForgeInstaller(IMinecraftProvider mp, File forgeInstaller) {
|
public ForgeInstaller(IMinecraftProvider mp, File forgeInstaller, InstallerVersion installerVersion) {
|
||||||
this.gameDir = mp.getBaseFolder();
|
this.gameDir = mp.getBaseFolder();
|
||||||
this.forgeInstaller = forgeInstaller;
|
this.forgeInstaller = forgeInstaller;
|
||||||
this.mp = mp;
|
this.mp = mp;
|
||||||
|
this.installerVersion = installerVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -79,6 +81,9 @@ public class ForgeInstaller extends Task {
|
|||||||
FileUtils.copyFile(new File(from, profile.install.minecraft + ".jar"),
|
FileUtils.copyFile(new File(from, profile.install.minecraft + ".jar"),
|
||||||
new File(to, profile.install.target + ".jar"));
|
new File(to, profile.install.target + ".jar"));
|
||||||
HMCLog.log("Creating new version profile..." + profile.install.target + ".json");
|
HMCLog.log("Creating new version profile..." + profile.install.target + ".json");
|
||||||
|
for (MinecraftLibrary library : profile.versionInfo.libraries)
|
||||||
|
if (library.name.startsWith("net.minecraftforge:forge:"))
|
||||||
|
library.url = installerVersion.universal;
|
||||||
FileUtils.write(new File(to, profile.install.target + ".json"), C.gsonPrettyPrinting.toJson(profile.versionInfo));
|
FileUtils.write(new File(to, profile.install.target + ".json"), C.gsonPrettyPrinting.toJson(profile.versionInfo));
|
||||||
|
|
||||||
HMCLog.log("Extracting universal forge pack..." + profile.install.filePath);
|
HMCLog.log("Extracting universal forge pack..." + profile.install.filePath);
|
||||||
|
@ -64,7 +64,9 @@ public class LiteLoaderInstaller extends Task implements PreviousResultRegistrat
|
|||||||
mv.jar = mv.jar == null ? mv.id : mv.jar;
|
mv.jar = mv.jar == null ? mv.id : mv.jar;
|
||||||
mv.libraries = new ArrayList(Arrays.asList(version.libraries));
|
mv.libraries = new ArrayList(Arrays.asList(version.libraries));
|
||||||
|
|
||||||
mv.libraries.add(0, new MinecraftLibrary("com.mumfrey:liteloader:" + version.selfVersion));
|
MinecraftLibrary ml = new MinecraftLibrary("com.mumfrey:liteloader:" + version.selfVersion);
|
||||||
|
ml.url = "http://dl.liteloader.com/versions/com/mumfrey/liteloader/" + version.mcVersion + "/liteloader-" + version.selfVersion + ".jar";
|
||||||
|
mv.libraries.add(0, ml);
|
||||||
FileUtils.copyFile(installer, new File(profile.getCanonicalGameDir(), "libraries/com/mumfrey/liteloader/" + version.selfVersion + "/liteloader-" + version.selfVersion + ".jar"));
|
FileUtils.copyFile(installer, new File(profile.getCanonicalGameDir(), "libraries/com/mumfrey/liteloader/" + version.selfVersion + "/liteloader-" + version.selfVersion + ".jar"));
|
||||||
|
|
||||||
mv.id += "-LiteLoader" + version.selfVersion;
|
mv.id += "-LiteLoader" + version.selfVersion;
|
||||||
|
@ -72,9 +72,8 @@ public class MinecraftLibrary extends IMinecraftLibrary {
|
|||||||
flag = false;
|
flag = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else
|
} else if (r.os == null || (r.os != null && (StrUtils.isBlank(r.os.name) || r.os.name.equalsIgnoreCase(OS.os().toString()))))
|
||||||
if (r.os == null || (r.os != null && (StrUtils.isBlank(r.os.name) || r.os.name.equalsIgnoreCase(OS.os().toString()))))
|
flag = true;
|
||||||
flag = true;
|
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,6 +122,7 @@ public class MinecraftLibrary extends IMinecraftLibrary {
|
|||||||
@Override
|
@Override
|
||||||
public String getDownloadURL(String urlBase, DownloadType downloadType) {
|
public String getDownloadURL(String urlBase, DownloadType downloadType) {
|
||||||
if (StrUtils.isNotBlank(url) && downloadType.getProvider().isAllowedToUseSelfURL()) urlBase = this.url;
|
if (StrUtils.isNotBlank(url) && downloadType.getProvider().isAllowedToUseSelfURL()) urlBase = this.url;
|
||||||
|
if (urlBase.endsWith(".jar")) return urlBase;
|
||||||
return urlBase + formatted.replace('\\', '/');
|
return urlBase + formatted.replace('\\', '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
<Component id="btnIncludeMinecraft" min="-2" max="-2" attributes="0"/>
|
<Component id="btnIncludeMinecraft" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="32767" attributes="0"/>
|
<EmptySpace max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<Component id="tabVersionEdit" alignment="0" max="32767" attributes="0"/>
|
<Component id="tabVersionEdit" alignment="0" pref="684" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
@ -306,7 +306,7 @@
|
|||||||
<Component id="jLabel9" min="-2" max="-2" attributes="0"/>
|
<Component id="jLabel9" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="txtHeight" min="-2" pref="100" max="-2" attributes="0"/>
|
<Component id="txtHeight" min="-2" pref="100" max="-2" attributes="0"/>
|
||||||
<EmptySpace pref="306" max="32767" attributes="0"/>
|
<EmptySpace pref="320" max="32767" attributes="0"/>
|
||||||
<Component id="chkFullscreen" min="-2" max="-2" attributes="0"/>
|
<Component id="chkFullscreen" min="-2" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<Group type="102" alignment="1" attributes="0">
|
<Group type="102" alignment="1" attributes="0">
|
||||||
@ -733,10 +733,9 @@
|
|||||||
<DimensionLayout dim="0">
|
<DimensionLayout dim="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="1" attributes="0">
|
<Group type="102" alignment="1" attributes="0">
|
||||||
<Component id="jScrollPane11" pref="587" max="32767" attributes="0"/>
|
<Component id="jScrollPane11" pref="601" max="32767" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||||
<Component id="btnRetryForge" alignment="0" max="32767" attributes="0"/>
|
|
||||||
<Component id="btnDownloadForge" alignment="0" max="32767" attributes="0"/>
|
<Component id="btnDownloadForge" alignment="0" max="32767" attributes="0"/>
|
||||||
<Component id="btnRefreshForge" alignment="0" max="32767" attributes="0"/>
|
<Component id="btnRefreshForge" alignment="0" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
@ -746,14 +745,12 @@
|
|||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Component id="jScrollPane11" pref="0" max="32767" attributes="0"/>
|
<Component id="jScrollPane11" pref="291" max="32767" attributes="0"/>
|
||||||
<Group type="102" attributes="0">
|
<Group type="102" attributes="0">
|
||||||
<Component id="btnDownloadForge" min="-2" max="-2" attributes="0"/>
|
<Component id="btnDownloadForge" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="btnRetryForge" min="-2" max="-2" attributes="0"/>
|
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
|
||||||
<Component id="btnRefreshForge" min="-2" max="-2" attributes="0"/>
|
<Component id="btnRefreshForge" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace min="0" pref="210" max="32767" attributes="0"/>
|
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
@ -801,16 +798,6 @@
|
|||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnDownloadForgeActionPerformed"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnDownloadForgeActionPerformed"/>
|
||||||
</Events>
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JButton" name="btnRetryForge">
|
|
||||||
<Properties>
|
|
||||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
|
||||||
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="ui.button.retry" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/>
|
|
||||||
</Property>
|
|
||||||
</Properties>
|
|
||||||
<Events>
|
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnRetryForgeActionPerformed"/>
|
|
||||||
</Events>
|
|
||||||
</Component>
|
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Container>
|
</Container>
|
||||||
<Container class="javax.swing.JPanel" name="pnlOptifine">
|
<Container class="javax.swing.JPanel" name="pnlOptifine">
|
||||||
@ -826,7 +813,7 @@
|
|||||||
<DimensionLayout dim="0">
|
<DimensionLayout dim="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<Component id="jScrollPane13" pref="587" max="32767" attributes="0"/>
|
<Component id="jScrollPane13" pref="601" max="32767" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||||
<Component id="btnDownloadOptifine" max="32767" attributes="0"/>
|
<Component id="btnDownloadOptifine" max="32767" attributes="0"/>
|
||||||
@ -906,11 +893,10 @@
|
|||||||
<DimensionLayout dim="0">
|
<DimensionLayout dim="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<Component id="jScrollPane12" pref="587" max="32767" attributes="0"/>
|
<Component id="jScrollPane12" pref="601" max="32767" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||||
<Component id="btnInstallLiteLoader" alignment="0" max="32767" attributes="0"/>
|
<Component id="btnInstallLiteLoader" alignment="0" max="32767" attributes="0"/>
|
||||||
<Component id="btnRetryLiteLoader" alignment="0" max="32767" attributes="0"/>
|
|
||||||
<Component id="btnRefreshLiteLoader" alignment="0" min="-2" max="-2" attributes="0"/>
|
<Component id="btnRefreshLiteLoader" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
@ -919,14 +905,12 @@
|
|||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Component id="jScrollPane12" pref="0" max="32767" attributes="0"/>
|
<Component id="jScrollPane12" pref="291" max="32767" attributes="0"/>
|
||||||
<Group type="102" attributes="0">
|
<Group type="102" attributes="0">
|
||||||
<Component id="btnInstallLiteLoader" min="-2" max="-2" attributes="0"/>
|
<Component id="btnInstallLiteLoader" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="btnRetryLiteLoader" min="-2" max="-2" attributes="0"/>
|
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
|
||||||
<Component id="btnRefreshLiteLoader" min="-2" max="-2" attributes="0"/>
|
<Component id="btnRefreshLiteLoader" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace min="0" pref="210" max="32767" attributes="0"/>
|
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
@ -974,16 +958,6 @@
|
|||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnRefreshLiteLoaderActionPerformed"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnRefreshLiteLoaderActionPerformed"/>
|
||||||
</Events>
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JButton" name="btnRetryLiteLoader">
|
|
||||||
<Properties>
|
|
||||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
|
||||||
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="ui.button.retry" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/>
|
|
||||||
</Property>
|
|
||||||
</Properties>
|
|
||||||
<Events>
|
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnRetryLiteLoaderActionPerformed"/>
|
|
||||||
</Events>
|
|
||||||
</Component>
|
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Container>
|
</Container>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
@ -1005,7 +979,7 @@
|
|||||||
<DimensionLayout dim="0">
|
<DimensionLayout dim="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<Component id="jScrollPane2" pref="592" max="32767" attributes="0"/>
|
<Component id="jScrollPane2" pref="606" max="32767" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||||
<Component id="btnRefreshGameDownloads" alignment="0" max="32767" attributes="0"/>
|
<Component id="btnRefreshGameDownloads" alignment="0" max="32767" attributes="0"/>
|
||||||
|
@ -223,7 +223,6 @@ public class GameSettingsPanel extends javax.swing.JPanel {
|
|||||||
lstForge = new javax.swing.JTable();
|
lstForge = new javax.swing.JTable();
|
||||||
btnRefreshForge = new javax.swing.JButton();
|
btnRefreshForge = new javax.swing.JButton();
|
||||||
btnDownloadForge = new javax.swing.JButton();
|
btnDownloadForge = new javax.swing.JButton();
|
||||||
btnRetryForge = new javax.swing.JButton();
|
|
||||||
pnlOptifine = new javax.swing.JPanel();
|
pnlOptifine = new javax.swing.JPanel();
|
||||||
jScrollPane13 = new javax.swing.JScrollPane();
|
jScrollPane13 = new javax.swing.JScrollPane();
|
||||||
lstOptifine = new javax.swing.JTable();
|
lstOptifine = new javax.swing.JTable();
|
||||||
@ -234,7 +233,6 @@ public class GameSettingsPanel extends javax.swing.JPanel {
|
|||||||
jScrollPane12 = new javax.swing.JScrollPane();
|
jScrollPane12 = new javax.swing.JScrollPane();
|
||||||
lstLiteLoader = new javax.swing.JTable();
|
lstLiteLoader = new javax.swing.JTable();
|
||||||
btnRefreshLiteLoader = new javax.swing.JButton();
|
btnRefreshLiteLoader = new javax.swing.JButton();
|
||||||
btnRetryLiteLoader = new javax.swing.JButton();
|
|
||||||
pnlGameDownloads = new javax.swing.JPanel();
|
pnlGameDownloads = new javax.swing.JPanel();
|
||||||
btnDownload = new javax.swing.JButton();
|
btnDownload = new javax.swing.JButton();
|
||||||
jScrollPane2 = new javax.swing.JScrollPane();
|
jScrollPane2 = new javax.swing.JScrollPane();
|
||||||
@ -498,7 +496,7 @@ public class GameSettingsPanel extends javax.swing.JPanel {
|
|||||||
.addComponent(jLabel9)
|
.addComponent(jLabel9)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(txtHeight, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(txtHeight, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 306, Short.MAX_VALUE)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 320, Short.MAX_VALUE)
|
||||||
.addComponent(chkFullscreen))
|
.addComponent(chkFullscreen))
|
||||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel22Layout.createSequentialGroup()
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel22Layout.createSequentialGroup()
|
||||||
.addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
.addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
@ -695,36 +693,26 @@ public class GameSettingsPanel extends javax.swing.JPanel {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
btnRetryForge.setText(bundle.getString("ui.button.retry")); // NOI18N
|
|
||||||
btnRetryForge.addActionListener(new java.awt.event.ActionListener() {
|
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
||||||
btnRetryForgeActionPerformed(evt);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
|
javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
|
||||||
jPanel16.setLayout(jPanel16Layout);
|
jPanel16.setLayout(jPanel16Layout);
|
||||||
jPanel16Layout.setHorizontalGroup(
|
jPanel16Layout.setHorizontalGroup(
|
||||||
jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel16Layout.createSequentialGroup()
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel16Layout.createSequentialGroup()
|
||||||
.addComponent(jScrollPane11, javax.swing.GroupLayout.DEFAULT_SIZE, 587, Short.MAX_VALUE)
|
.addComponent(jScrollPane11, javax.swing.GroupLayout.DEFAULT_SIZE, 601, Short.MAX_VALUE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
.addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||||
.addComponent(btnRetryForge, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
||||||
.addComponent(btnDownloadForge, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(btnDownloadForge, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(btnRefreshForge, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
.addComponent(btnRefreshForge, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||||
.addContainerGap())
|
.addContainerGap())
|
||||||
);
|
);
|
||||||
jPanel16Layout.setVerticalGroup(
|
jPanel16Layout.setVerticalGroup(
|
||||||
jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jScrollPane11, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
|
.addComponent(jScrollPane11, javax.swing.GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE)
|
||||||
.addGroup(jPanel16Layout.createSequentialGroup()
|
.addGroup(jPanel16Layout.createSequentialGroup()
|
||||||
.addComponent(btnDownloadForge)
|
.addComponent(btnDownloadForge)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(btnRetryForge)
|
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
||||||
.addComponent(btnRefreshForge)
|
.addComponent(btnRefreshForge)
|
||||||
.addGap(0, 210, Short.MAX_VALUE))
|
.addGap(0, 0, Short.MAX_VALUE))
|
||||||
);
|
);
|
||||||
|
|
||||||
tabInstallers.addTab("Forge", jPanel16);
|
tabInstallers.addTab("Forge", jPanel16);
|
||||||
@ -753,7 +741,7 @@ btnRefreshOptifine.addActionListener(new java.awt.event.ActionListener() {
|
|||||||
pnlOptifineLayout.setHorizontalGroup(
|
pnlOptifineLayout.setHorizontalGroup(
|
||||||
pnlOptifineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
pnlOptifineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(pnlOptifineLayout.createSequentialGroup()
|
.addGroup(pnlOptifineLayout.createSequentialGroup()
|
||||||
.addComponent(jScrollPane13, javax.swing.GroupLayout.DEFAULT_SIZE, 587, Short.MAX_VALUE)
|
.addComponent(jScrollPane13, javax.swing.GroupLayout.DEFAULT_SIZE, 601, Short.MAX_VALUE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(pnlOptifineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
.addGroup(pnlOptifineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||||
.addComponent(btnDownloadOptifine, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(btnDownloadOptifine, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
@ -791,36 +779,26 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
btnRetryLiteLoader.setText(bundle.getString("ui.button.retry")); // NOI18N
|
|
||||||
btnRetryLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
||||||
btnRetryLiteLoaderActionPerformed(evt);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
|
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
|
||||||
jPanel3.setLayout(jPanel3Layout);
|
jPanel3.setLayout(jPanel3Layout);
|
||||||
jPanel3Layout.setHorizontalGroup(
|
jPanel3Layout.setHorizontalGroup(
|
||||||
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel3Layout.createSequentialGroup()
|
.addGroup(jPanel3Layout.createSequentialGroup()
|
||||||
.addComponent(jScrollPane12, javax.swing.GroupLayout.DEFAULT_SIZE, 587, Short.MAX_VALUE)
|
.addComponent(jScrollPane12, javax.swing.GroupLayout.DEFAULT_SIZE, 601, Short.MAX_VALUE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||||
.addComponent(btnInstallLiteLoader, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(btnInstallLiteLoader, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(btnRetryLiteLoader, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
||||||
.addComponent(btnRefreshLiteLoader))
|
.addComponent(btnRefreshLiteLoader))
|
||||||
.addContainerGap())
|
.addContainerGap())
|
||||||
);
|
);
|
||||||
jPanel3Layout.setVerticalGroup(
|
jPanel3Layout.setVerticalGroup(
|
||||||
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jScrollPane12, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
|
.addComponent(jScrollPane12, javax.swing.GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE)
|
||||||
.addGroup(jPanel3Layout.createSequentialGroup()
|
.addGroup(jPanel3Layout.createSequentialGroup()
|
||||||
.addComponent(btnInstallLiteLoader)
|
.addComponent(btnInstallLiteLoader)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(btnRetryLiteLoader)
|
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
||||||
.addComponent(btnRefreshLiteLoader)
|
.addComponent(btnRefreshLiteLoader)
|
||||||
.addGap(0, 210, Short.MAX_VALUE))
|
.addGap(0, 0, Short.MAX_VALUE))
|
||||||
);
|
);
|
||||||
|
|
||||||
tabInstallers.addTab("LiteLoader", jPanel3);
|
tabInstallers.addTab("LiteLoader", jPanel3);
|
||||||
@ -862,7 +840,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
|||||||
pnlGameDownloadsLayout.setHorizontalGroup(
|
pnlGameDownloadsLayout.setHorizontalGroup(
|
||||||
pnlGameDownloadsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
pnlGameDownloadsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(pnlGameDownloadsLayout.createSequentialGroup()
|
.addGroup(pnlGameDownloadsLayout.createSequentialGroup()
|
||||||
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 592, Short.MAX_VALUE)
|
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 606, Short.MAX_VALUE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(pnlGameDownloadsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
.addGroup(pnlGameDownloadsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||||
.addComponent(btnRefreshGameDownloads, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(btnRefreshGameDownloads, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
@ -896,7 +874,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
|||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(btnIncludeMinecraft)
|
.addComponent(btnIncludeMinecraft)
|
||||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||||
.addComponent(tabVersionEdit)
|
.addComponent(tabVersionEdit, javax.swing.GroupLayout.DEFAULT_SIZE, 684, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
@ -970,18 +948,11 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
|||||||
url = v.installer;
|
url = v.installer;
|
||||||
TaskWindow.getInstance()
|
TaskWindow.getInstance()
|
||||||
.addTask(new FileDownloadTask(url, filepath).setTag("forge"))
|
.addTask(new FileDownloadTask(url, filepath).setTag("forge"))
|
||||||
.addTask(new ForgeInstaller(profile.getMinecraftProvider(), filepath))
|
.addTask(new ForgeInstaller(profile.getMinecraftProvider(), filepath, v))
|
||||||
.start();
|
.start();
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_btnDownloadForgeActionPerformed
|
}//GEN-LAST:event_btnDownloadForgeActionPerformed
|
||||||
|
|
||||||
private void btnRetryForgeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRetryForgeActionPerformed
|
|
||||||
if (profile == null) return;
|
|
||||||
MinecraftVersion v = profile.getMinecraftProvider().getVersionById(mcVersion);
|
|
||||||
if (v == null) return;
|
|
||||||
TaskWindow.getInstance().addTask(new ForgeInstaller(profile.getMinecraftProvider(), IOUtils.tryGetCanonicalFile(IOUtils.currentDirWithSeparator() + "forge-installer.jar"))).start();
|
|
||||||
}//GEN-LAST:event_btnRetryForgeActionPerformed
|
|
||||||
|
|
||||||
private void btnRefreshOptifineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRefreshOptifineActionPerformed
|
private void btnRefreshOptifineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRefreshOptifineActionPerformed
|
||||||
optifine.refreshVersions();
|
optifine.refreshVersions();
|
||||||
}//GEN-LAST:event_btnRefreshOptifineActionPerformed
|
}//GEN-LAST:event_btnRefreshOptifineActionPerformed
|
||||||
@ -1023,15 +994,6 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
|||||||
liteloader.refreshVersions();
|
liteloader.refreshVersions();
|
||||||
}//GEN-LAST:event_btnRefreshLiteLoaderActionPerformed
|
}//GEN-LAST:event_btnRefreshLiteLoaderActionPerformed
|
||||||
|
|
||||||
private void btnRetryLiteLoaderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRetryLiteLoaderActionPerformed
|
|
||||||
if (profile == null) return;
|
|
||||||
int idx = lstLiteLoader.getSelectedRow();
|
|
||||||
if (idx == -1) return;
|
|
||||||
InstallerVersion v = liteloader.getVersion(idx);
|
|
||||||
File filepath = new File(IOUtils.currentDir(), "liteloader-universal.jar");
|
|
||||||
TaskWindow.getInstance().addTask(new LiteLoaderInstaller(profile, (LiteLoaderInstallerVersion) v, filepath)).start();
|
|
||||||
}//GEN-LAST:event_btnRetryLiteLoaderActionPerformed
|
|
||||||
|
|
||||||
private void btnDownloadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDownloadActionPerformed
|
private void btnDownloadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDownloadActionPerformed
|
||||||
downloadMinecraft(Settings.getInstance().getDownloadSource());
|
downloadMinecraft(Settings.getInstance().getDownloadSource());
|
||||||
refreshVersions();
|
refreshVersions();
|
||||||
@ -1447,8 +1409,6 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
|||||||
private javax.swing.JButton btnRefreshOptifine;
|
private javax.swing.JButton btnRefreshOptifine;
|
||||||
private javax.swing.JButton btnRefreshVersions;
|
private javax.swing.JButton btnRefreshVersions;
|
||||||
private javax.swing.JButton btnRemoveProfile;
|
private javax.swing.JButton btnRemoveProfile;
|
||||||
private javax.swing.JButton btnRetryForge;
|
|
||||||
private javax.swing.JButton btnRetryLiteLoader;
|
|
||||||
private javax.swing.JComboBox cboGameDirType;
|
private javax.swing.JComboBox cboGameDirType;
|
||||||
private javax.swing.JComboBox cboLauncherVisibility;
|
private javax.swing.JComboBox cboLauncherVisibility;
|
||||||
private javax.swing.JComboBox cboProfiles;
|
private javax.swing.JComboBox cboProfiles;
|
||||||
|
@ -262,7 +262,7 @@ public class TaskWindow extends javax.swing.JDialog
|
|||||||
@Override
|
@Override
|
||||||
public void onFailed(Task task) {
|
public void onFailed(Task task) {
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
failReasons.add(task.getInfo() + ": " + (null == task.getFailReason() ? "No exception" : task.getFailReason().getLocalizedMessage()));
|
failReasons.add(task.getInfo() + ": " + (null == task.getFailReason() ? "No exception" : task.getFailReason().getClass().toString() + ": " + task.getFailReason().getLocalizedMessage()));
|
||||||
pgsTotal.setMaximum(taskList.taskCount());
|
pgsTotal.setMaximum(taskList.taskCount());
|
||||||
pgsTotal.setValue(pgsTotal.getValue() + 1);
|
pgsTotal.setValue(pgsTotal.getValue() + 1);
|
||||||
int idx = tasks.indexOf(task);
|
int idx = tasks.indexOf(task);
|
||||||
|
@ -431,15 +431,4 @@ public class FileUtils {
|
|||||||
if (f.getName().endsWith(suffix)) al.add(f);
|
if (f.getName().endsWith(suffix)) al.add(f);
|
||||||
return al.toArray(new File[0]);
|
return al.toArray(new File[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] toByteArray(File file) throws IOException {
|
|
||||||
try (FileInputStream is = new FileInputStream(file)) {
|
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
||||||
int n;
|
|
||||||
byte[] b = new byte[1024];
|
|
||||||
while ((n = is.read(b)) != -1) os.write(b, 0, n);
|
|
||||||
os.close();
|
|
||||||
return os.toByteArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -195,10 +195,12 @@ class BlockInputStream extends InputStream {
|
|||||||
filterChain = filters[i].getInputStream(filterChain);
|
filterChain = filters[i].getInputStream(filterChain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int read() throws IOException {
|
public int read() throws IOException {
|
||||||
return read(tempBuf, 0, 1) == -1 ? -1 : (tempBuf[0] & 0xFF);
|
return read(tempBuf, 0, 1) == -1 ? -1 : (tempBuf[0] & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int read(byte[] buf, int off, int len) throws IOException {
|
public int read(byte[] buf, int off, int len) throws IOException {
|
||||||
if (endReached)
|
if (endReached)
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user