fix: Dependency cycles
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
b95b4f6928
commit
12b3973b38
@ -1,3 +1,5 @@
|
|||||||
|
import { NativePluginManager } from './native_plugin'
|
||||||
|
|
||||||
export namespace server {
|
export namespace server {
|
||||||
/**
|
/**
|
||||||
* Runtime ServerType
|
* Runtime ServerType
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
interface NativePluginManager {
|
export interface NativePluginManager {
|
||||||
load(name: string): boolean;
|
load(name: string): boolean;
|
||||||
unload(name: string): boolean;
|
unload(name: string): boolean;
|
||||||
reload(name: string): boolean;
|
reload(name: string): boolean;
|
||||||
|
@ -41,7 +41,7 @@ export class BukkitServer implements server.Server {
|
|||||||
return this.pluginsFolder;
|
return this.pluginsFolder;
|
||||||
}
|
}
|
||||||
getNativePluginManager() {
|
getNativePluginManager() {
|
||||||
throw new Error("Method not implemented.");
|
return Bukkit.getPluginManager() as any;
|
||||||
}
|
}
|
||||||
sendJson(sender: string | any, json: object | string): void {
|
sendJson(sender: string | any, json: object | string): void {
|
||||||
if (typeof sender === "string") {
|
if (typeof sender === "string") {
|
||||||
|
@ -39,7 +39,7 @@ export class BungeeServer implements server.Server {
|
|||||||
return this.pluginsFolder;
|
return this.pluginsFolder;
|
||||||
}
|
}
|
||||||
getNativePluginManager() {
|
getNativePluginManager() {
|
||||||
throw new Error("Method not implemented.");
|
return Bungee.getPluginManager() as any
|
||||||
}
|
}
|
||||||
sendJson(sender: string | any, json: string): void {
|
sendJson(sender: string | any, json: string): void {
|
||||||
throw new Error("Method not implemented.");
|
throw new Error("Method not implemented.");
|
||||||
|
@ -28,9 +28,6 @@
|
|||||||
"typescript": "^3.8.3"
|
"typescript": "^3.8.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ms/common": "^0.3.0",
|
|
||||||
"@ms/container": "^0.3.0",
|
|
||||||
"@ms/ployfill": "^0.3.0",
|
|
||||||
"js-yaml": "^3.13.1"
|
"js-yaml": "^3.13.1"
|
||||||
},
|
},
|
||||||
"gitHead": "781524f83e52cad26d7c480513e3c525df867121"
|
"gitHead": "781524f83e52cad26d7c480513e3c525df867121"
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import '@ms/ployfill'
|
/// <reference types="@ms/types/dist/typings/nashorn" />
|
||||||
|
/// <reference types="@ms/ployfill" />
|
||||||
import * as yaml from 'js-yaml'
|
import * as yaml from 'js-yaml'
|
||||||
|
|
||||||
import * as fs from '@ms/common/dist/fs'
|
const File = Java.type("java.io.File");
|
||||||
|
const separatorChar = File.separatorChar;
|
||||||
|
|
||||||
let langMap = {};
|
let langMap = {};
|
||||||
let fallbackMap = {};
|
let fallbackMap = {};
|
||||||
@ -18,16 +20,24 @@ function translate(name: string, param?: TranslateParam) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initialize(lang: string = 'zh_cn', fallback: string = 'zh_cn') {
|
function initialize(lang: string = 'zh_cn', fallback: string = 'zh_cn') {
|
||||||
langMap = readYamlFile(root, lang) || readYamlFile(fs.concat(__dirname, '..'), lang)
|
langMap = readYamlFile(root, lang) || readYamlFile(concat(__dirname, '..'), lang)
|
||||||
fallbackMap = readYamlFile(root, fallback) || readYamlFile(fs.concat(__dirname, '..'), fallback)
|
fallbackMap = readYamlFile(root, fallback) || readYamlFile(concat(__dirname, '..'), fallback)
|
||||||
console.i18n = function i18n(name: string, param?: TranslateParam) {
|
console.i18n = function i18n(name: string, param?: TranslateParam) {
|
||||||
console.log(translate(name, param))
|
console.log(translate(name, param))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function readYamlFile(dir: string, name: string) {
|
function readYamlFile(dir: string, name: string) {
|
||||||
let langFile = fs.concat(dir, 'languages', name + '.yml');
|
let langFile = concat(dir, 'languages', name + '.yml');
|
||||||
return fs.exists(langFile) && yaml.safeLoad(base.read(langFile))
|
return exists(langFile) && yaml.safeLoad(base.read(langFile))
|
||||||
|
}
|
||||||
|
|
||||||
|
function concat(...args: string[]) {
|
||||||
|
return args.join(separatorChar)
|
||||||
|
}
|
||||||
|
|
||||||
|
function exists(path: string) {
|
||||||
|
return new File(path).exists()
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
@ -40,7 +40,7 @@ export class NukkitServer implements server.Server {
|
|||||||
return this.pluginsFolder;
|
return this.pluginsFolder;
|
||||||
}
|
}
|
||||||
getNativePluginManager() {
|
getNativePluginManager() {
|
||||||
throw new Error("Method not implemented.");
|
return Nukkit.getPluginManager() as any;
|
||||||
}
|
}
|
||||||
sendJson(sender: string | any, json: object | string): void {
|
sendJson(sender: string | any, json: object | string): void {
|
||||||
throw new Error("Method not implemented.");
|
throw new Error("Method not implemented.");
|
||||||
|
@ -44,7 +44,7 @@ export class SpongeServer implements server.Server {
|
|||||||
return this.pluginsFolder;
|
return this.pluginsFolder;
|
||||||
}
|
}
|
||||||
getNativePluginManager() {
|
getNativePluginManager() {
|
||||||
throw new Error("Method not implemented.");
|
return Sponge.getPluginManager() as any;
|
||||||
}
|
}
|
||||||
sendJson(sender: string | any, json: string): void {
|
sendJson(sender: string | any, json: string): void {
|
||||||
if (typeof sender === "string") {
|
if (typeof sender === "string") {
|
||||||
|
Loading…
Reference in New Issue
Block a user