13
0
geforkt von Mirrors/Velocity

Avoid unneeded copy in BackendPlaySessionHandler plugin messages

Dieser Commit ist enthalten in:
Andrew Steinborn 2020-11-07 10:57:03 -05:00
Ursprung 8a3b6403da
Commit d51f357fa8
2 geänderte Dateien mit 3 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -146,7 +146,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
.thenAcceptAsync(pme -> { .thenAcceptAsync(pme -> {
if (pme.getResult().isAllowed() && !playerConnection.isClosed()) { if (pme.getResult().isAllowed() && !playerConnection.isClosed()) {
PluginMessage copied = new PluginMessage(packet.getChannel(), PluginMessage copied = new PluginMessage(packet.getChannel(),
Unpooled.unreleasableBuffer(Unpooled.wrappedBuffer(copy))); Unpooled.wrappedBuffer(copy));
playerConnection.write(copied); playerConnection.write(copied);
} }
}, playerConnection.eventLoop()) }, playerConnection.eventLoop())

Datei anzeigen

@ -225,12 +225,11 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
backendConn.write(packet.retain()); backendConn.write(packet.retain());
} else { } else {
byte[] copy = ByteBufUtil.getBytes(packet.content()); byte[] copy = ByteBufUtil.getBytes(packet.content());
PluginMessageEvent event = new PluginMessageEvent(player, serverConn, id, PluginMessageEvent event = new PluginMessageEvent(player, serverConn, id, copy);
ByteBufUtil.getBytes(packet.content()));
server.getEventManager().fire(event).thenAcceptAsync(pme -> { server.getEventManager().fire(event).thenAcceptAsync(pme -> {
if (pme.getResult().isAllowed()) { if (pme.getResult().isAllowed()) {
PluginMessage message = new PluginMessage(packet.getChannel(), PluginMessage message = new PluginMessage(packet.getChannel(),
Unpooled.unreleasableBuffer(Unpooled.wrappedBuffer(copy))); Unpooled.wrappedBuffer(copy));
backendConn.write(message); backendConn.write(message);
} }
}, backendConn.eventLoop()) }, backendConn.eventLoop())