3
0
Mirror von https://github.com/Moulberry/AxiomPaperPlugin.git synchronisiert 2024-11-17 05:40:06 +01:00

Improve handling of large chunk data request

Dieser Commit ist enthalten in:
Moulberry 2024-03-26 23:17:53 +08:00
Ursprung 9248d48315
Commit 17b304128f

Datei anzeigen

@ -1,6 +1,7 @@
package com.moulberry.axiom.packet; package com.moulberry.axiom.packet;
import com.moulberry.axiom.AxiomPaper; import com.moulberry.axiom.AxiomPaper;
import com.moulberry.axiom.VersionHelper;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder; import io.netty.handler.codec.ByteToMessageDecoder;
@ -61,7 +62,8 @@ public class AxiomBigPayloadHandler extends ByteToMessageDecoder {
} else if (identifier.equals(UPLOAD_BLUEPRINT)) { } else if (identifier.equals(UPLOAD_BLUEPRINT)) {
ServerPlayer player = connection.getPlayer(); ServerPlayer player = connection.getPlayer();
if (AxiomPaper.PLUGIN.canUseAxiom(player.getBukkitEntity())) { if (AxiomPaper.PLUGIN.canUseAxiom(player.getBukkitEntity())) {
uploadBlueprint.onReceive(player, buf); player.getServer().execute(() -> uploadBlueprint.onReceive(player, buf));
success = true; success = true;
in.skipBytes(in.readableBytes()); in.skipBytes(in.readableBytes());
return; return;
@ -69,8 +71,12 @@ public class AxiomBigPayloadHandler extends ByteToMessageDecoder {
} else if (requestChunkDataPacketListener != null && identifier.equals(REQUEST_CHUNK_DATA)) { } else if (requestChunkDataPacketListener != null && identifier.equals(REQUEST_CHUNK_DATA)) {
ServerPlayer player = connection.getPlayer(); ServerPlayer player = connection.getPlayer();
if (AxiomPaper.PLUGIN.canUseAxiom(player.getBukkitEntity())) { if (AxiomPaper.PLUGIN.canUseAxiom(player.getBukkitEntity())) {
requestChunkDataPacketListener.onPluginMessageReceived(identifier.toString(), player.getBukkitEntity(), byte[] bytes = new byte[buf.writerIndex() - buf.readerIndex()];
buf.array()); buf.getBytes(buf.readerIndex(), bytes);
player.getServer().execute(() -> requestChunkDataPacketListener.onPluginMessageReceived(
identifier.toString(), player.getBukkitEntity(), bytes));
success = true; success = true;
in.skipBytes(in.readableBytes()); in.skipBytes(in.readableBytes());
return; return;