Skip to content

Commit

Permalink
allow gzip, change gamedir in the launcher profile, fix launch with t…
Browse files Browse the repository at this point in the history
…he new launcher
  • Loading branch information
robin4002 committed Feb 25, 2017
1 parent fddb153 commit ed486f9
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 76 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ repositories {

group = 'net.minecraftforgefrance'
archivesBaseName = 'installer'
version = '2.2.1'
version = '2.3.0'
targetCompatibility = '1.6'
sourceCompatibility = '1.6'

Expand Down
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Tue May 06 21:57:37 CEST 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip
30 changes: 30 additions & 0 deletions nativelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Set run directory to C:\Program Files (x86)\Minecraft
Native Launcher Version: 1234
Operating System: Windows 10 Home
Application Hash: 7dbb83a4ffb116a3c37230ec727e30298990c365
Application Data directory: C:\Users\robin\AppData\Roaming/.minecraft
Executable Path: MinecraftLauncher.exe
App Directory dir: C:\Program Files (x86)\Minecraft
Start dir: C:/Users/robin/AppData/Roaming/.minecraft
Launcher dir: C:/Program Files (x86)/Minecraft/game
TmpDir dir: C:/Program Files (x86)/Minecraft/tmp
(Optional) Java Launcher hash:
Java Version: 1.8.0_25
x64: 1
LauncherConfiguration from: http://launchermeta.mojang.com/mc/launcher.json
Downloaded config
Native launcher is current
Native launcher is current
Found name of process 9056: \Device\HarddiskVolume5\Program Files\Java\jre1.8.0_121\bin\javaw.exe
Found name of process 8596: \Device\HarddiskVolume5\Program Files\Eclipse\eclipse.exe
Couldn't open handle to process 9048: 87
Detected previous run with new launcher, format of C:/Users/robin/AppData/Roaming/.minecraft/launcher_profiles.json is 2
Using new launcher as self upgrade has been detected.
Launcher library is up to date with hash c023f36c3f0d1929f4dab6ad112ebd097cb4c44c
Check to see if we can run the launcher
Native launcher is current
Starting launcher.dll with C:\Program Files (x86)\Minecraft\runtime\jre-x64\1.8.0_25\bin\javaw.exe
Found SetDllDirectoryW in kernel32.dll!
Added C:\Program Files (x86)\Minecraft\game to DLL search path
Running launcher!
Launcher ended with 0
16 changes: 2 additions & 14 deletions src/main/java/fr/minecraftforgefrance/common/FileChecker.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package fr.minecraftforgefrance.common;

import static fr.minecraftforgefrance.common.Localization.LANG;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
Expand All @@ -12,8 +10,6 @@
import java.util.Collections;
import java.util.List;

import javax.swing.JOptionPane;

import argo.jdom.JsonField;

public class FileChecker
Expand All @@ -26,26 +22,18 @@ public class FileChecker
public List<FileEntry> missingList;
public List<FileEntry> outdatedList;

private final File mcDir;
private final File modPackDir;

public FileChecker(File mcDir)
public FileChecker(File modpackDir)
{
this.mcDir = mcDir;
this.modPackDir = new File(new File(mcDir, "modpacks"), RemoteInfoReader.instance().getModPackName());
this.modPackDir = modpackDir;
DownloadUtils.readRemoteList(this.remoteList, this.checkDir);
this.getLocalFile();
this.compare();
}

private void getLocalFile()
{
if(!this.mcDir.exists() || !this.mcDir.isDirectory())
{
JOptionPane.showMessageDialog(null, LANG.getTranslation("err.mcdirmissing"), LANG.getTranslation("misc.error"), JOptionPane.ERROR_MESSAGE);
return;
}

if(!this.modPackDir.isDirectory())
{
this.modPackDir.delete();
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/fr/minecraftforgefrance/common/ProcessInstall.java
Original file line number Diff line number Diff line change
Expand Up @@ -468,14 +468,14 @@ private void addToProfileList()

if(!isProfileValid(jsonProfileData, modpackName, displayName))
{
JsonField[] fields = null;
JsonField[] fields = new JsonField[RemoteInfoReader.instance().hasArgument() ? 5 : 4];
fields[0] = JsonNodeFactories.field("name", JsonNodeFactories.string(displayName));
fields[1] = JsonNodeFactories.field("lastVersionId", JsonNodeFactories.string(modpackName));
fields[2] = JsonNodeFactories.field("type", JsonNodeFactories.string("custom"));
fields[3] = JsonNodeFactories.field("gameDir", JsonNodeFactories.string(this.modPackDir.getAbsoluteFile().toString()));
if(RemoteInfoReader.instance().hasArgument())
{
fields = new JsonField[] {JsonNodeFactories.field("name", JsonNodeFactories.string(displayName)), JsonNodeFactories.field("lastVersionId", JsonNodeFactories.string(modpackName)), JsonNodeFactories.field("javaArgs", JsonNodeFactories.string(RemoteInfoReader.instance().getArgument()))};
}
else
{
fields = new JsonField[] {JsonNodeFactories.field("name", JsonNodeFactories.string(displayName)), JsonNodeFactories.field("lastVersionId", JsonNodeFactories.string(modpackName))};
fields[4] = JsonNodeFactories.field("javaArgs", JsonNodeFactories.string(RemoteInfoReader.instance().getArgument()));
}

HashMap<JsonStringNode, JsonNode> profileCopy = Maps.newHashMap(jsonProfileData.getNode("profiles").getFields());
Expand Down
60 changes: 35 additions & 25 deletions src/main/java/fr/minecraftforgefrance/common/RemoteInfoReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import static fr.minecraftforgefrance.common.Localization.LANG;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.zip.GZIPInputStream;

import javax.swing.JOptionPane;

Expand Down Expand Up @@ -37,10 +38,8 @@ public boolean init()
{
try
{
URI uri = new URI(this.remoteUrl);
URLConnection connection = uri.toURL().openConnection();
InputStream in = connection.getInputStream();
this.data = this.parser.parse(new InputStreamReader(in, Charsets.UTF_8));
InputStreamReader reader = getRemoteStream(this.remoteUrl);
this.data = this.parser.parse(reader);
return true;
}
catch(InvalidSyntaxException e)
Expand Down Expand Up @@ -72,7 +71,7 @@ public String getModPackName()
{
return this.data.getStringValue("profile", "id");
}

public String getModPackDisplayName()
{
return this.data.getStringValue("install", "name");
Expand All @@ -87,11 +86,11 @@ public String getForgeVersion()
{
return this.data.getStringValue("install", "forge");
}

/**
* An option to manage manually sub-folders
* By default the check of files is recursive, if you put "mods" in the list all folder inside
* "mods" will also be check. If sub-folder is enabled, is it will not be the case and you
* By default the check of files is recursive, if you put "mods" in the list all folder inside
* "mods" will also be check. If sub-folder is enabled, is it will not be the case and you
* need to add "mods/subfolder" in the syncDir to make the installer checking it
* @return true if sub-folder is enabled
*/
Expand Down Expand Up @@ -139,15 +138,13 @@ public boolean hasWhiteList()
{
return this.data.isStringValue("install", "whiteList");
}

public JsonRootNode getWhileList()
{
try
{
URI uri = new URI(this.data.getStringValue("install", "whiteList"));
URLConnection connection = uri.toURL().openConnection();
InputStream in = connection.getInputStream();
return this.parser.parse(new InputStreamReader(in, Charsets.UTF_8));
InputStreamReader reader = getRemoteStream(this.data.getStringValue("install", "whiteList"));
return this.parser.parse(reader);
}
catch(Exception e)
{
Expand Down Expand Up @@ -175,7 +172,7 @@ public String getCredits()
{
return this.data.getStringValue("install", "credits");
}

public boolean hasChangeLog()
{
return this.data.isStringValue("install", "changeLog");
Expand All @@ -185,18 +182,16 @@ public JsonRootNode getChangeLog()
{
try
{
URI uri = new URI(this.data.getStringValue("install", "changeLog"));
URLConnection connection = uri.toURL().openConnection();
InputStream in = connection.getInputStream();
return this.parser.parse(new InputStreamReader(in, Charsets.UTF_8));
InputStreamReader reader = getRemoteStream(this.data.getStringValue("install", "changeLog"));
return this.parser.parse(reader);
}
catch(Exception e)
{
e.printStackTrace();
return null;
}
}

public boolean hasPreset()
{
return this.data.isStringValue("install", "preset");
Expand All @@ -206,20 +201,35 @@ public JsonRootNode getPreset()
{
try
{
URI uri = new URI(this.data.getStringValue("install", "preset"));
URLConnection connection = uri.toURL().openConnection();
InputStream in = connection.getInputStream();
return this.parser.parse(new InputStreamReader(in, Charsets.UTF_8));
InputStreamReader reader = getRemoteStream(this.data.getStringValue("install", "preset"));
return this.parser.parse(reader);
}
catch(Exception e)
{
e.printStackTrace();
return null;
}
}

public String getPresetUrl()
{
return this.data.getStringValue("install", "preset");
}

private InputStreamReader getRemoteStream(String str) throws MalformedURLException, IOException, URISyntaxException
{
URI uri = new URI(str);
URLConnection connection = uri.toURL().openConnection();
connection.setRequestProperty("Accept-Encoding", "gzip");
InputStreamReader reader = null;
if("gzip".equals(connection.getContentEncoding()))
{
reader = new InputStreamReader(new GZIPInputStream(connection.getInputStream()), Charsets.UTF_8);
}
else
{
reader = new InputStreamReader(connection.getInputStream(), Charsets.UTF_8);
}
return reader;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ public InstallerFrame()
public void actionPerformed(ActionEvent e)
{
InstallerFrame.this.dispose();
FileChecker checker = new FileChecker(mcDir);
if(!InstallerFrame.this.mcDir.exists() || !InstallerFrame.this.mcDir.isDirectory())
{
JOptionPane.showMessageDialog(null, LANG.getTranslation("err.mcdirmissing"), LANG.getTranslation("misc.error"), JOptionPane.ERROR_MESSAGE);
return;
}
FileChecker checker = new FileChecker(new File(new File(InstallerFrame.this.mcDir, "modpacks"), RemoteInfoReader.instance().getModPackName()));
ProcessInstall install = new ProcessInstall(checker, InstallerFrame.this, InstallerFrame.this.mcDir, InstallerFrame.this.preSet);
install.createFrame();
}
Expand Down
47 changes: 28 additions & 19 deletions src/main/java/fr/minecraftforgefrance/installer/SuccessFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
public class SuccessFrame extends JDialog
{
private static final long serialVersionUID = 1L;
private boolean launcherExist = false;
private File launcherFile = new File(Installer.frame.mcDir.getPath(), "launcher.jar");
private File launcherFile;

public SuccessFrame()
{
Expand Down Expand Up @@ -50,54 +49,64 @@ public void actionPerformed(ActionEvent e)
}
});
buttonPanel.add(exit);

this.launcherExist = this.launcherFile.exists();
if(!this.launcherExist && EnumOS.getPlatform() == EnumOS.WINDOWS)

if(EnumOS.getPlatform() == EnumOS.WINDOWS)
{
File launcherWithMsi = new File("C:\\Program Files (x86)\\Minecraft\\game\\launcher.jar");
this.launcherExist = launcherWithMsi.exists();
if(System.getenv("ProgramW6432").isEmpty())
{
// 32 bits system
this.launcherFile = new File("C:\\Program Files\\Minecraft\\MinecraftLauncher.exe");
}
else
{
// 64 bits system
this.launcherFile = new File("C:\\Program Files (x86)\\Minecraft\\MinecraftLauncher.exe");
}
}

else
{
this.launcherFile = new File(Installer.frame.mcDir.getPath(), "launcher.jar");
}

JButton runGame = new JButton(LANG.getTranslation("scr.btn.run"));
runGame.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
if(SuccessFrame.this.launcherFile.exists())
if(EnumOS.getPlatform() == EnumOS.WINDOWS)
{
try
{
Runtime.getRuntime().exec(EnumOS.getJavaExecutable() + " -jar " + Installer.frame.mcDir.getPath() + File.separator + "launcher.jar");
Runtime.getRuntime().exec(SuccessFrame.this.launcherFile.getAbsolutePath());
}
catch(IOException ex)
catch(IOException ex2)
{
ex.printStackTrace();
ex2.printStackTrace();
JOptionPane.showMessageDialog(null, LANG.getTranslation("err.runminecraft"), LANG.getTranslation("misc.error"), JOptionPane.ERROR_MESSAGE);
}
}
else if(EnumOS.getPlatform() == EnumOS.WINDOWS)
else
{
// fix for Minecraft installer on Windows
try
{
Runtime.getRuntime().exec(EnumOS.getJavaExecutable() + " -jar " + "\"C:\\Program Files (x86)\\Minecraft\\game\\launcher.jar\"");
Runtime.getRuntime().exec(EnumOS.getJavaExecutable() + " -jar " + SuccessFrame.this.launcherFile.getAbsolutePath());
}
catch(IOException ex2)
catch(IOException ex)
{
ex2.printStackTrace();
ex.printStackTrace();
JOptionPane.showMessageDialog(null, LANG.getTranslation("err.runminecraft"), LANG.getTranslation("misc.error"), JOptionPane.ERROR_MESSAGE);
}
}
SuccessFrame.this.dispose();
}
});
if(this.launcherExist)
if(SuccessFrame.this.launcherFile.exists())
{
buttonPanel.add(runGame);
}
this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);

this.setLocationRelativeTo(null);
}
}
Loading

0 comments on commit ed486f9

Please sign in to comment.