Skip to content

Commit

Permalink
Fix GDL to work on osx and minor tweaks (#283)
Browse files Browse the repository at this point in the history
* fix concurrent downloads (#253)

* Disable i18n debug logging (#243)

Disabled i18n debug logging to cleanup dev tools console

* Hotfix for login

* Fixed forge patching on paths with whitespaces

* v0.12.3

* fixed concurrent downloads

* Fix typo in rule checking rules for deps jars and natives.

* Changed how libs from json are scanned so osx can now run mc.

* Removed my debug text and fixed missing quotes around forge installers last step for lmza.

* Fixed name in array for windows.
Correctly added double qoutes around the last part of forge installer.
Added some logging of forge installation.

* Minor change, removed extra double qoutes from cp path string creation.

* very small text change.

* :Made it easier to tell release channel has to do with GDL and not curseforge mods.

* Up Version Number

* Removed TODOs.
Correct bad copy paste from figuring out back quotes.

* rename to suggested.

* one more text replacement on home.

* Changed try out card to use latest release from mojang manifest instead of hard coded version.

* removed unneeded

Co-authored-by: Davide Ceschia <[email protected]>
  • Loading branch information
TOLoneWolf and blarfoon committed Jan 4, 2020
1 parent 5ba5634 commit 5aeff5b
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 59 deletions.
19 changes: 13 additions & 6 deletions app/actions/downloadManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,13 +480,12 @@ export function downloadPack(pack, isRepair = false) {
if (installProfileJson.data[finalArg]) {
// Handle special case
if (finalArg === 'BINPATCH') {
return path
.join(
INSTANCES_PATH,
return '"' + path
.join(INSTANCES_PATH,
'libraries',
...arraify(installProfileJson.path)
...arraify(installProfileJson.path),
)
.replace('.jar', '-clientdata.lzma');
.replace('.jar', '-clientdata.lzma') + '"';
}
// Return replaced string
return installProfileJson.data[finalArg].client;
Expand Down Expand Up @@ -524,14 +523,22 @@ export function downloadPack(pack, isRepair = false) {
const jarFile = await promisify(jarAnalyzer.fetchJarAtPath)(filePath);
const mainClass = jarFile.valueForManifestEntry('Main-Class');

var currentProcess = (processors[p].jar).split(':')[1]
log.info(`Forge installer [${i}/${processors.length}]: ${currentProcess} - starting.`);

const { stderr, stdout } = await promisify(exec)(
`"${javaPath}" -classpath "${filePath}${CLASSPATH_DIVIDER_CHAR}${classPaths.join(
CLASSPATH_DIVIDER_CHAR
)}" ${mainClass} ${args.join(' ')}`,
{ maxBuffer: 10000000000 }
);

log.error(stderr);
if (stderr) {
log.info(`Forge installer [${i}/${processors.length}]: ${currentProcess} - Finished with error.`);
log.error(stderr);
} else {
log.info(`Forge installer [${i}/${processors.length}]: ${currentProcess} - Finished.`);
}
dispatch(updateDownloadProgress(90, 10, i, processors.length));
}
}
Expand Down
57 changes: 32 additions & 25 deletions app/components/Home/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,18 @@ export default class Home extends Component<Props> {
}

componentDidMount = async () => {
try {
await promisify(fs.access)(path.join(PACKS_PATH, '1.13.2'));
this.setState({ latestInstalled: true });
} catch (e) {
this.setState({ latestInstalled: false });
}
// Downloads the versions list just the first time
if (this.props.versionsManifest.length === 0) {
this.props.getVanillaMCVersions();
}
if (this.props.latestMCVersions.release) {
try {
await promisify(fs.access)(path.join(PACKS_PATH, this.props.latestMCVersions.release));
this.setState({ latestInstalled: true });
} catch (e) {
this.setState({ latestInstalled: false });
}
}
};

/* eslint-enable */
Expand Down Expand Up @@ -106,28 +108,33 @@ export default class Home extends Component<Props> {
marginTop: 15,
textAlign: 'center'
}}
title="Try out the new v1.13.2"
title={`Try out the newest release of minecraft`}
>
V1.13.2 has just been released. Wanna try it out?
{this.state.latestBtnClicked || this.state.latestInstalled ? (
<Link
to="/dmanager"
style={{ display: 'block', margin: '35px auto' }}
>
Go to your instances
</Link>
<div>
<p>&nbsp;</p>
<Link
to="/dmanager"
style={{ display: 'block', margin: '35px auto' }}
>
Latest installed, go to instances to start playing.
</Link>
</div>
) : (
<Button
type="primary"
loading={this.props.packCreationLoading}
style={{ display: 'block', margin: '35px auto' }}
onClick={() => {
this.props.createPack('1.13.2', '1.13.2');
this.setState({ latestBtnClicked: true });
}}
>
Install and Start v1.13.2
</Button>
<div>
<p>{this.props.latestMCVersions.release} has just been released. Wanna try it out?</p>
<Button
type="primary"
loading={this.props.packCreationLoading}
style={{ display: 'block', margin: '35px auto' }}
onClick={() => {
this.props.createPack(this.props.latestMCVersions.release, this.props.latestMCVersions.release);
this.setState({ latestBtnClicked: true });
}}
>
Install {this.props.latestMCVersions.release}
</Button>
</div>
)}
</Card>
</div>
Expand Down
3 changes: 2 additions & 1 deletion app/components/Home/containers/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ function mapStateToProps(state) {
newUser: state.auth.newUser,
news: state.news,
packCreationLoading: state.packCreator.loading,
versionsManifest: state.packCreator.versionsManifest
versionsManifest: state.packCreator.versionsManifest,
latestMCVersions: state.packCreator.latestMCVersions
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const MyAccount = props => {
onChange={props.setSounds}
/>
<SelectSetting
mainText={<span>{t('ReleaseChannel', 'Release Channel')}</span>}
mainText={<span>{t('ReleaseChannel', 'GDLauncher Release Channel')}</span>}
description={t('ReleaseChannelDescription', 'Stable updates once a month, beta does update more often but it may have more bugs.')}
icon="rocket"
onChange={v => {
Expand Down
4 changes: 3 additions & 1 deletion app/reducers/packCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {

const initialState = {
versionsManifest: [],
latestMCVersions: [],
forgeManifest: {},
loading: false
};
Expand All @@ -16,7 +17,8 @@ export default function packManager(state = initialState, action) {
case `${GET_MC_VANILLA_VERSIONS}`:
return {
...state,
versionsManifest: action.payload.versions
versionsManifest: action.payload.versions,
latestMCVersions: action.payload.latest
};
case `${GET_FORGE_MANIFEST}`:
return {
Expand Down
13 changes: 9 additions & 4 deletions app/utils/MCLaunchCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ const getStartCommand = async (packName, userData, settings, javaArguments) => {
os.release().substr(0, 2) === 10
? '"-Dos.name=Windows 10" -Dos.version=10.0 '
: '';
// If OSX and 1.13+ then we need something special to be added.
const OSX_XstartOnFirstThread =
os.type() === 'Darwin' && vanillaJSON.arguments
? '-XstartOnFirstThread'
: '';
// It concatenates vanilla and forge libraries. If the instance does not contain forge, it concatenates an empty array
const libs = await computeVanillaAndForgeLibraries(vanillaJSON, forgeJSON);
const Arguments = getMCArguments(
Expand All @@ -77,7 +82,7 @@ const getStartCommand = async (packName, userData, settings, javaArguments) => {
"${javaPath}" ${config.overrideArgs ||
javaArguments} -Xmx${instanceConfigJSON.overrideMemory ||
settings.java.memory}m ${dosName} -Djava.library.path="${path.join(
settings.java.memory}m ${dosName} ${OSX_XstartOnFirstThread} -Djava.library.path="${path.join(
PACKS_PATH,
packName,
'natives'
Expand All @@ -88,10 +93,10 @@ const getStartCommand = async (packName, userData, settings, javaArguments) => {
vanillaJSON.id,
`${vanillaJSON.id}.jar`
)}"
-cp ${libs
-cp "${libs
.filter(lib => !lib.natives)
.map(lib => `"${lib.path}"`)
.join(CLASSPATH_DIVIDER_CHAR)}${CLASSPATH_DIVIDER_CHAR}${`"${path.join(
.map(lib => `${lib.path}`)
.join(CLASSPATH_DIVIDER_CHAR)}"${CLASSPATH_DIVIDER_CHAR}${`"${path.join(
INSTANCES_PATH,
'versions',
vanillaJSON.id,
Expand Down
48 changes: 28 additions & 20 deletions app/utils/getMCFilesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import makeDir from 'make-dir';
import SysOS from 'os';
import { promisify } from 'util';
import compressing from 'compressing';
import log from 'electron-log';
import {
INSTANCES_PATH,
PACKS_PATH,
Expand All @@ -24,7 +25,14 @@ export const extractMainJar = async json => {
};

export const extractVanillaLibs = async json => {
log.info("Parsing json version for libraries");
const libs = [];
const MC_OS_Lookup = {
// Mojang gave osx different names in parts of different versions..
Darwin: ['osx', 'macos'],
Windows_NT: ['windows', 'windows-64'],
Linux: ['linux']
};
await Promise.all(
json.libraries
.filter(lib => !parseLibRules(lib.rules))
Expand All @@ -39,24 +47,24 @@ export const extractVanillaLibs = async json => {
)
});
}
if (
'classifiers' in lib.downloads &&
`natives-${convertOSToMCFormat(SysOS.type())}` in
lib.downloads.classifiers
) {
libs.push({
url:
lib.downloads.classifiers[
`natives-${convertOSToMCFormat(SysOS.type())}`
].url,
path: path.join(
INSTANCES_PATH,
'libraries',
lib.downloads.classifiers[
`natives-${convertOSToMCFormat(SysOS.type())}`
].path
),
natives: true
if ('classifiers' in lib.downloads) {
MC_OS_Lookup[SysOS.type()].forEach(os_type => {
if (`natives-${os_type}` in lib.downloads.classifiers) {
libs.push({
url:
lib.downloads.classifiers[
`natives-${os_type}`
].url,
path: path.join(
INSTANCES_PATH,
'libraries',
lib.downloads.classifiers[
`natives-${os_type}`
].path
),
natives: true
});
}
});
}
})
Expand Down Expand Up @@ -201,13 +209,13 @@ function parseLibRules(rules) {
rules.forEach(({ action, os }) => {
if (
action === 'allow' &&
((os && SysOS.name === convertOSToMCFormat(SysOS.type())) || !os)
((os && os.name === convertOSToMCFormat(SysOS.type())) || !os)
) {
skip = false;
}
if (
action === 'disallow' &&
((os && SysOS.name === convertOSToMCFormat(SysOS.type())) || !os)
((os && os.name === convertOSToMCFormat(SysOS.type())) || !os)
) {
skip = true;
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gdlauncher",
"version": "0.12.3",
"version": "0.12.4",
"description": "GDLauncher is simple, yet powerful Minecraft custom launcher with a strong focus on the user experience",
"keywords": [
"minecraft",
Expand Down Expand Up @@ -47,6 +47,7 @@
"package-ci": "yarn postinstall && yarn build && cross-env ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true electron-builder --publish onTag",
"package-linux": "yarn build && cross-env ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true electron-builder build --linux",
"package-win": "yarn build && cross-env ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true electron-builder build --win --x64",
"package-osx": "yarn build && cross-env ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true electron-builder build --mac",
"postinstall": "yarn flow-typed && cross-env ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true cross-env ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true electron-builder install-app-deps package.json && yarn build-dll",
"postlint-fix": "prettier --ignore-path .eslintignore --single-quote --write '**/*.{js,jsx,json,html,css,less,scss,yml}'",
"postlint-styles-fix": "prettier --ignore-path .eslintignore --single-quote --write '**/*.{css,scss}'",
Expand Down

0 comments on commit 5aeff5b

Please sign in to comment.