From fad4e27a7f30d44d586aea076c6f481abd17236a Mon Sep 17 00:00:00 2001 From: MiaoWoo Date: Fri, 14 Feb 2020 04:03:25 +0800 Subject: [PATCH] fix: bungee servers forEach error Signed-off-by: MiaoWoo --- packages/plugins/src/MiaoChat.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/plugins/src/MiaoChat.ts b/packages/plugins/src/MiaoChat.ts index bfe65045..37967420 100644 --- a/packages/plugins/src/MiaoChat.ts +++ b/packages/plugins/src/MiaoChat.ts @@ -14,6 +14,8 @@ const GZIPOutputStream = Java.type("java.util.zip.GZIPOutputStream"); const Consumer = Java.type("java.util.function.Consumer"); const ByteArray = Java.type("byte[]") +const BiConsumer = Java.type('java.util.function.BiConsumer') + class MiaoMessage { // public static final String CHANNEL = "MiaoChat:Default".toLowerCase(); public static CHANNEL: string = "MiaoChat:Default".toLowerCase() @@ -287,11 +289,13 @@ export class MiaoChat extends interfaces.Plugin { let event = e as net.md_5.bungee.api.event.PluginMessageEvent if (event.getTag() == MiaoMessage.CHANNEL || event.getTag() == MiaoMessage.NORMAL_CHANNEL) { let origin = event.getSender().getAddress(); - bungee.getServers().forEach(server => { - if (server.getAddress() != origin && server.getPlayers().size() > 0) { - server.sendData(event.getTag(), event.getData()) + bungee.getServers().forEach(new BiConsumer({ + accept: (s, server) => { + if (server.getAddress() != origin && server.getPlayers().size() > 0) { + server.sendData(event.getTag(), event.getData()) + } } - }); + })) } }