Skip to content

Commit

Permalink
Added legacyJavaFixer support
Browse files Browse the repository at this point in the history
  • Loading branch information
blarfoon committed Nov 4, 2018
1 parent a42476d commit 5dc5ec2
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 37 deletions.
31 changes: 23 additions & 8 deletions app/actions/downloadManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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);

Expand Down
4 changes: 4 additions & 0 deletions app/app.global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -396,4 +396,8 @@ a:hover {

.ant-popover-inner-content {
color: white;
}

.ant-message-notice-content {
background: var(--secondary-color-2);
}
7 changes: 4 additions & 3 deletions app/components/Common/SideBar/SideBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class SideBar extends Component<Props> {
style={{ textAlign: 'center', fontWeight: 'italic', fontSize: 12 }}
>
<span>Playing on</span>{' '}
<Popover placement="left" title="Title">
<Popover placement="left" title="Coming Soon">
<b
className={styles.playingServer}
style={{
Expand All @@ -91,15 +91,16 @@ class SideBar extends Component<Props> {
</div>
</div>
<div className={styles.scroller}>
<div style={{ height: 1000 }}>
<h1>Coming Soon</h1>
{/* <div style={{ height: 1000 }}>
<div className={styles.serv}>
AnonymousCraft
<i className="fas fa-play" style={{ marginTop: 3 }} />
</div>
<div className={styles.serv}>HyPixel</div>
<div className={styles.serv}>PvPWars</div>
<div className={styles.serv}>Mineplex</div>
</div>
</div> */}
</div>
<hr />
<div className={styles.socialsContainer}>
Expand Down
2 changes: 2 additions & 0 deletions app/components/Common/SideBar/SideBar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
justify-content: space-between;
height: 25px;
line-height: 25px;
padding-left: 3px;
div:first-child {
position: relative;
right: 10px;
Expand Down Expand Up @@ -90,6 +91,7 @@
height: calc(100% - 60px - 140px - 25px);
width: 200px;
overflow: auto;
text-align: center;
.serv {
position: relative;
padding: 9px 3px;
Expand Down
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class LocalMods extends Component<Props> {
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 };
});
Expand Down
104 changes: 82 additions & 22 deletions app/components/InstanceManagerModal/Settings/ForgeManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -22,7 +23,9 @@ class Instances extends Component<Props> {
state = {
forgeSelectVersion: null,
loadingCompanionDownload: false,
companionModState: false
companionModState: false,
legacyJavaFixerState: false,
loadingLJFDownload: false
};

componentDidMount = async () => {
Expand All @@ -32,6 +35,12 @@ class Instances extends Component<Props> {
);
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 () => {
Expand Down Expand Up @@ -82,6 +91,25 @@ class Instances extends Component<Props> {
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 (
Expand All @@ -93,11 +121,17 @@ class Instances extends Component<Props> {
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 => (
<Select.Option key={Object.keys(ver)[0]} value={Object.keys(ver)[0]}>{Object.keys(ver)[0]}</Select.Option>
)
)}
{this.props.forgeVersions[this.props.data.version] &&
_.reverse(
this.props.forgeVersions[this.props.data.version].slice()
).map(ver => (
<Select.Option
key={Object.keys(ver)[0]}
value={Object.keys(ver)[0]}
>
{Object.keys(ver)[0]}
</Select.Option>
))}
</Select>
<br />
<Button
Expand Down Expand Up @@ -129,24 +163,50 @@ class Instances extends Component<Props> {
</Button>
</div>
<div>
Companion Mod{' '}
<Tooltip
title="The Companion Mod is an optional feature that allows us to keep track of actions happening in the game.
<div>
Companion Mod{' '}
<Tooltip
title="The Companion Mod is an optional feature that allows us to keep track of actions happening in the game.
This way we can create more precise stats on the instance."
>
<Icon
type="info-circle"
theme="filled"
className={styles.companionModInfo}
>
<Icon
type="info-circle"
theme="filled"
className={styles.companionModInfo}
/>
</Tooltip>
<br />
<Switch
onChange={this.companionModSwitchChange}
checked={this.state.companionModState}
loading={this.state.loadingCompanionDownload}
style={{ marginTop: 10 }}
/>
</Tooltip>
<br />
<Switch
onChange={this.companionModSwitchChange}
checked={this.state.companionModState}
loading={this.state.loadingCompanionDownload}
style={{ marginTop: 10 }}
/>
</div>
{vCompare(
this.props.data.forgeVersion.includes('-')
? this.props.data.forgeVersion.split('-')[1]
: this.props.data.forgeVersion,
'10.13.1.1217'
) === -1 && (
<div style={{ marginTop: 15 }}>
Java Legacy Fixer{' '}
<Tooltip title="This is a mod to fix compatibility issues between old versions of forge and newest versions of Java.">
<Icon
type="info-circle"
theme="filled"
className={styles.companionModInfo}
/>
</Tooltip>
<br />
<Switch
onChange={this.legacyJavaFixerModSwitchChange}
checked={this.state.legacyJavaFixerState}
loading={this.state.loadingLJFDownload}
style={{ marginTop: 10 }}
/>
</div>
)}
</div>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions app/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 0 additions & 2 deletions app/utils/MCLaunchCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '');
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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\"",
Expand Down

0 comments on commit 5dc5ec2

Please sign in to comment.