fix: Dependency cycles
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
8c12319dc9
commit
6ada3e41d0
@ -1,3 +1,5 @@
|
||||
import { NativePluginManager } from './native_plugin'
|
||||
|
||||
export namespace server {
|
||||
/**
|
||||
* Runtime ServerType
|
||||
|
@ -1,4 +1,4 @@
|
||||
interface NativePluginManager {
|
||||
export interface NativePluginManager {
|
||||
load(name: string): boolean;
|
||||
unload(name: string): boolean;
|
||||
reload(name: string): boolean;
|
||||
|
@ -41,7 +41,7 @@ export class BukkitServer implements server.Server {
|
||||
return this.pluginsFolder;
|
||||
}
|
||||
getNativePluginManager() {
|
||||
throw new Error("Method not implemented.");
|
||||
return Bukkit.getPluginManager() as any;
|
||||
}
|
||||
sendJson(sender: string | any, json: object | string): void {
|
||||
if (typeof sender === "string") {
|
||||
|
@ -39,7 +39,7 @@ export class BungeeServer implements server.Server {
|
||||
return this.pluginsFolder;
|
||||
}
|
||||
getNativePluginManager() {
|
||||
throw new Error("Method not implemented.");
|
||||
return Bungee.getPluginManager() as any
|
||||
}
|
||||
sendJson(sender: string | any, json: string): void {
|
||||
throw new Error("Method not implemented.");
|
||||
|
@ -28,9 +28,6 @@
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ms/common": "^0.3.0",
|
||||
"@ms/container": "^0.3.0",
|
||||
"@ms/ployfill": "^0.3.0",
|
||||
"js-yaml": "^3.13.1"
|
||||
},
|
||||
"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 fs from '@ms/common/dist/fs'
|
||||
const File = Java.type("java.io.File");
|
||||
const separatorChar = File.separatorChar;
|
||||
|
||||
let langMap = {};
|
||||
let fallbackMap = {};
|
||||
@ -18,16 +20,24 @@ function translate(name: string, param?: TranslateParam) {
|
||||
}
|
||||
|
||||
function initialize(lang: string = 'zh_cn', fallback: string = 'zh_cn') {
|
||||
langMap = readYamlFile(root, lang) || readYamlFile(fs.concat(__dirname, '..'), lang)
|
||||
fallbackMap = readYamlFile(root, fallback) || readYamlFile(fs.concat(__dirname, '..'), fallback)
|
||||
langMap = readYamlFile(root, lang) || readYamlFile(concat(__dirname, '..'), lang)
|
||||
fallbackMap = readYamlFile(root, fallback) || readYamlFile(concat(__dirname, '..'), fallback)
|
||||
console.i18n = function i18n(name: string, param?: TranslateParam) {
|
||||
console.log(translate(name, param))
|
||||
}
|
||||
}
|
||||
|
||||
function readYamlFile(dir: string, name: string) {
|
||||
let langFile = fs.concat(dir, 'languages', name + '.yml');
|
||||
return fs.exists(langFile) && yaml.safeLoad(base.read(langFile))
|
||||
let langFile = concat(dir, 'languages', name + '.yml');
|
||||
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 {
|
||||
|
@ -40,7 +40,7 @@ export class NukkitServer implements server.Server {
|
||||
return this.pluginsFolder;
|
||||
}
|
||||
getNativePluginManager() {
|
||||
throw new Error("Method not implemented.");
|
||||
return Nukkit.getPluginManager() as any;
|
||||
}
|
||||
sendJson(sender: string | any, json: object | string): void {
|
||||
throw new Error("Method not implemented.");
|
||||
|
@ -44,7 +44,7 @@ export class SpongeServer implements server.Server {
|
||||
return this.pluginsFolder;
|
||||
}
|
||||
getNativePluginManager() {
|
||||
throw new Error("Method not implemented.");
|
||||
return Sponge.getPluginManager() as any;
|
||||
}
|
||||
sendJson(sender: string | any, json: string): void {
|
||||
if (typeof sender === "string") {
|
||||
|
1
packages/types/dist/typings/nashorn/index.d.ts
vendored
Normal file
1
packages/types/dist/typings/nashorn/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
/// <reference path="./nashorn.d.ts" />
|
38
packages/types/dist/typings/nashorn/nashorn.d.ts
vendored
Normal file
38
packages/types/dist/typings/nashorn/nashorn.d.ts
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
declare global {
|
||||
function print(...message: any[]): void;
|
||||
function load(script: string | object);
|
||||
function loadWithNewGlobal(script: string | object);
|
||||
function exit(code?: number);
|
||||
function quit(code?: number);
|
||||
function JavaImporter(...className: string[]);
|
||||
|
||||
namespace Java {
|
||||
function type(clazz: string): any;
|
||||
function from(javaObj: any): any[];
|
||||
function to(array: any[]): any;
|
||||
function extend(...parentTypes: any[]);
|
||||
//@ts-ignore
|
||||
// function super(type: any);
|
||||
}
|
||||
|
||||
interface Error {
|
||||
readonly lineNumber?: number;
|
||||
readonly columnNumber?: number;
|
||||
readonly fileName?: string;
|
||||
dumpStack?: Function;
|
||||
printStackTrace?: Function;
|
||||
getStackTrace?: () => any[];
|
||||
}
|
||||
|
||||
interface String {
|
||||
trimLeft();
|
||||
trimRight();
|
||||
}
|
||||
|
||||
interface Object {
|
||||
setPrototypeOf(obj: object, prototype: object);
|
||||
bindProperties(to: object, from: object);
|
||||
}
|
||||
}
|
||||
|
||||
export { };
|
Loading…
Reference in New Issue
Block a user