From 05cbd85828599037d1c53cf786d9f937ae5161e6 Mon Sep 17 00:00:00 2001 From: MiaoWoo Date: Mon, 24 Feb 2020 04:02:29 +0800 Subject: [PATCH] feat: add nukkit support Signed-off-by: MiaoWoo --- packages/bukkit/package.json | 2 +- packages/bukkit/src/command.ts | 1 - packages/core/src/index.ts | 5 +++++ packages/plugins/src/HelloWorld.ts | 3 ++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/bukkit/package.json b/packages/bukkit/package.json index ccb3c13a..2c113dff 100644 --- a/packages/bukkit/package.json +++ b/packages/bukkit/package.json @@ -1,7 +1,7 @@ { "name": "@ms/bukkit", "version": "0.2.0", - "description": "MiaoScript api package", + "description": "MiaoScript bukkit package", "keywords": [ "miaoscript", "minecraft", diff --git a/packages/bukkit/src/command.ts b/packages/bukkit/src/command.ts index 95f6abbe..75afbf4a 100644 --- a/packages/bukkit/src/command.ts +++ b/packages/bukkit/src/command.ts @@ -19,7 +19,6 @@ export class BukkitCommand extends command.Command { init() { this.commandMap = reflect.on(Bukkit.getPluginManager()).get('commandMap').get(); } - create(plugin: any, command: string) { var cmd = this.commandMap.getCommand(command) if (cmd && cmd instanceof PluginCommand) { return cmd }; diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index a9d14db0..793455a8 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -61,6 +61,11 @@ function detectServer() { return 'sponge' } catch (ex) { } + try { + Java.type("cn.nukkit.Nukkit"); + return 'nukkit' + } catch (ex) { + } try { Java.type("net.md_5.bungee.api.ProxyServer"); return 'bungee' diff --git a/packages/plugins/src/HelloWorld.ts b/packages/plugins/src/HelloWorld.ts index de0f5391..947aa494 100644 --- a/packages/plugins/src/HelloWorld.ts +++ b/packages/plugins/src/HelloWorld.ts @@ -1,6 +1,7 @@ /// /// /// +/// import { server } from '@ms/api'; import { inject } from '@ms/container'; @@ -62,7 +63,7 @@ export class HelloWorld extends interfaces.Plugin { return ['world'] } - @listener({ servers: ['bukkit'] }) + @listener({ servers: ['bukkit', 'nukkit'] }) PlayerJoin(event: org.bukkit.event.player.PlayerJoinEvent) { let plyaer = event.getPlayer(); this.logger.console(`§cBukkit §aPlayerJoinEvent: §b${plyaer.getName()}`)