diff --git a/doc/MCBBS.MD b/doc/MCBBS.MD index 68b6ee73..c2d7acde 100644 --- a/doc/MCBBS.MD +++ b/doc/MCBBS.MD @@ -13,8 +13,8 @@ ## 插件简介 - 此插件可以实现跨端使用 `TypeScript` 开发 脚本插件 -- 目前已经兼容 `Spigot` `Sponge` -- 后续计划兼容 `BungeeCord` `Nukkit` +- 目前已经兼容 `Spigot` `Sponge` `Paper` `CatServer` `BungeeCord` `Nukkit` +- 后续计划兼容 暂无 ## 起源 (可以略过) @@ -103,17 +103,20 @@ ├─type Java的类型定义 | ├─bungee BungeeCord类型定义 | ├─bukkit Bukkit类型定义 - | └─sponge Sponge类型定义 + | ├─sponge Sponge类型定义 + | └─nukkit Nukkit类型定义 ├─websocket Netty的WebSocket注入 └─plugins 这里当然是插件啦 ├─bungee 只兼容BungeeCord的插件 ├─bukkit 只兼容Bukkit的插件 - └─sponge 只兼容Sponge的插件 + ├─sponge 只兼容Sponge的插件 + └─nukkit 只兼容Nukkit的插件 ``` 详细的内容就不逼逼了 自己看代码吧 Github: https://github.com/circlecloud/ms +YUMC: https://git.yumc.pw/circlecloud/ms ## 插件开发基础 @@ -146,6 +149,7 @@ Github: https://github.com/circlecloud/ms /// /// /// +/// import { server } from '@ms/api'; import { inject } from '@ms/container'; @@ -196,6 +200,16 @@ export class HelloWorld extends interfaces.Plugin { this.logger.log('Disable When ServerType is BungeeCord!') } + nukkitload() { + this.logger.log('Load When ServerType is Nukkit!') + } + nukkitenable() { + this.logger.log('Enable When ServerType is Nukkit!') + } + nukkitdisable() { + this.logger.log('Disable When ServerType is Nukkit!') + } + @cmd() hello(sender: any, command: string, args: string[]) { this.logger.log(sender, command, args); @@ -207,7 +221,8 @@ export class HelloWorld extends interfaces.Plugin { return ['world'] } - @listener({ servers: ['bukkit'] }) + // bukkit nukkit 大部分API神似 可以直接用 + @listener({ servers: ['bukkit', 'nukkit'] }) PlayerJoin(event: org.bukkit.event.player.PlayerJoinEvent) { let plyaer = event.getPlayer(); this.logger.console(`§cBukkit §aPlayerJoinEvent: §b${plyaer.getName()}`) @@ -236,10 +251,11 @@ export class HelloWorld extends interfaces.Plugin { - 进入 `ms`目录 - 执行编译 `yarn build:plugins` -- 从 `packages/plugins/dist` 中复制 `HelloWorld.js` 文件 到对应的插件目录 +- 从 `packages/plugins/dist` 中复制 `HelloWorld.js` 和 `HelloWorld.js.map`(可选 用于显示插件原有行数) 文件 到对应的插件目录 - Bungee: plugins/MiaoScript/plugins/ - Bukkit: plugins/MiaoScript/plugins/ - Sponge: config/miaoscript/plugins/ + - Nukkit: plugins/MiaoScript/plugins/ - 重载 `MiaoScript` - 打开客户端进入游戏 预览一下效果 - 从 Spigot 服务端进入 @@ -358,7 +374,8 @@ tabhello(_sender: any, _command: string, _args: string[]) { - 事件监听方法的第一个参数就是本次事件的具体内容 (这里就需要自己去查询对应的JavaDoc了) ```ts -@listener({ servers: ['bukkit'] }) +// bukkit nukkit 大部分API神似 可以直接用 +@listener({ servers: ['bukkit', 'nukkit'] }) PlayerJoin(event: org.bukkit.event.player.PlayerJoinEvent) { let plyaer = event.getPlayer(); this.logger.console(`§cBukkit §aPlayerJoinEvent: §b${plyaer.getName()}`) diff --git a/packages/api/src/index.ts b/packages/api/src/index.ts index d3826377..c1339bf7 100644 --- a/packages/api/src/index.ts +++ b/packages/api/src/index.ts @@ -1,4 +1,4 @@ -/// +import "@ms/ployfill" export * from './task' export * from './event' export * from './console' diff --git a/packages/bukkit/src/index.ts b/packages/bukkit/src/index.ts index 5fdf063f..33c70582 100644 --- a/packages/bukkit/src/index.ts +++ b/packages/bukkit/src/index.ts @@ -1,6 +1,6 @@ /// -import { server, command, event, channel, task } from '@ms/api' +import { server } from '@ms/api' import { Container } from '@ms/container' import { BukkitConsole } from './console'; diff --git a/packages/bungee/src/index.ts b/packages/bungee/src/index.ts index f79c9420..69f48e63 100644 --- a/packages/bungee/src/index.ts +++ b/packages/bungee/src/index.ts @@ -1,6 +1,6 @@ /// -import { server, command, event, channel, task } from '@ms/api' +import { server } from '@ms/api' import { Container } from '@ms/container' import { BungeeConsole } from './console'; diff --git a/packages/i18n/package.json b/packages/i18n/package.json index 25618341..afe74dae 100644 --- a/packages/i18n/package.json +++ b/packages/i18n/package.json @@ -28,6 +28,7 @@ "typescript": "^3.8.2" }, "dependencies": { + "@ms/common": "^0.2.1", "@ms/container": "^0.2.1", "@ms/ployfill": "^0.2.1", "js-yaml": "^3.13.1" diff --git a/packages/plugin/package.json b/packages/plugin/package.json index 16cd5675..f41ab4b3 100644 --- a/packages/plugin/package.json +++ b/packages/plugin/package.json @@ -31,6 +31,7 @@ "@ms/api": "^0.2.1", "@ms/common": "^0.2.1", "@ms/container": "^0.2.1", + "@ms/i18n": "^0.2.1", "js-yaml": "^3.13.1" } }