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;
|
package de.steamwar.bungeecore.listeners;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.messages.ChatSender;
|
||||||
import de.steamwar.bungeecore.Message;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.ByteBufAllocator;
|
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.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
import net.md_5.bungee.protocol.DefinedPacket;
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public class BrandListener extends BasicListener {
|
public class BrandListener extends BasicListener {
|
||||||
|
|
||||||
@ -42,27 +39,18 @@ public class BrandListener extends BasicListener {
|
|||||||
if(event.getReceiver().getAddress().getHostName().contains("localhost")) {
|
if(event.getReceiver().getAddress().getHostName().contains("localhost")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
|
||||||
|
|
||||||
if (!(event.getReceiver() instanceof ProxiedPlayer)) {
|
if (!(event.getReceiver() instanceof ProxiedPlayer)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||||
|
|
||||||
BungeeCore.get().getProxy().getScheduler().schedule(BungeeCore.get(), () -> {
|
event.setCancelled(true);
|
||||||
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));
|
||||||
|
|
||||||
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));
|
ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
||||||
|
DefinedPacket.writeString(brandString, brand);
|
||||||
ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
player.sendData(event.getTag(), DefinedPacket.toArray(brand));
|
||||||
DefinedPacket.writeString(brandString, brand);
|
brand.release();
|
||||||
player.sendData(channel, DefinedPacket.toArray(brand));
|
|
||||||
brand.release();
|
|
||||||
}, 50, TimeUnit.MILLISECONDS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren