From 50ac0ddc553629e3b206be75c987b4141a3364de Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 24 Apr 2022 17:54:06 +0200 Subject: [PATCH] Speed Brandlistener up Signed-off-by: Lixfel --- .../bungeecore/listeners/BrandListener.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/BrandListener.java b/src/de/steamwar/bungeecore/listeners/BrandListener.java index c26baa7..6ff10e5 100644 --- a/src/de/steamwar/bungeecore/listeners/BrandListener.java +++ b/src/de/steamwar/bungeecore/listeners/BrandListener.java @@ -19,6 +19,7 @@ package de.steamwar.bungeecore.listeners; +import de.steamwar.bungeecore.BungeeCore; import de.steamwar.messages.ChatSender; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; @@ -43,14 +44,16 @@ public class BrandListener extends BasicListener { if (!(event.getReceiver() instanceof ProxiedPlayer)) { return; } - ProxiedPlayer player = (ProxiedPlayer) event.getReceiver(); - event.setCancelled(true); - String brandString = ChatSender.of(player).parseToLegacy("STEAMWAR_BRAND", ProxyServer.getInstance().getName(), player.getServer().getInfo().getName(), new String(event.getData(), 1, event.getData().length - 1)); - ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer(); - DefinedPacket.writeString(brandString, brand); - player.sendData(event.getTag(), DefinedPacket.toArray(brand)); - brand.release(); + ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> { + ProxiedPlayer player = (ProxiedPlayer) event.getReceiver(); + String brandString = ChatSender.of(player).parseToLegacy("STEAMWAR_BRAND", ProxyServer.getInstance().getName(), player.getServer().getInfo().getName(), new String(event.getData(), 1, event.getData().length - 1)); + + ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer(); + DefinedPacket.writeString(brandString, brand); + player.sendData(event.getTag(), DefinedPacket.toArray(brand)); + brand.release(); + }); } }