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

Add option to increase limit for request chunk data packet

Dieser Commit ist enthalten in:
Moulberry 2024-03-26 13:26:59 +08:00
Ursprung f3f5c38c43
Commit 9248d48315
3 geänderte Dateien mit 25 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -71,6 +71,7 @@ public class AxiomPaper extends JavaPlugin implements Listener {
this.getLogger().warning("Invalid value for unsupported-axiom-version, expected 'kick', 'warn' or 'ignore'"); this.getLogger().warning("Invalid value for unsupported-axiom-version, expected 'kick', 'warn' or 'ignore'");
} }
boolean allowLargeChunkDataRequest = this.configuration.getBoolean("allow-large-chunk-data-request");
this.logLargeBlockBufferChanges = this.configuration.getBoolean("log-large-block-buffer-changes"); this.logLargeBlockBufferChanges = this.configuration.getBoolean("log-large-block-buffer-changes");
List<String> disallowedBlocks = this.configuration.getStringList("disallowed-blocks"); List<String> disallowedBlocks = this.configuration.getStringList("disallowed-blocks");
@ -123,8 +124,10 @@ public class AxiomPaper extends JavaPlugin implements Listener {
if (configuration.getBoolean("packet-handlers.set-editor-views")) { if (configuration.getBoolean("packet-handlers.set-editor-views")) {
msg.registerIncomingPluginChannel(this, "axiom:set_editor_views", new SetEditorViewsPacketListener(this)); msg.registerIncomingPluginChannel(this, "axiom:set_editor_views", new SetEditorViewsPacketListener(this));
} }
if (configuration.getBoolean("packet-handlers.request-chunk-data")) { if (!allowLargeChunkDataRequest) {
msg.registerIncomingPluginChannel(this, "axiom:request_chunk_data", new RequestChunkDataPacketListener(this)); if (configuration.getBoolean("packet-handlers.request-chunk-data")) {
msg.registerIncomingPluginChannel(this, "axiom:request_chunk_data", new RequestChunkDataPacketListener(this));
}
} }
if (configuration.getBoolean("packet-handlers.spawn-entity")) { if (configuration.getBoolean("packet-handlers.spawn-entity")) {
msg.registerIncomingPluginChannel(this, "axiom:spawn_entity", new SpawnEntityPacketListener(this)); msg.registerIncomingPluginChannel(this, "axiom:spawn_entity", new SpawnEntityPacketListener(this));
@ -145,6 +148,8 @@ public class AxiomPaper extends JavaPlugin implements Listener {
if (configuration.getBoolean("packet-handlers.set-buffer")) { if (configuration.getBoolean("packet-handlers.set-buffer")) {
SetBlockBufferPacketListener setBlockBufferPacketListener = new SetBlockBufferPacketListener(this); SetBlockBufferPacketListener setBlockBufferPacketListener = new SetBlockBufferPacketListener(this);
UploadBlueprintPacketListener uploadBlueprintPacketListener = new UploadBlueprintPacketListener(this); UploadBlueprintPacketListener uploadBlueprintPacketListener = new UploadBlueprintPacketListener(this);
RequestChunkDataPacketListener requestChunkDataPacketListener = allowLargeChunkDataRequest ?
new RequestChunkDataPacketListener(this) : null;
ChannelInitializeListenerHolder.addListener(Key.key("axiom:handle_big_payload"), new ChannelInitializeListener() { ChannelInitializeListenerHolder.addListener(Key.key("axiom:handle_big_payload"), new ChannelInitializeListener() {
@Override @Override
@ -164,7 +169,7 @@ public class AxiomPaper extends JavaPlugin implements Listener {
Connection connection = (Connection) channel.pipeline().get("packet_handler"); Connection connection = (Connection) channel.pipeline().get("packet_handler");
channel.pipeline().addBefore("decoder", "axiom-big-payload-handler", channel.pipeline().addBefore("decoder", "axiom-big-payload-handler",
new AxiomBigPayloadHandler(payloadId, connection, setBlockBufferPacketListener, new AxiomBigPayloadHandler(payloadId, connection, setBlockBufferPacketListener,
uploadBlueprintPacketListener)); uploadBlueprintPacketListener, requestChunkDataPacketListener));
} }
}); });
} }

Datei anzeigen

@ -16,17 +16,20 @@ public class AxiomBigPayloadHandler extends ByteToMessageDecoder {
private static final ResourceLocation SET_BUFFER = new ResourceLocation("axiom", "set_buffer"); private static final ResourceLocation SET_BUFFER = new ResourceLocation("axiom", "set_buffer");
private static final ResourceLocation UPLOAD_BLUEPRINT = new ResourceLocation("axiom", "upload_blueprint"); private static final ResourceLocation UPLOAD_BLUEPRINT = new ResourceLocation("axiom", "upload_blueprint");
private static final ResourceLocation REQUEST_CHUNK_DATA = new ResourceLocation("axiom", "request_chunk_data");
private final int payloadId; private final int payloadId;
private final Connection connection; private final Connection connection;
private final SetBlockBufferPacketListener setBlockBuffer; private final SetBlockBufferPacketListener setBlockBuffer;
private final UploadBlueprintPacketListener uploadBlueprint; private final UploadBlueprintPacketListener uploadBlueprint;
private final RequestChunkDataPacketListener requestChunkDataPacketListener;
public AxiomBigPayloadHandler(int payloadId, Connection connection, SetBlockBufferPacketListener setBlockBuffer, public AxiomBigPayloadHandler(int payloadId, Connection connection, SetBlockBufferPacketListener setBlockBuffer,
UploadBlueprintPacketListener uploadBlueprint) { UploadBlueprintPacketListener uploadBlueprint, RequestChunkDataPacketListener requestChunkDataPacketListener) {
this.payloadId = payloadId; this.payloadId = payloadId;
this.connection = connection; this.connection = connection;
this.setBlockBuffer = setBlockBuffer; this.setBlockBuffer = setBlockBuffer;
this.uploadBlueprint = uploadBlueprint; this.uploadBlueprint = uploadBlueprint;
this.requestChunkDataPacketListener = requestChunkDataPacketListener;
} }
@Override @Override
@ -63,6 +66,15 @@ public class AxiomBigPayloadHandler extends ByteToMessageDecoder {
in.skipBytes(in.readableBytes()); in.skipBytes(in.readableBytes());
return; return;
} }
} else if (requestChunkDataPacketListener != null && identifier.equals(REQUEST_CHUNK_DATA)) {
ServerPlayer player = connection.getPlayer();
if (AxiomPaper.PLUGIN.canUseAxiom(player.getBukkitEntity())) {
requestChunkDataPacketListener.onPluginMessageReceived(identifier.toString(), player.getBukkitEntity(),
buf.array());
success = true;
in.skipBytes(in.readableBytes());
return;
}
} }
} }
} catch (Throwable ignored) { } catch (Throwable ignored) {
@ -86,7 +98,7 @@ public class AxiomBigPayloadHandler extends ByteToMessageDecoder {
if (evt == ConnectionEvent.COMPRESSION_THRESHOLD_SET || evt == ConnectionEvent.COMPRESSION_DISABLED) { if (evt == ConnectionEvent.COMPRESSION_THRESHOLD_SET || evt == ConnectionEvent.COMPRESSION_DISABLED) {
ctx.channel().pipeline().remove("axiom-big-payload-handler"); ctx.channel().pipeline().remove("axiom-big-payload-handler");
ctx.channel().pipeline().addBefore("decoder", "axiom-big-payload-handler", ctx.channel().pipeline().addBefore("decoder", "axiom-big-payload-handler",
new AxiomBigPayloadHandler(payloadId, connection, setBlockBuffer, uploadBlueprint)); new AxiomBigPayloadHandler(payloadId, connection, setBlockBuffer, uploadBlueprint, requestChunkDataPacketListener));
} }
super.userEventTriggered(ctx, evt); super.userEventTriggered(ctx, evt);
} }

Datei anzeigen

@ -14,6 +14,9 @@ allow-teleport-between-worlds: true
# Whether to allow clients to save/load/share blueprints through the server # Whether to allow clients to save/load/share blueprints through the server
blueprint-sharing: false blueprint-sharing: false
# Allow large chunk data requests, not recommended for public servers
allow-large-chunk-data-request: false
# Action to take when a user with an incompatible Minecraft version or Axiom version joins # Action to take when a user with an incompatible Minecraft version or Axiom version joins
# Valid actions are 'kick', 'warn' and 'ignore' # Valid actions are 'kick', 'warn' and 'ignore'
# 'warn' will give the player a warning and disable Axiom # 'warn' will give the player a warning and disable Axiom