Skip to content

Commit

Permalink
Added support for legacy config memory
Browse files Browse the repository at this point in the history
  • Loading branch information
blarfoon committed May 2, 2019
1 parent 5a0c31b commit ca03070
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 14 additions & 0 deletions app/actions/instancesManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import log from 'electron-log';
import { spawn } from 'child_process';
import path from 'path';
import { promisify } from 'util';
import _ from 'lodash';
import fs from 'fs';
import launchCommand from '../utils/MCLaunchCommand';
import { PACKS_PATH } from '../constants';
import { readConfig, updateConfig } from '../utils/instances';
import { setJavaArgs } from './settings';

export const SELECT_INSTANCE = 'SELECT_INSTANCE';
export const START_INSTANCE = 'START_INSTANCE';
Expand Down Expand Up @@ -41,6 +44,17 @@ export function startInstance(instanceName) {
return async (dispatch, getState) => {
const { auth, settings } = getState();

// Checks for legacy java memory
const legacyString = [' -Xmx{_RAM_}m', '-Xmx{_RAM_}m'];
const config = await readConfig(instanceName);
if (_.has(config, 'overrideArgs') && config.overrideArgs.includes(legacyString[0]) || config.overrideArgs.includes(legacyString[1])) {
await updateConfig(instanceName, {
overrideArgs: config.overrideArgs.replace(legacyString, '')
});
}
if (settings.java.javaArgs.includes(legacyString[0]) || settings.java.javaArgs.includes(legacyString[1]))
dispatch(setJavaArgs(settings.java.javaArgs.replace(legacyString, '')));

const command = await launchCommand(
instanceName,
auth,
Expand Down
1 change: 0 additions & 1 deletion app/actions/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,3 @@ export function setJavaArgs(args) {
dispatch(saveSettings());
};
}

0 comments on commit ca03070

Please sign in to comment.