2020-02-23 20:01:39 +00:00
|
|
|
import { server } from '@ms/api'
|
2020-02-26 02:15:33 +00:00
|
|
|
import { provideSingleton } from '@ms/container';
|
2020-02-23 20:01:39 +00:00
|
|
|
|
|
|
|
let Nukkit: cn.nukkit.Server = base.getInstance().getServer();
|
|
|
|
|
2020-02-26 02:15:33 +00:00
|
|
|
@provideSingleton(server.Server)
|
2020-02-23 20:01:39 +00:00
|
|
|
export class NukkitServer implements server.Server {
|
|
|
|
getPlayer(name: string) {
|
|
|
|
return Nukkit.getPlayer(name)
|
|
|
|
}
|
|
|
|
getVersion(): string {
|
|
|
|
return Nukkit.getVersion()
|
|
|
|
}
|
|
|
|
getOnlinePlayers() {
|
|
|
|
return Nukkit.getOnlinePlayers() as unknown as any[]
|
|
|
|
}
|
|
|
|
getConsoleSender() {
|
|
|
|
return Nukkit.getConsoleSender()
|
|
|
|
}
|
|
|
|
getService(service: string) {
|
|
|
|
return Nukkit.getServiceManager().getProvider(base.getClass(service))
|
|
|
|
}
|
|
|
|
dispatchCommand(sender: string | any, command: string): boolean {
|
|
|
|
if (typeof sender === 'string') {
|
|
|
|
sender = this.getPlayer(sender)
|
|
|
|
}
|
|
|
|
return Nukkit.dispatchCommand(sender, command)
|
|
|
|
}
|
|
|
|
dispatchConsoleCommand(command: string): boolean {
|
|
|
|
return Nukkit.dispatchCommand(Nukkit.getConsoleSender(), command)
|
|
|
|
}
|
|
|
|
sendJson(sender: string | any, json: object | string): void {
|
|
|
|
throw new Error("Method not implemented.");
|
|
|
|
}
|
|
|
|
}
|