Mirror von
https://github.com/Moulberry/AxiomPaperPlugin.git
synchronisiert 2024-11-08 17:40:04 +01:00
Add option to increase limit for request chunk data packet
Dieser Commit ist enthalten in:
Ursprung
f3f5c38c43
Commit
9248d48315
@ -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'");
|
||||
}
|
||||
|
||||
boolean allowLargeChunkDataRequest = this.configuration.getBoolean("allow-large-chunk-data-request");
|
||||
this.logLargeBlockBufferChanges = this.configuration.getBoolean("log-large-block-buffer-changes");
|
||||
|
||||
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")) {
|
||||
msg.registerIncomingPluginChannel(this, "axiom:set_editor_views", new SetEditorViewsPacketListener(this));
|
||||
}
|
||||
if (configuration.getBoolean("packet-handlers.request-chunk-data")) {
|
||||
msg.registerIncomingPluginChannel(this, "axiom:request_chunk_data", new RequestChunkDataPacketListener(this));
|
||||
if (!allowLargeChunkDataRequest) {
|
||||
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")) {
|
||||
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")) {
|
||||
SetBlockBufferPacketListener setBlockBufferPacketListener = new SetBlockBufferPacketListener(this);
|
||||
UploadBlueprintPacketListener uploadBlueprintPacketListener = new UploadBlueprintPacketListener(this);
|
||||
RequestChunkDataPacketListener requestChunkDataPacketListener = allowLargeChunkDataRequest ?
|
||||
new RequestChunkDataPacketListener(this) : null;
|
||||
|
||||
ChannelInitializeListenerHolder.addListener(Key.key("axiom:handle_big_payload"), new ChannelInitializeListener() {
|
||||
@Override
|
||||
@ -164,7 +169,7 @@ public class AxiomPaper extends JavaPlugin implements Listener {
|
||||
Connection connection = (Connection) channel.pipeline().get("packet_handler");
|
||||
channel.pipeline().addBefore("decoder", "axiom-big-payload-handler",
|
||||
new AxiomBigPayloadHandler(payloadId, connection, setBlockBufferPacketListener,
|
||||
uploadBlueprintPacketListener));
|
||||
uploadBlueprintPacketListener, requestChunkDataPacketListener));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -16,17 +16,20 @@ public class AxiomBigPayloadHandler extends ByteToMessageDecoder {
|
||||
|
||||
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 REQUEST_CHUNK_DATA = new ResourceLocation("axiom", "request_chunk_data");
|
||||
private final int payloadId;
|
||||
private final Connection connection;
|
||||
private final SetBlockBufferPacketListener setBlockBuffer;
|
||||
private final UploadBlueprintPacketListener uploadBlueprint;
|
||||
private final RequestChunkDataPacketListener requestChunkDataPacketListener;
|
||||
|
||||
public AxiomBigPayloadHandler(int payloadId, Connection connection, SetBlockBufferPacketListener setBlockBuffer,
|
||||
UploadBlueprintPacketListener uploadBlueprint) {
|
||||
UploadBlueprintPacketListener uploadBlueprint, RequestChunkDataPacketListener requestChunkDataPacketListener) {
|
||||
this.payloadId = payloadId;
|
||||
this.connection = connection;
|
||||
this.setBlockBuffer = setBlockBuffer;
|
||||
this.uploadBlueprint = uploadBlueprint;
|
||||
this.requestChunkDataPacketListener = requestChunkDataPacketListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -63,6 +66,15 @@ public class AxiomBigPayloadHandler extends ByteToMessageDecoder {
|
||||
in.skipBytes(in.readableBytes());
|
||||
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) {
|
||||
@ -86,7 +98,7 @@ public class AxiomBigPayloadHandler extends ByteToMessageDecoder {
|
||||
if (evt == ConnectionEvent.COMPRESSION_THRESHOLD_SET || evt == ConnectionEvent.COMPRESSION_DISABLED) {
|
||||
ctx.channel().pipeline().remove("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);
|
||||
}
|
||||
|
@ -14,6 +14,9 @@ allow-teleport-between-worlds: true
|
||||
# Whether to allow clients to save/load/share blueprints through the server
|
||||
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
|
||||
# Valid actions are 'kick', 'warn' and 'ignore'
|
||||
# 'warn' will give the player a warning and disable Axiom
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren