From 1d2a528bbbe3a79428114f7051d001204637d7c3 Mon Sep 17 00:00:00 2001 From: MiaoWoo Date: Fri, 2 Oct 2020 19:57:10 +0800 Subject: [PATCH] fix: continer Autowired error Signed-off-by: MiaoWoo --- packages/api/src/proxy.ts | 11 ++++++----- packages/container/src/index.ts | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/api/src/proxy.ts b/packages/api/src/proxy.ts index 809816b6..3dee0dcd 100644 --- a/packages/api/src/proxy.ts +++ b/packages/api/src/proxy.ts @@ -1,4 +1,4 @@ -import { provideSingleton, Autowired } from '@ccms/container' +import { provideSingleton, Autowired, optional } from '@ccms/container' import { channel } from './channel' export namespace proxy { @@ -44,7 +44,7 @@ export namespace proxy { * Get a list of players connected on a certain server, or on ALL the servers. * @param server count server * Response: - * String server = in.readUTF(); // The name of the server you got the player list of, as given in args. + * String server = in.readUTF(); // The name of the server you got the player list of, as given in args. * String[] playerList = in.readUTF().split(", "); */ playerList(server: string | "ALL") { @@ -98,7 +98,7 @@ export namespace proxy { return this.forward("ALL", channel, data) } /** - * Send a custom plugin message to said server. This is one of the most useful channels ever. + * Send a custom plugin message to said server. This is one of the most useful channels ever. * Remember, the sending and receiving server(s) need to have a player online. * @param server reciver * @param channel channelName @@ -112,7 +112,7 @@ export namespace proxy { return this.finalSend() } /** - * Send a custom plugin message to said server. This is one of the most useful channels ever. + * Send a custom plugin message to said server. This is one of the most useful channels ever. * Remember, the sending and receiving server(s) need to have a player online. * @param server reciver * @param channel channelName @@ -147,6 +147,7 @@ export namespace proxy { } @provideSingleton(BungeeCord) export class BungeeCord { + @optional() @Autowired() private channel: channel.Channel /** @@ -157,4 +158,4 @@ export namespace proxy { return new bungeecord.SubChannelBuilder(this.channel, player) } } -} \ No newline at end of file +} diff --git a/packages/container/src/index.ts b/packages/container/src/index.ts index ea96dd81..d6912cb8 100644 --- a/packages/container/src/index.ts +++ b/packages/container/src/index.ts @@ -66,7 +66,7 @@ export const Autowired = (className?: any) => { return inject(className)(target, propertyKey, index) } let type = Reflect.getMetadata('design:type', target, propertyKey) - if (type && type !== Object && Java.isJavaObject(type)) { + if (type && type !== Object && !Java.isJavaObject(type)) { inject(type)(target, propertyKey, index) named(className || propertyKey)(target, propertyKey, index) } else if (container.isBound(ioc.Autowired)) {