@ -21,7 +21,7 @@
|
||||
"devDependencies": {
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.17.0",
|
||||
|
@ -51,34 +51,34 @@ function detectServer(): constants.ServerType {
|
||||
try {
|
||||
Java.type("org.bukkit.Bukkit")
|
||||
return constants.ServerType.Bukkit
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
}
|
||||
try {
|
||||
Java.type("org.spongepowered.api.Sponge")
|
||||
return constants.ServerType.Sponge
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
}
|
||||
try {
|
||||
Java.type("cn.nukkit.Nukkit")
|
||||
return constants.ServerType.Nukkit
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
}
|
||||
try {
|
||||
Java.type("net.md_5.bungee.api.ProxyServer")
|
||||
return constants.ServerType.Bungee
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
}
|
||||
try {
|
||||
Java.type("org.springframework.boot.SpringApplication")
|
||||
return constants.ServerType.Spring
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
}
|
||||
throw Error('Unknow Server Type...')
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
global.ScriptEngineVersion = require('../package.json').version
|
||||
try { engineLoad({ script: http.get("http://ms.yumc.pw/api/plugin/download/name/initialize"), name: 'core/initialize.js' }) } catch (error) { console.debug(error) }
|
||||
try { engineLoad({ script: http.get("http://ms.yumc.pw/api/plugin/download/name/initialize"), name: 'core/initialize.js' }) } catch (error: any) { console.debug(error) }
|
||||
try {
|
||||
let corePackageStartTime = new Date().getTime()
|
||||
container.bind(ContainerInstance).toConstantValue(container)
|
||||
@ -97,7 +97,7 @@ function initialize() {
|
||||
let disable = container.get<MiaoScriptCore>(MiaoScriptCore).enable()
|
||||
console.i18n("ms.core.engine.completed", { version: 'v' + global.ScriptEngineVersion, time: (Date.now() - global.ScriptEngineStartTime) / 1000 })
|
||||
return disable
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.i18n("ms.core.initialize.error", { error })
|
||||
console.ex(error)
|
||||
return () => console.i18n('ms.core.engine.disable.abnormal')
|
||||
|
38
packages/core/src/initialize.js
Normal file
38
packages/core/src/initialize.js
Normal file
@ -0,0 +1,38 @@
|
||||
function initialize() {
|
||||
var mspmc = 'http://ms.yumc.pw/api/plugin/download/name/'
|
||||
|
||||
var http = require('@ccms/common/dist/http').default
|
||||
var fs = require('@ccms/common/dist/fs')
|
||||
var yaml = require('js-yaml')
|
||||
|
||||
var pluginFolder = fs.concat(root, 'plugins')
|
||||
var updateFolder = fs.concat(pluginFolder, 'update')
|
||||
var pluginFile = fs.concat(pluginFolder, 'MiaoScriptPackageManager.js')
|
||||
if (!fs.exists(pluginFile)) {
|
||||
fs.mkdirs(pluginFile)
|
||||
base.save(fs.concat(updateFolder, 'MiaoScriptPackageManager.auto.install'), '.')
|
||||
}
|
||||
fs.list(updateFolder).forEach(function (path) {
|
||||
var file = path.toFile()
|
||||
if (file.exists()) {
|
||||
var filename = file.getName()
|
||||
if (filename.endsWith(".auto.install")) {
|
||||
var pluginName = filename.replace('.auto.install', '')
|
||||
var pluginFile = fs.concat(pluginFolder, pluginName + '.js')
|
||||
if (!fs.exists(pluginFile)) {
|
||||
var pluginTemp = pluginFile + '.tmp'
|
||||
http.download(mspmc + pluginName, pluginTemp)
|
||||
fs.move(pluginTemp, pluginFile, true)
|
||||
}
|
||||
base.delete(file)
|
||||
}
|
||||
}
|
||||
})
|
||||
var core = http.get('https://registry.npmmirror.com/@ccms/core')
|
||||
if (global.ScriptEngineVersion != core['dist-tags']['latest']) {
|
||||
var Paths = Java.type('java.nio.file.Paths')
|
||||
base.save(Paths.get(root, "upgrade"), core['dist-tags']['latest'])
|
||||
}
|
||||
console.debug('initialize finish!')
|
||||
}
|
||||
initialize()
|
Reference in New Issue
Block a user