diff --git a/packages/api/src/interfaces/server/index.ts b/packages/api/src/interfaces/server/index.ts
index 47f4c3ce..ed1c6a0b 100644
--- a/packages/api/src/interfaces/server/index.ts
+++ b/packages/api/src/interfaces/server/index.ts
@@ -1,3 +1,5 @@
+import { NativePluginManager } from './native_plugin'
+
export namespace server {
/**
* Runtime ServerType
diff --git a/packages/api/src/interfaces/server/native_plugin.ts b/packages/api/src/interfaces/server/native_plugin.ts
index 2f826e35..3edb6498 100644
--- a/packages/api/src/interfaces/server/native_plugin.ts
+++ b/packages/api/src/interfaces/server/native_plugin.ts
@@ -1,4 +1,4 @@
-interface NativePluginManager {
+export interface NativePluginManager {
load(name: string): boolean;
unload(name: string): boolean;
reload(name: string): boolean;
diff --git a/packages/bukkit/src/server.ts b/packages/bukkit/src/server.ts
index 814a0b93..54aaa1f7 100644
--- a/packages/bukkit/src/server.ts
+++ b/packages/bukkit/src/server.ts
@@ -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") {
diff --git a/packages/bungee/src/server.ts b/packages/bungee/src/server.ts
index 6eddbc20..71076214 100644
--- a/packages/bungee/src/server.ts
+++ b/packages/bungee/src/server.ts
@@ -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.");
diff --git a/packages/i18n/package.json b/packages/i18n/package.json
index c35db5a4..07b6b40d 100644
--- a/packages/i18n/package.json
+++ b/packages/i18n/package.json
@@ -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"
diff --git a/packages/i18n/src/index.ts b/packages/i18n/src/index.ts
index c9cb2cb7..1c0d269c 100644
--- a/packages/i18n/src/index.ts
+++ b/packages/i18n/src/index.ts
@@ -1,7 +1,9 @@
-import '@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 {
diff --git a/packages/nukkit/src/server.ts b/packages/nukkit/src/server.ts
index ce2c9ad1..32d191b2 100644
--- a/packages/nukkit/src/server.ts
+++ b/packages/nukkit/src/server.ts
@@ -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.");
diff --git a/packages/sponge/src/server.ts b/packages/sponge/src/server.ts
index 4b509a2d..23444594 100644
--- a/packages/sponge/src/server.ts
+++ b/packages/sponge/src/server.ts
@@ -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") {
diff --git a/packages/types/dist/typings/nashorn/index.d.ts b/packages/types/dist/typings/nashorn/index.d.ts
new file mode 100644
index 00000000..2ebe4c84
--- /dev/null
+++ b/packages/types/dist/typings/nashorn/index.d.ts
@@ -0,0 +1 @@
+///
diff --git a/packages/types/dist/typings/nashorn/nashorn.d.ts b/packages/types/dist/typings/nashorn/nashorn.d.ts
new file mode 100644
index 00000000..3fe2d66f
--- /dev/null
+++ b/packages/types/dist/typings/nashorn/nashorn.d.ts
@@ -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 { };