最新のoptions.txtを取得し共通化する
ただしそのままコピペするとマイクラのバージョン互換がないため設定がリセットされる。 そのため必要な部分を抽出してペーストする機構が必要
This commit is contained in:
parent
a57d1eddac
commit
dc72aee727
@ -27,8 +27,6 @@ class ProcessBuilder {
|
||||
this.fmlDir = path.join(this.gameDir, 'forgeModList.json')
|
||||
this.llDir = path.join(this.gameDir, 'liteloaderModList.json')
|
||||
this.libPath = path.join(this.commonDir, 'libraries')
|
||||
this.originalOptionsTxt = path.join(ConfigManager.getInstanceDirectory(), 'Minecraft-1.15.2','options.txt')
|
||||
this.copyOptionsTxt = path.join(this.gameDir, 'options.txt')
|
||||
|
||||
this.usingLiteLoader = false
|
||||
this.llPath = null
|
||||
|
@ -707,19 +707,41 @@ function dlAsync(login = true){
|
||||
// Build Minecraft process.
|
||||
proc = pb.build()
|
||||
|
||||
|
||||
|
||||
//options.txtを共通化する
|
||||
const copy = require('fs')
|
||||
if (!copy.existsSync(pb.copyOptionsTxt) && ConfigManager.getoptionStandardize() && copy.existsSync(pb.originalOptionsTxt)){
|
||||
copy.copyFile(pb.originalOptionsTxt, pb.copyOptionsTxt, (err) => {
|
||||
if (err) {
|
||||
console.log(err.stack)
|
||||
}
|
||||
else {
|
||||
console.log('Done.')
|
||||
const fs = require('fs')
|
||||
const filenames = fs.readdirSync(ConfigManager.getInstanceDirectory())
|
||||
const path = require('path')
|
||||
//共通化のオプションがオンの時かつコピー先オプションファイルが存在しないときコピーを実行する
|
||||
if (ConfigManager.getoptionStandardize() && !fs.existsSync(path.join(pb.gameDir,'options.txt'))){
|
||||
//最新のoptions.txtを取得する
|
||||
let maxMtime = null
|
||||
let optionfilepath = ''
|
||||
filenames.forEach((filename) => {
|
||||
|
||||
const optionPath = path.join(ConfigManager.getInstanceDirectory(),filename,'options.txt')
|
||||
|
||||
if(fs.existsSync(optionPath) ){
|
||||
const stats = fs.statSync(optionPath)
|
||||
if(maxMtime == null || stats.mtime >maxMtime){
|
||||
maxMtime = stats.mtime
|
||||
optionfilepath = optionPath
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
//コピー元ファイルが存在するときコピーを実行する
|
||||
if (maxMtime != null){
|
||||
console.log('options.txtコピー実行 コピー元:'+optionfilepath)
|
||||
fs.copyFile(optionfilepath,path.join(pb.gameDir,'options.txt'),(err)=>{if(err){console.log(err.stack)}})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Bind listeners to stdout.
|
||||
proc.stdout.on('data', tempListener)
|
||||
proc.stderr.on('data', gameErrorListener)
|
||||
|
Loading…
Reference in New Issue
Block a user