Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
f2df750894
Commit
f30b779347
@ -19,17 +19,14 @@
|
||||
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class BrandListener extends BasicListener {
|
||||
|
||||
@ -42,27 +39,18 @@ public class BrandListener extends BasicListener {
|
||||
if(event.getReceiver().getAddress().getHostName().contains("localhost")) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
|
||||
if (!(event.getReceiver() instanceof ProxiedPlayer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
BungeeCore.get().getProxy().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||
|
||||
String channel = player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand";
|
||||
StringBuilder serverBrand = new StringBuilder();
|
||||
for (byte b:event.getData()) {
|
||||
serverBrand.append((char) b);
|
||||
}
|
||||
|
||||
String brandString = Message.parse("STEAMWAR_BRAND", player, BungeeCore.get().getProxy().getName(), player.getServer().getInfo().getName(), serverBrand.substring(1));
|
||||
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(channel, DefinedPacket.toArray(brand));
|
||||
player.sendData(event.getTag(), DefinedPacket.toArray(brand));
|
||||
brand.release();
|
||||
}, 50, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren