From 5dc5ec282b87406490bff35f7bd19f3aedcd8b26 Mon Sep 17 00:00:00 2001 From: Davide Ceschia Date: Sun, 4 Nov 2018 17:21:10 +0100 Subject: [PATCH] Added legacyJavaFixer support --- app/actions/downloadManager.js | 31 ++++-- app/app.global.scss | 4 + app/components/Common/SideBar/SideBar.js | 7 +- app/components/Common/SideBar/SideBar.scss | 2 + .../CurseModpacksBrowserModal.js | 0 .../CurseModpacksBrowserModal.scss | 0 .../ModsManager/LocalMods/LocalMods.js | 2 +- .../Settings/ForgeManager.js | 104 ++++++++++++++---- app/constants.js | 1 + app/utils/MCLaunchCommand.js | 2 - package.json | 2 +- 11 files changed, 118 insertions(+), 37 deletions(-) create mode 100644 app/components/CurseModpacksBrowserModal/CurseModpacksBrowserModal.js create mode 100644 app/components/CurseModpacksBrowserModal/CurseModpacksBrowserModal.scss diff --git a/app/actions/downloadManager.js b/app/actions/downloadManager.js index bb14c3f34..3a8b32d7c 100644 --- a/app/actions/downloadManager.js +++ b/app/actions/downloadManager.js @@ -4,10 +4,15 @@ import { promisify } from 'util'; import axios from 'axios'; import makeDir from 'make-dir'; import fs from 'fs'; -import _ from 'lodash'; import Zip from 'adm-zip'; import { downloadFile, downloadArr } from '../utils/downloader'; -import { PACKS_PATH, INSTANCES_PATH, META_PATH } from '../constants'; +import { + PACKS_PATH, + INSTANCES_PATH, + META_PATH, + GDL_LEGACYJAVAFIXER_MOD_URL +} from '../constants'; +import vCompare from '../utils/versionsCompare'; import { extractAssets, extractMainJar, @@ -180,7 +185,16 @@ export function downloadPack(pack) { }) ); - const totalFiles = libraries.length + assets.length + mainJar.length; + const legacyJavaFixer = + vCompare(currPack.forgeVersion, '10.13.1.1217') === -1 + ? { + url: GDL_LEGACYJAVAFIXER_MOD_URL, + path: path.join(PACKS_PATH, pack, 'mods', 'LJF.jar') + } + : null; + + const totalFiles = + libraries.length + assets.length + mainJar.length; dispatch({ type: UPDATE_TOTAL_FILES_TO_DOWNLOAD, @@ -202,11 +216,12 @@ export function downloadPack(pack) { }); }; - await downloadArr( - [...libraries, ...assets, ...mainJar], - updatePercentage, - pack - ); + const allFiles = + legacyJavaFixer !== null + ? [...libraries, ...assets, ...mainJar, legacyJavaFixer] + : [...libraries, ...assets, ...mainJar]; + + await downloadArr(allFiles, updatePercentage, pack); await extractNatives(libraries.filter(lib => 'natives' in lib), pack); diff --git a/app/app.global.scss b/app/app.global.scss index 75d3137ab..999771aca 100644 --- a/app/app.global.scss +++ b/app/app.global.scss @@ -396,4 +396,8 @@ a:hover { .ant-popover-inner-content { color: white; +} + +.ant-message-notice-content { + background: var(--secondary-color-2); } \ No newline at end of file diff --git a/app/components/Common/SideBar/SideBar.js b/app/components/Common/SideBar/SideBar.js index b381a7354..38319d6e0 100644 --- a/app/components/Common/SideBar/SideBar.js +++ b/app/components/Common/SideBar/SideBar.js @@ -67,7 +67,7 @@ class SideBar extends Component { style={{ textAlign: 'center', fontWeight: 'italic', fontSize: 12 }} > Playing on{' '} - + {
-
+

Coming Soon

+ {/*
AnonymousCraft @@ -99,7 +100,7 @@ class SideBar extends Component {
HyPixel
PvPWars
Mineplex
-
+
*/}

diff --git a/app/components/Common/SideBar/SideBar.scss b/app/components/Common/SideBar/SideBar.scss index bb399b46f..ba8f479b0 100644 --- a/app/components/Common/SideBar/SideBar.scss +++ b/app/components/Common/SideBar/SideBar.scss @@ -60,6 +60,7 @@ justify-content: space-between; height: 25px; line-height: 25px; + padding-left: 3px; div:first-child { position: relative; right: 10px; @@ -90,6 +91,7 @@ height: calc(100% - 60px - 140px - 25px); width: 200px; overflow: auto; + text-align: center; .serv { position: relative; padding: 9px 3px; diff --git a/app/components/CurseModpacksBrowserModal/CurseModpacksBrowserModal.js b/app/components/CurseModpacksBrowserModal/CurseModpacksBrowserModal.js new file mode 100644 index 000000000..e69de29bb diff --git a/app/components/CurseModpacksBrowserModal/CurseModpacksBrowserModal.scss b/app/components/CurseModpacksBrowserModal/CurseModpacksBrowserModal.scss new file mode 100644 index 000000000..e69de29bb diff --git a/app/components/InstanceManagerModal/ModsManager/LocalMods/LocalMods.js b/app/components/InstanceManagerModal/ModsManager/LocalMods/LocalMods.js index 12930d85b..94b865b9e 100644 --- a/app/components/InstanceManagerModal/ModsManager/LocalMods/LocalMods.js +++ b/app/components/InstanceManagerModal/ModsManager/LocalMods/LocalMods.js @@ -82,7 +82,7 @@ class LocalMods extends Component { let mods = (await fs.readdirAsync( path.join(PACKS_PATH, this.props.match.params.instance, 'mods') )) - .filter(el => el !== 'GDLCompanion.jar') + .filter(el => el !== 'GDLCompanion.jar' && el !== 'LJF.jar') .map(el => { return { name: el, state: path.extname(el) !== '.disabled', key: el }; }); diff --git a/app/components/InstanceManagerModal/Settings/ForgeManager.js b/app/components/InstanceManagerModal/Settings/ForgeManager.js index 9b04a1174..8a2dee98f 100644 --- a/app/components/InstanceManagerModal/Settings/ForgeManager.js +++ b/app/components/InstanceManagerModal/Settings/ForgeManager.js @@ -11,6 +11,7 @@ import * as packCreatorActions from '../../../actions/packCreator'; import * as downloadManagerActions from '../../../actions/downloadManager'; import { downloadFile } from '../../../utils/downloader'; import { PACKS_PATH, GDL_COMPANION_MOD_URL } from '../../../constants'; +import vCompare from '../../../utils/versionsCompare'; import colors from '../../../style/theme/colors.scss'; import styles from './ForgeManager.scss'; @@ -22,7 +23,9 @@ class Instances extends Component { state = { forgeSelectVersion: null, loadingCompanionDownload: false, - companionModState: false + companionModState: false, + legacyJavaFixerState: false, + loadingLJFDownload: false }; componentDidMount = async () => { @@ -32,6 +35,12 @@ class Instances extends Component { ); this.setState({ companionModState: true }); } catch (err) {} + try { + await promisify(fs.access)( + path.join(PACKS_PATH, this.props.name, 'mods', 'LJF.jar') + ); + this.setState({ legacyJavaFixerState: true }); + } catch (err) {} }; removeForge = async () => { @@ -82,6 +91,25 @@ class Instances extends Component { this.setState({ loadingCompanionDownload: false }); }; + legacyJavaFixerModSwitchChange = async value => { + this.setState({ loadingLJFDownload: true }); + if (value) { + await makeDir(path.join(PACKS_PATH, this.props.name, 'mods')); + await downloadFile( + path.join(PACKS_PATH, this.props.name, 'mods', 'LJF.jar'), + GDL_COMPANION_MOD_URL, + () => {} + ); + this.setState({ legacyJavaFixerState: true }); + } else { + await promisify(fs.unlink)( + path.join(PACKS_PATH, this.props.name, 'mods', 'LJF.jar') + ); + this.setState({ legacyJavaFixerState: false }); + } + this.setState({ loadingLJFDownload: false }); + }; + render() { if (this.props.data.forgeVersion === null) { return ( @@ -93,11 +121,17 @@ class Instances extends Component { notFoundContent="No version found" onChange={this.handleForgeVersionChange} > - {this.props.forgeVersions[this.props.data.version] && _.reverse(this.props.forgeVersions[this.props.data.version].slice()).map( - ver => ( - {Object.keys(ver)[0]} - ) - )} + {this.props.forgeVersions[this.props.data.version] && + _.reverse( + this.props.forgeVersions[this.props.data.version].slice() + ).map(ver => ( + + {Object.keys(ver)[0]} + + ))}
- Companion Mod{' '} - - + + +
+ - -
- +
+ {vCompare( + this.props.data.forgeVersion.includes('-') + ? this.props.data.forgeVersion.split('-')[1] + : this.props.data.forgeVersion, + '10.13.1.1217' + ) === -1 && ( +
+ Java Legacy Fixer{' '} + + + +
+ +
+ )}
); diff --git a/app/constants.js b/app/constants.js index b7c9b9740..c8e6318ec 100644 --- a/app/constants.js +++ b/app/constants.js @@ -29,6 +29,7 @@ export const MC_LIBRARIES_URL = 'https://libraries.minecraft.net'; export const LOGIN_PROXY_API = 'https://api.gdevs.io/auth'; export const LOGIN_TOKEN_PROXY_API = 'https://api.gdevs.io/authToken'; export const GDL_COMPANION_MOD_URL = 'https://gdevs.io/GDLCompanion.jar'; +export const GDL_LEGACYJAVAFIXER_MOD_URL = 'https://gdevs.io/legacyjavafixer-1.0.jar'; export const CURSEMETA_API_URL = `https://staging_cursemeta.dries007.net/api/v3`; export const CURSEFORGE_MODLOADERS_API = 'https://modloaders.cursecdn.com/647622546/maven'; diff --git a/app/utils/MCLaunchCommand.js b/app/utils/MCLaunchCommand.js index e49d40ba1..583dc7ba8 100644 --- a/app/utils/MCLaunchCommand.js +++ b/app/utils/MCLaunchCommand.js @@ -33,8 +33,6 @@ ${os.platform() === WINDOWS ? '-XX:HeapDumpPath=MojangTricksIntelDriversForPerfo .join(dividerChar)}${dividerChar}${`"${path.join(INSTANCES_PATH, 'versions', vanillaJSON.id, `${vanillaJSON.id}.jar`)}"`} ${mainClass} ${Arguments} `; - - console.log(completeCMD.replace(/\n|\r/g, '')) return completeCMD.replace(/\n|\r/g, ''); }; diff --git a/package.json b/package.json index 664617f31..501975c9e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "gdlauncher", "productName": "GDLauncher", "main": "./app/main.prod.js", - "version": "0.8.1", + "version": "0.8.2", "description": "GDLauncher is simple, yet powerful Minecraft custom launcher with a strong focus on the user experience", "scripts": { "build": "yarn build-antd && concurrently \"yarn build-main\" \"yarn build-renderer\"",