Mirror von
https://github.com/Moulberry/AxiomPaperPlugin.git
synchronisiert 2024-11-17 05:40:06 +01:00
Add option to allow large payload for all packets
Dieser Commit ist enthalten in:
Ursprung
0c59cea0e6
Commit
4a3b1172c0
@ -8,7 +8,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "com.moulberry.axiom"
|
group = "com.moulberry.axiom"
|
||||||
version = "4.0.1"
|
version = "4.0.2"
|
||||||
description = "Serverside component for Axiom on Paper"
|
description = "Serverside component for Axiom on Paper"
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
@ -7,12 +7,12 @@ paper = "1.20.6-R0.1-SNAPSHOT"
|
|||||||
plotsquared = "7.3.9-20240513.192211-13"
|
plotsquared = "7.3.9-20240513.192211-13"
|
||||||
reflection-remapper = "0.1.2-20240315.033304-2"
|
reflection-remapper = "0.1.2-20240315.033304-2"
|
||||||
viaversion-api = "5.0.1"
|
viaversion-api = "5.0.1"
|
||||||
worldguard-bukkit = "7.1.0-20240503.180049-12"
|
worldguard-bukkit = "7.0.9-SNAPSHOT"
|
||||||
zstd-jni = "1.5.5-4"
|
zstd-jni = "1.5.5-4"
|
||||||
|
|
||||||
# Plugins
|
# Plugins
|
||||||
paperweight-userdev = "1.7.1"
|
paperweight-userdev = "1.7.2"
|
||||||
run-paper = "2.2.4"
|
run-paper = "2.3.0"
|
||||||
shadow = "8.1.7"
|
shadow = "8.1.7"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
@ -29,4 +29,4 @@ zstd-jni = { group = "com.github.luben", name = "zstd-jni", version = "1.5.5-4"
|
|||||||
[plugins]
|
[plugins]
|
||||||
paperweight-userdev = { id = "io.papermc.paperweight.userdev", version.ref = "paperweight-userdev" }
|
paperweight-userdev = { id = "io.papermc.paperweight.userdev", version.ref = "paperweight-userdev" }
|
||||||
run-paper = { id = "xyz.jpenilla.run-paper", version.ref = "run-paper" }
|
run-paper = { id = "xyz.jpenilla.run-paper", version.ref = "run-paper" }
|
||||||
shadow = { id = "io.github.goooler.shadow", version.ref = "shadow" }
|
shadow = { id = "io.github.goooler.shadow", version.ref = "shadow" }
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -9,6 +9,25 @@ import com.moulberry.axiom.event.AxiomModifyWorldEvent;
|
|||||||
import com.moulberry.axiom.integration.coreprotect.CoreProtectIntegration;
|
import com.moulberry.axiom.integration.coreprotect.CoreProtectIntegration;
|
||||||
import com.moulberry.axiom.integration.plotsquared.PlotSquaredIntegration;
|
import com.moulberry.axiom.integration.plotsquared.PlotSquaredIntegration;
|
||||||
import com.moulberry.axiom.packet.*;
|
import com.moulberry.axiom.packet.*;
|
||||||
|
import com.moulberry.axiom.packet.impl.BlueprintRequestPacketListener;
|
||||||
|
import com.moulberry.axiom.packet.impl.DeleteEntityPacketListener;
|
||||||
|
import com.moulberry.axiom.packet.impl.HelloPacketListener;
|
||||||
|
import com.moulberry.axiom.packet.impl.ManipulateEntityPacketListener;
|
||||||
|
import com.moulberry.axiom.packet.impl.MarkerNbtRequestPacketListener;
|
||||||
|
import com.moulberry.axiom.packet.impl.RequestChunkDataPacketListener;
|
||||||
|
import com.moulberry.axiom.packet.impl.SetBlockBufferPacketListener;
|
||||||
|
import com.moulberry.axiom.packet.impl.SetBlockPacketListener;
|
||||||
|
import com.moulberry.axiom.packet.impl.SetEditorViewsPacketListener;
|
||||||
|
import com.moulberry.axiom.packet.impl.SetFlySpeedPacketListener;
|
||||||
|
import com.moulberry.axiom.packet.impl.SetGamemodePacketListener;
|
||||||
|
import com.moulberry.axiom.packet.impl.SetHotbarSlotPacketListener;
|
||||||
|
import com.moulberry.axiom.packet.impl.SetTimePacketListener;
|
||||||
|
import com.moulberry.axiom.packet.impl.SetWorldPropertyListener;
|
||||||
|
import com.moulberry.axiom.packet.impl.SpawnEntityPacketListener;
|
||||||
|
import com.moulberry.axiom.packet.impl.SwitchActiveHotbarPacketListener;
|
||||||
|
import com.moulberry.axiom.packet.impl.TeleportPacketListener;
|
||||||
|
import com.moulberry.axiom.packet.impl.UpdateAnnotationPacketListener;
|
||||||
|
import com.moulberry.axiom.packet.impl.UploadBlueprintPacketListener;
|
||||||
import com.moulberry.axiom.world_properties.server.ServerWorldPropertiesRegistry;
|
import com.moulberry.axiom.world_properties.server.ServerWorldPropertiesRegistry;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
@ -111,64 +130,31 @@ public class AxiomPaper extends JavaPlugin implements Listener {
|
|||||||
msg.registerOutgoingPluginChannel(this, "axiom:marker_nbt_response");
|
msg.registerOutgoingPluginChannel(this, "axiom:marker_nbt_response");
|
||||||
msg.registerOutgoingPluginChannel(this, "axiom:annotation_update");
|
msg.registerOutgoingPluginChannel(this, "axiom:annotation_update");
|
||||||
|
|
||||||
if (configuration.getBoolean("packet-handlers.hello")) {
|
Map<String, PacketHandler> largePayloadHandlers = new HashMap<>();
|
||||||
msg.registerIncomingPluginChannel(this, "axiom:hello", new HelloPacketListener(this));
|
|
||||||
}
|
|
||||||
if (configuration.getBoolean("packet-handlers.set-gamemode")) {
|
|
||||||
msg.registerIncomingPluginChannel(this, "axiom:set_gamemode", new SetGamemodePacketListener(this));
|
|
||||||
}
|
|
||||||
if (configuration.getBoolean("packet-handlers.set-fly-speed")) {
|
|
||||||
msg.registerIncomingPluginChannel(this, "axiom:set_fly_speed", new SetFlySpeedPacketListener(this));
|
|
||||||
}
|
|
||||||
if (configuration.getBoolean("packet-handlers.set-world-time")) {
|
|
||||||
msg.registerIncomingPluginChannel(this, "axiom:set_world_time", new SetTimePacketListener(this));
|
|
||||||
}
|
|
||||||
if (configuration.getBoolean("packet-handlers.set-world-property")) {
|
|
||||||
msg.registerIncomingPluginChannel(this, "axiom:set_world_property", new SetWorldPropertyListener(this));
|
|
||||||
}
|
|
||||||
if (configuration.getBoolean("packet-handlers.set-single-block")) {
|
|
||||||
msg.registerIncomingPluginChannel(this, "axiom:set_block", new SetBlockPacketListener(this));
|
|
||||||
}
|
|
||||||
if (configuration.getBoolean("packet-handlers.set-hotbar-slot")) {
|
|
||||||
msg.registerIncomingPluginChannel(this, "axiom:set_hotbar_slot", new SetHotbarSlotPacketListener(this));
|
|
||||||
}
|
|
||||||
if (configuration.getBoolean("packet-handlers.switch-active-hotbar")) {
|
|
||||||
msg.registerIncomingPluginChannel(this, "axiom:switch_active_hotbar", new SwitchActiveHotbarPacketListener(this));
|
|
||||||
}
|
|
||||||
if (configuration.getBoolean("packet-handlers.teleport")) {
|
|
||||||
msg.registerIncomingPluginChannel(this, "axiom:teleport", new TeleportPacketListener(this));
|
|
||||||
}
|
|
||||||
if (configuration.getBoolean("packet-handlers.set-editor-views")) {
|
|
||||||
msg.registerIncomingPluginChannel(this, "axiom:set_editor_views", new SetEditorViewsPacketListener(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));
|
|
||||||
}
|
|
||||||
if (configuration.getBoolean("packet-handlers.manipulate-entity")) {
|
|
||||||
msg.registerIncomingPluginChannel(this, "axiom:manipulate_entity", new ManipulateEntityPacketListener(this));
|
|
||||||
}
|
|
||||||
if (configuration.getBoolean("packet-handlers.delete-entity")) {
|
|
||||||
msg.registerIncomingPluginChannel(this, "axiom:delete_entity", new DeleteEntityPacketListener(this));
|
|
||||||
}
|
|
||||||
if (configuration.getBoolean("packet-handlers.marker-nbt-request")) {
|
|
||||||
msg.registerIncomingPluginChannel(this, "axiom:marker_nbt_request", new MarkerNbtRequestPacketListener(this));
|
|
||||||
}
|
|
||||||
if (configuration.getBoolean("packet-handlers.blueprint-request")) {
|
|
||||||
msg.registerIncomingPluginChannel(this, "axiom:request_blueprint", new BlueprintRequestPacketListener(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configuration.getBoolean("packet-handlers.set-buffer")) {
|
registerPacketHandler("hello", new HelloPacketListener(this), msg, largePayloadHandlers);
|
||||||
SetBlockBufferPacketListener setBlockBufferPacketListener = new SetBlockBufferPacketListener(this);
|
registerPacketHandler("set_gamemode", new SetGamemodePacketListener(this), msg, largePayloadHandlers);
|
||||||
UploadBlueprintPacketListener uploadBlueprintPacketListener = new UploadBlueprintPacketListener(this);
|
registerPacketHandler("set_fly_speed", new SetFlySpeedPacketListener(this), msg, largePayloadHandlers);
|
||||||
UpdateAnnotationPacketListener updateAnnotationPacketListener = new UpdateAnnotationPacketListener(this);
|
registerPacketHandler("set_world_time", new SetTimePacketListener(this), msg, largePayloadHandlers);
|
||||||
RequestChunkDataPacketListener requestChunkDataPacketListener = allowLargeChunkDataRequest ?
|
registerPacketHandler("set_world_property", new SetWorldPropertyListener(this), msg, largePayloadHandlers);
|
||||||
new RequestChunkDataPacketListener(this) : null;
|
registerPacketHandler("set_block", new SetBlockPacketListener(this), msg, largePayloadHandlers); // set-single-block
|
||||||
|
registerPacketHandler("set_hotbar_slot", new SetHotbarSlotPacketListener(this), msg, largePayloadHandlers);
|
||||||
|
registerPacketHandler("switch_active_hotbar", new SwitchActiveHotbarPacketListener(this), msg, largePayloadHandlers);
|
||||||
|
registerPacketHandler("teleport", new TeleportPacketListener(this), msg, largePayloadHandlers);
|
||||||
|
registerPacketHandler("set_editor_views", new SetEditorViewsPacketListener(this), msg, largePayloadHandlers);
|
||||||
|
registerPacketHandler("request_chunk_data", new RequestChunkDataPacketListener(this,
|
||||||
|
!configuration.getBoolean("packet-handlers.request-chunk-data")), msg, largePayloadHandlers);
|
||||||
|
registerPacketHandler("spawn_entity", new SpawnEntityPacketListener(this), msg, largePayloadHandlers);
|
||||||
|
registerPacketHandler("manipulate_entity", new ManipulateEntityPacketListener(this), msg, largePayloadHandlers);
|
||||||
|
registerPacketHandler("delete_entity", new DeleteEntityPacketListener(this), msg, largePayloadHandlers);
|
||||||
|
registerPacketHandler("marker_nbt_request", new MarkerNbtRequestPacketListener(this), msg, largePayloadHandlers);
|
||||||
|
registerPacketHandler("request_blueprint", new BlueprintRequestPacketListener(this), msg, largePayloadHandlers);
|
||||||
|
|
||||||
|
registerPacketHandler("set_buffer", new SetBlockBufferPacketListener(this), msg, largePayloadHandlers);
|
||||||
|
registerPacketHandler("upload_blueprint", new UploadBlueprintPacketListener(this), msg, largePayloadHandlers);
|
||||||
|
registerPacketHandler("annotation_update", new UpdateAnnotationPacketListener(this), msg, largePayloadHandlers);
|
||||||
|
|
||||||
|
if (!largePayloadHandlers.isEmpty()) {
|
||||||
// Hack to figure out the id of the CustomPayload packet
|
// Hack to figure out the id of the CustomPayload packet
|
||||||
ProtocolInfo<ServerGamePacketListener> protocol = GameProtocols.SERVERBOUND.bind(k -> new RegistryFriendlyByteBuf(k,
|
ProtocolInfo<ServerGamePacketListener> protocol = GameProtocols.SERVERBOUND.bind(k -> new RegistryFriendlyByteBuf(k,
|
||||||
MinecraftServer.getServer().registryAccess()));
|
MinecraftServer.getServer().registryAccess()));
|
||||||
@ -181,8 +167,7 @@ public class AxiomPaper extends JavaPlugin implements Listener {
|
|||||||
public void afterInitChannel(@NonNull Channel channel) {
|
public void afterInitChannel(@NonNull Channel channel) {
|
||||||
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, largePayloadHandlers));
|
||||||
uploadBlueprintPacketListener, updateAnnotationPacketListener, requestChunkDataPacketListener));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -314,6 +299,35 @@ public class AxiomPaper extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerPacketHandler(String name, PacketHandler handler, Messenger messenger, Map<String, PacketHandler> largePayloadHandlers) {
|
||||||
|
String configEntry = "packet-handlers." + name.replace("_", "-");
|
||||||
|
if (name.equals("set_block")) {
|
||||||
|
configEntry = "packet-handlers.set-single-block";
|
||||||
|
} else if (name.equals("request_blueprint")) {
|
||||||
|
configEntry = "packet-handlers.blueprint-request";
|
||||||
|
}
|
||||||
|
if (name.equals("request-chunk-data") || this.configuration.getBoolean(configEntry, true)) {
|
||||||
|
boolean isLargePayload = false;
|
||||||
|
|
||||||
|
if (name.equals("hello")) { // Hello must use normal system, as non-Axiom players can't send large payloads
|
||||||
|
isLargePayload = false;
|
||||||
|
} else if (this.configuration.getBoolean("allow-large-payload-for-all-packets")) {
|
||||||
|
isLargePayload = true;
|
||||||
|
} else if (name.equals("set_buffer") || name.equals("upload_blueprint") || name.equals("annotation_update")) {
|
||||||
|
isLargePayload = true;
|
||||||
|
} else if (name.equals("request_chunk_data") && this.configuration.getBoolean("allow-large-chunk-data-request")) {
|
||||||
|
isLargePayload = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isLargePayload) {
|
||||||
|
largePayloadHandlers.put("axiom:"+name, handler);
|
||||||
|
messenger.registerIncomingPluginChannel(this, "axiom:"+name, new DummyPacketListener());
|
||||||
|
} else {
|
||||||
|
messenger.registerIncomingPluginChannel(this, "axiom:"+name, new WrapperPacketListener(handler));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int calculateAllowedCapabilities() {
|
private int calculateAllowedCapabilities() {
|
||||||
Set<String> allowed = new HashSet<>(this.configuration.getStringList("allow-capabilities"));
|
Set<String> allowed = new HashSet<>(this.configuration.getStringList("allow-capabilities"));
|
||||||
if (allowed.contains("all")) {
|
if (allowed.contains("all")) {
|
||||||
|
@ -2,42 +2,36 @@ package com.moulberry.axiom.packet;
|
|||||||
|
|
||||||
import com.moulberry.axiom.AxiomPaper;
|
import com.moulberry.axiom.AxiomPaper;
|
||||||
import com.moulberry.axiom.VersionHelper;
|
import com.moulberry.axiom.VersionHelper;
|
||||||
|
import com.moulberry.axiom.packet.impl.RequestChunkDataPacketListener;
|
||||||
|
import com.moulberry.axiom.packet.impl.SetBlockBufferPacketListener;
|
||||||
|
import com.moulberry.axiom.packet.impl.UpdateAnnotationPacketListener;
|
||||||
|
import com.moulberry.axiom.packet.impl.UploadBlueprintPacketListener;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.ChannelHandler;
|
import io.netty.buffer.Unpooled;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
|
||||||
import io.netty.handler.codec.MessageToMessageDecoder;
|
import io.netty.handler.codec.MessageToMessageDecoder;
|
||||||
import io.papermc.paper.network.ConnectionEvent;
|
import io.papermc.paper.network.ConnectionEvent;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minecraft.network.Connection;
|
import net.minecraft.network.Connection;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class AxiomBigPayloadHandler extends MessageToMessageDecoder<ByteBuf> {
|
public class AxiomBigPayloadHandler extends MessageToMessageDecoder<ByteBuf> {
|
||||||
|
|
||||||
private static final ResourceLocation SET_BUFFER = VersionHelper.createResourceLocation("axiom", "set_buffer");
|
|
||||||
private static final ResourceLocation UPLOAD_BLUEPRINT = VersionHelper.createResourceLocation("axiom", "upload_blueprint");
|
|
||||||
private static final ResourceLocation UPDATE_ANNOTATIONS = VersionHelper.createResourceLocation("axiom", "annotation_update");
|
|
||||||
private static final ResourceLocation REQUEST_CHUNK_DATA = VersionHelper.createResourceLocation("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 Map<String, PacketHandler> packetHandlers;
|
||||||
private final UploadBlueprintPacketListener uploadBlueprint;
|
|
||||||
private final UpdateAnnotationPacketListener updateAnnotation;
|
|
||||||
private final RequestChunkDataPacketListener requestChunkDataPacketListener;
|
|
||||||
|
|
||||||
public AxiomBigPayloadHandler(int payloadId, Connection connection, SetBlockBufferPacketListener setBlockBuffer,
|
public AxiomBigPayloadHandler(int payloadId, Connection connection, Map<String, PacketHandler> packetHandlers) {
|
||||||
UploadBlueprintPacketListener uploadBlueprint, UpdateAnnotationPacketListener updateAnnotation,
|
|
||||||
RequestChunkDataPacketListener requestChunkDataPacketListener) {
|
|
||||||
this.payloadId = payloadId;
|
this.payloadId = payloadId;
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.setBlockBuffer = setBlockBuffer;
|
this.packetHandlers = packetHandlers;
|
||||||
this.uploadBlueprint = uploadBlueprint;
|
|
||||||
this.updateAnnotation = updateAnnotation;
|
|
||||||
this.requestChunkDataPacketListener = requestChunkDataPacketListener;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -67,47 +61,29 @@ public class AxiomBigPayloadHandler extends MessageToMessageDecoder<ByteBuf> {
|
|||||||
int packetId = buf.readVarInt();
|
int packetId = buf.readVarInt();
|
||||||
|
|
||||||
if (packetId == payloadId) {
|
if (packetId == payloadId) {
|
||||||
ResourceLocation identifier = buf.readResourceLocation();
|
String identifier = buf.readUtf(32767);
|
||||||
if (identifier.equals(SET_BUFFER)) {
|
PacketHandler handler = this.packetHandlers.get(identifier);
|
||||||
setBlockBuffer.onReceive(player, buf);
|
if (handler != null) {
|
||||||
success = true;
|
if (handler.handleAsync()) {
|
||||||
if (in.readableBytes() > 0) {
|
handler.onReceive(player.getBukkitEntity(), buf);
|
||||||
throw new IOException("Axiom packet " + identifier + " was larger than I expected, found " + in.readableBytes() +
|
success = true;
|
||||||
" bytes extra whilst reading packet");
|
} else {
|
||||||
}
|
byte[] bytes = new byte[buf.writerIndex() - buf.readerIndex()];
|
||||||
return;
|
buf.getBytes(buf.readerIndex(), bytes);
|
||||||
} else if (identifier.equals(UPLOAD_BLUEPRINT)) {
|
Player bukkitPlayer = player.getBukkitEntity();
|
||||||
uploadBlueprint.onReceive(player, buf);
|
|
||||||
success = true;
|
|
||||||
if (in.readableBytes() > 0) {
|
|
||||||
throw new IOException("Axiom packet " + identifier + " was larger than I expected, found " + in.readableBytes() +
|
|
||||||
" bytes extra whilst reading packet");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else if (identifier.equals(UPDATE_ANNOTATIONS)) {
|
|
||||||
updateAnnotation.onReceive(player, buf);
|
|
||||||
success = true;
|
|
||||||
if (in.readableBytes() > 0) {
|
|
||||||
throw new IOException("Axiom packet " + identifier + " was larger than I expected, found " + in.readableBytes() +
|
|
||||||
" bytes extra whilst reading packet");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else if (requestChunkDataPacketListener != null && identifier.equals(REQUEST_CHUNK_DATA)) {
|
|
||||||
byte[] bytes = new byte[buf.writerIndex() - buf.readerIndex()];
|
|
||||||
buf.getBytes(buf.readerIndex(), bytes);
|
|
||||||
|
|
||||||
player.getServer().execute(() -> {
|
player.getServer().execute(() -> {
|
||||||
try {
|
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(bytes));
|
||||||
requestChunkDataPacketListener.onPluginMessageReceived(
|
try {
|
||||||
identifier.toString(), player.getBukkitEntity(), bytes);
|
handler.onReceive(bukkitPlayer, friendlyByteBuf);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
player.getBukkitEntity().kick(net.kyori.adventure.text.Component.text(
|
bukkitPlayer.kick(Component.text("Error while processing packet " + identifier + ": " + t.getMessage()));
|
||||||
"An error occured while requesting chunk data: " + t.getMessage()));
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
in.skipBytes(in.readableBytes());
|
in.readerIndex(in.writerIndex());
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,7 +110,7 @@ public class AxiomBigPayloadHandler extends MessageToMessageDecoder<ByteBuf> {
|
|||||||
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, updateAnnotation, requestChunkDataPacketListener));
|
new AxiomBigPayloadHandler(payloadId, connection, packetHandlers));
|
||||||
}
|
}
|
||||||
super.userEventTriggered(ctx, evt);
|
super.userEventTriggered(ctx, evt);
|
||||||
}
|
}
|
||||||
|
18
src/main/java/com/moulberry/axiom/packet/DummyPacketListener.java
Normale Datei
18
src/main/java/com/moulberry/axiom/packet/DummyPacketListener.java
Normale Datei
@ -0,0 +1,18 @@
|
|||||||
|
package com.moulberry.axiom.packet;
|
||||||
|
|
||||||
|
import io.netty.buffer.Unpooled;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class DummyPacketListener implements PluginMessageListener {
|
||||||
|
|
||||||
|
public DummyPacketListener() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPluginMessageReceived(@NotNull String s, @NotNull Player player, @NotNull byte[] bytes) {
|
||||||
|
}
|
||||||
|
}
|
15
src/main/java/com/moulberry/axiom/packet/PacketHandler.java
Normale Datei
15
src/main/java/com/moulberry/axiom/packet/PacketHandler.java
Normale Datei
@ -0,0 +1,15 @@
|
|||||||
|
package com.moulberry.axiom.packet;
|
||||||
|
|
||||||
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public interface PacketHandler {
|
||||||
|
|
||||||
|
default boolean handleAsync() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void onReceive(Player player, FriendlyByteBuf friendlyByteBuf);
|
||||||
|
|
||||||
|
}
|
27
src/main/java/com/moulberry/axiom/packet/WrapperPacketListener.java
Normale Datei
27
src/main/java/com/moulberry/axiom/packet/WrapperPacketListener.java
Normale Datei
@ -0,0 +1,27 @@
|
|||||||
|
package com.moulberry.axiom.packet;
|
||||||
|
|
||||||
|
import io.netty.buffer.Unpooled;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class WrapperPacketListener implements PluginMessageListener {
|
||||||
|
|
||||||
|
private final PacketHandler packetHandler;
|
||||||
|
|
||||||
|
public WrapperPacketListener(PacketHandler packetHandler) {
|
||||||
|
this.packetHandler = packetHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPluginMessageReceived(@NotNull String s, @NotNull Player player, @NotNull byte[] bytes) {
|
||||||
|
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(bytes));
|
||||||
|
try {
|
||||||
|
this.packetHandler.onReceive(player, friendlyByteBuf);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
player.kick(Component.text("Error while processing packet " + s + ": " + t.getMessage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,11 @@
|
|||||||
package com.moulberry.axiom.packet;
|
package com.moulberry.axiom.packet.impl;
|
||||||
|
|
||||||
import com.moulberry.axiom.AxiomPaper;
|
import com.moulberry.axiom.AxiomPaper;
|
||||||
import com.moulberry.axiom.VersionHelper;
|
import com.moulberry.axiom.VersionHelper;
|
||||||
import com.moulberry.axiom.blueprint.RawBlueprint;
|
import com.moulberry.axiom.blueprint.RawBlueprint;
|
||||||
import com.moulberry.axiom.blueprint.ServerBlueprintManager;
|
import com.moulberry.axiom.blueprint.ServerBlueprintManager;
|
||||||
import com.moulberry.axiom.blueprint.ServerBlueprintRegistry;
|
import com.moulberry.axiom.blueprint.ServerBlueprintRegistry;
|
||||||
|
import com.moulberry.axiom.packet.PacketHandler;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minecraft.SharedConstants;
|
import net.minecraft.SharedConstants;
|
||||||
@ -15,9 +16,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.UUID;
|
public class BlueprintRequestPacketListener implements PacketHandler {
|
||||||
|
|
||||||
public class BlueprintRequestPacketListener implements PluginMessageListener {
|
|
||||||
|
|
||||||
private final AxiomPaper plugin;
|
private final AxiomPaper plugin;
|
||||||
public BlueprintRequestPacketListener(AxiomPaper plugin) {
|
public BlueprintRequestPacketListener(AxiomPaper plugin) {
|
||||||
@ -27,15 +26,7 @@ public class BlueprintRequestPacketListener implements PluginMessageListener {
|
|||||||
private static final ResourceLocation RESPONSE_PACKET_IDENTIFIER = VersionHelper.createResourceLocation("axiom:response_blueprint");
|
private static final ResourceLocation RESPONSE_PACKET_IDENTIFIER = VersionHelper.createResourceLocation("axiom:response_blueprint");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) {
|
public void onReceive(Player player, FriendlyByteBuf friendlyByteBuf) {
|
||||||
try {
|
|
||||||
this.process(player, message);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
player.kick(Component.text("Error while processing packet " + channel + ": " + t.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void process(Player player, byte[] message) {
|
|
||||||
if (!this.plugin.canUseAxiom(player, "axiom.blueprint.request")) {
|
if (!this.plugin.canUseAxiom(player, "axiom.blueprint.request")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -45,7 +36,6 @@ public class BlueprintRequestPacketListener implements PluginMessageListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(message));
|
|
||||||
String path = friendlyByteBuf.readUtf();
|
String path = friendlyByteBuf.readUtf();
|
||||||
|
|
||||||
ServerBlueprintRegistry registry = ServerBlueprintManager.getRegistry();
|
ServerBlueprintRegistry registry = ServerBlueprintManager.getRegistry();
|
@ -1,8 +1,8 @@
|
|||||||
package com.moulberry.axiom.packet;
|
package com.moulberry.axiom.packet.impl;
|
||||||
|
|
||||||
import com.moulberry.axiom.AxiomPaper;
|
import com.moulberry.axiom.AxiomPaper;
|
||||||
import com.moulberry.axiom.integration.Integration;
|
import com.moulberry.axiom.integration.Integration;
|
||||||
import com.moulberry.axiom.integration.plotsquared.PlotSquaredIntegration;
|
import com.moulberry.axiom.packet.PacketHandler;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
@ -18,7 +18,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DeleteEntityPacketListener implements PluginMessageListener {
|
public class DeleteEntityPacketListener implements PacketHandler {
|
||||||
|
|
||||||
private final AxiomPaper plugin;
|
private final AxiomPaper plugin;
|
||||||
public DeleteEntityPacketListener(AxiomPaper plugin) {
|
public DeleteEntityPacketListener(AxiomPaper plugin) {
|
||||||
@ -26,15 +26,7 @@ public class DeleteEntityPacketListener implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) {
|
public void onReceive(Player player, FriendlyByteBuf friendlyByteBuf) {
|
||||||
try {
|
|
||||||
this.process(player, message);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
player.kick(Component.text("Error while processing packet " + channel + ": " + t.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void process(Player player, byte[] message) {
|
|
||||||
if (!this.plugin.canUseAxiom(player, "axiom.entity.delete", true)) {
|
if (!this.plugin.canUseAxiom(player, "axiom.entity.delete", true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -43,7 +35,6 @@ public class DeleteEntityPacketListener implements PluginMessageListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(message));
|
|
||||||
List<UUID> delete = friendlyByteBuf.readCollection(FriendlyByteBuf.limitValue(ArrayList::new, 1000),
|
List<UUID> delete = friendlyByteBuf.readCollection(FriendlyByteBuf.limitValue(ArrayList::new, 1000),
|
||||||
buf -> buf.readUUID());
|
buf -> buf.readUUID());
|
||||||
|
|
@ -1,15 +1,14 @@
|
|||||||
package com.moulberry.axiom.packet;
|
package com.moulberry.axiom.packet.impl;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.RateLimiter;
|
import com.google.common.util.concurrent.RateLimiter;
|
||||||
import com.moulberry.axiom.*;
|
import com.moulberry.axiom.*;
|
||||||
import com.moulberry.axiom.annotations.ServerAnnotations;
|
|
||||||
import com.moulberry.axiom.blueprint.ServerBlueprintManager;
|
import com.moulberry.axiom.blueprint.ServerBlueprintManager;
|
||||||
import com.moulberry.axiom.event.AxiomHandshakeEvent;
|
import com.moulberry.axiom.event.AxiomHandshakeEvent;
|
||||||
|
import com.moulberry.axiom.packet.PacketHandler;
|
||||||
import com.moulberry.axiom.persistence.ItemStackDataType;
|
import com.moulberry.axiom.persistence.ItemStackDataType;
|
||||||
import com.moulberry.axiom.persistence.UUIDDataType;
|
import com.moulberry.axiom.persistence.UUIDDataType;
|
||||||
import com.moulberry.axiom.viaversion.ViaVersionHelper;
|
import com.moulberry.axiom.viaversion.ViaVersionHelper;
|
||||||
import com.moulberry.axiom.world_properties.server.ServerWorldPropertiesRegistry;
|
import com.moulberry.axiom.world_properties.server.ServerWorldPropertiesRegistry;
|
||||||
import com.viaversion.viaversion.api.Via;
|
|
||||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -30,13 +29,11 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.persistence.PersistentDataContainer;
|
import org.bukkit.persistence.PersistentDataContainer;
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class HelloPacketListener implements PluginMessageListener {
|
public class HelloPacketListener implements PacketHandler {
|
||||||
|
|
||||||
private final AxiomPaper plugin;
|
private final AxiomPaper plugin;
|
||||||
|
|
||||||
@ -45,20 +42,11 @@ public class HelloPacketListener implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) {
|
public void onReceive(Player player, FriendlyByteBuf friendlyByteBuf) {
|
||||||
try {
|
|
||||||
this.process(player, message);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
player.kick(Component.text("Error while processing packet " + channel + ": " + t.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void process(Player player, byte[] message) {
|
|
||||||
if (!this.plugin.hasAxiomPermission(player)) {
|
if (!this.plugin.hasAxiomPermission(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(message));
|
|
||||||
int apiVersion = friendlyByteBuf.readVarInt();
|
int apiVersion = friendlyByteBuf.readVarInt();
|
||||||
|
|
||||||
if (apiVersion != AxiomConstants.API_VERSION) {
|
if (apiVersion != AxiomConstants.API_VERSION) {
|
@ -1,12 +1,11 @@
|
|||||||
package com.moulberry.axiom.packet;
|
package com.moulberry.axiom.packet.impl;
|
||||||
|
|
||||||
import com.moulberry.axiom.AxiomPaper;
|
import com.moulberry.axiom.AxiomPaper;
|
||||||
import com.moulberry.axiom.NbtSanitization;
|
import com.moulberry.axiom.NbtSanitization;
|
||||||
import com.moulberry.axiom.event.AxiomManipulateEntityEvent;
|
import com.moulberry.axiom.event.AxiomManipulateEntityEvent;
|
||||||
import com.moulberry.axiom.integration.Integration;
|
import com.moulberry.axiom.integration.Integration;
|
||||||
import com.moulberry.axiom.integration.plotsquared.PlotSquaredIntegration;
|
import com.moulberry.axiom.packet.PacketHandler;
|
||||||
import com.moulberry.axiom.viaversion.UnknownVersionHelper;
|
import com.moulberry.axiom.viaversion.UnknownVersionHelper;
|
||||||
import com.moulberry.axiom.viaversion.ViaVersionHelper;
|
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
@ -34,7 +33,7 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ManipulateEntityPacketListener implements PluginMessageListener {
|
public class ManipulateEntityPacketListener implements PacketHandler {
|
||||||
|
|
||||||
private final AxiomPaper plugin;
|
private final AxiomPaper plugin;
|
||||||
public ManipulateEntityPacketListener(AxiomPaper plugin) {
|
public ManipulateEntityPacketListener(AxiomPaper plugin) {
|
||||||
@ -82,15 +81,7 @@ public class ManipulateEntityPacketListener implements PluginMessageListener {
|
|||||||
private static final Rotation[] ROTATION_VALUES = Rotation.values();
|
private static final Rotation[] ROTATION_VALUES = Rotation.values();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) {
|
public void onReceive(Player player, FriendlyByteBuf friendlyByteBuf) {
|
||||||
try {
|
|
||||||
this.process(player, message);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
player.kick(Component.text("Error while processing packet " + channel + ": " + t.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void process(Player player, byte[] message) {
|
|
||||||
if (!this.plugin.canUseAxiom(player, "axiom.entity.manipulate", true)) {
|
if (!this.plugin.canUseAxiom(player, "axiom.entity.manipulate", true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -99,7 +90,6 @@ public class ManipulateEntityPacketListener implements PluginMessageListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(message));
|
|
||||||
List<ManipulateEntry> entries = friendlyByteBuf.readCollection(FriendlyByteBuf.limitValue(ArrayList::new, 1000),
|
List<ManipulateEntry> entries = friendlyByteBuf.readCollection(FriendlyByteBuf.limitValue(ArrayList::new, 1000),
|
||||||
buf -> ManipulateEntry.read(buf, player));
|
buf -> ManipulateEntry.read(buf, player));
|
||||||
|
|
@ -1,7 +1,8 @@
|
|||||||
package com.moulberry.axiom.packet;
|
package com.moulberry.axiom.packet.impl;
|
||||||
|
|
||||||
import com.moulberry.axiom.AxiomPaper;
|
import com.moulberry.axiom.AxiomPaper;
|
||||||
import com.moulberry.axiom.marker.MarkerData;
|
import com.moulberry.axiom.marker.MarkerData;
|
||||||
|
import com.moulberry.axiom.packet.PacketHandler;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
@ -16,7 +17,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class MarkerNbtRequestPacketListener implements PluginMessageListener {
|
public class MarkerNbtRequestPacketListener implements PacketHandler {
|
||||||
|
|
||||||
private final AxiomPaper plugin;
|
private final AxiomPaper plugin;
|
||||||
public MarkerNbtRequestPacketListener(AxiomPaper plugin) {
|
public MarkerNbtRequestPacketListener(AxiomPaper plugin) {
|
||||||
@ -24,15 +25,7 @@ public class MarkerNbtRequestPacketListener implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) {
|
public void onReceive(Player player, FriendlyByteBuf friendlyByteBuf) {
|
||||||
try {
|
|
||||||
this.process(player, message);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
player.kick(Component.text("Error while processing packet " + channel + ": " + t.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void process(Player player, byte[] message) {
|
|
||||||
if (!this.plugin.canUseAxiom(player, "axiom.entity.manipulate", true)) {
|
if (!this.plugin.canUseAxiom(player, "axiom.entity.manipulate", true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -41,7 +34,6 @@ public class MarkerNbtRequestPacketListener implements PluginMessageListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(message));
|
|
||||||
UUID uuid = friendlyByteBuf.readUUID();
|
UUID uuid = friendlyByteBuf.readUUID();
|
||||||
|
|
||||||
ServerLevel serverLevel = ((CraftWorld)player.getWorld()).getHandle();
|
ServerLevel serverLevel = ((CraftWorld)player.getWorld()).getHandle();
|
@ -1,10 +1,11 @@
|
|||||||
package com.moulberry.axiom.packet;
|
package com.moulberry.axiom.packet.impl;
|
||||||
|
|
||||||
import com.moulberry.axiom.AxiomConstants;
|
import com.moulberry.axiom.AxiomConstants;
|
||||||
import com.moulberry.axiom.AxiomPaper;
|
import com.moulberry.axiom.AxiomPaper;
|
||||||
import com.moulberry.axiom.VersionHelper;
|
import com.moulberry.axiom.VersionHelper;
|
||||||
import com.moulberry.axiom.buffer.CompressedBlockEntity;
|
import com.moulberry.axiom.buffer.CompressedBlockEntity;
|
||||||
import com.moulberry.axiom.integration.plotsquared.PlotSquaredIntegration;
|
import com.moulberry.axiom.integration.plotsquared.PlotSquaredIntegration;
|
||||||
|
import com.moulberry.axiom.packet.PacketHandler;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import it.unimi.dsi.fastutil.longs.*;
|
import it.unimi.dsi.fastutil.longs.*;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -32,30 +33,23 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
|
||||||
public class RequestChunkDataPacketListener implements PluginMessageListener {
|
public class RequestChunkDataPacketListener implements PacketHandler {
|
||||||
|
|
||||||
private static final ResourceLocation RESPONSE_ID = VersionHelper.createResourceLocation("axiom:response_chunk_data");
|
private static final ResourceLocation RESPONSE_ID = VersionHelper.createResourceLocation("axiom:response_chunk_data");
|
||||||
|
|
||||||
private final AxiomPaper plugin;
|
private final AxiomPaper plugin;
|
||||||
public RequestChunkDataPacketListener(AxiomPaper plugin) {
|
private final boolean forceFail;
|
||||||
|
public RequestChunkDataPacketListener(AxiomPaper plugin, boolean forceFail) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.forceFail = forceFail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) {
|
public void onReceive(Player bukkitPlayer, FriendlyByteBuf friendlyByteBuf) {
|
||||||
try {
|
|
||||||
this.process(player, message);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
player.kick(Component.text("Error while processing packet " + channel + ": " + t.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void process(Player bukkitPlayer, byte[] message) {
|
|
||||||
ServerPlayer player = ((CraftPlayer)bukkitPlayer).getHandle();
|
ServerPlayer player = ((CraftPlayer)bukkitPlayer).getHandle();
|
||||||
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(message));
|
|
||||||
long id = friendlyByteBuf.readLong();
|
long id = friendlyByteBuf.readLong();
|
||||||
|
|
||||||
if (!this.plugin.canUseAxiom(bukkitPlayer, "axiom.chunk.request") || this.plugin.isMismatchedDataVersion(bukkitPlayer.getUniqueId())) {
|
if (this.forceFail || !this.plugin.canUseAxiom(bukkitPlayer, "axiom.chunk.request") || this.plugin.isMismatchedDataVersion(bukkitPlayer.getUniqueId())) {
|
||||||
// We always send an 'empty' response in order to make the client happy
|
// We always send an 'empty' response in order to make the client happy
|
||||||
sendEmptyResponse(player, id);
|
sendEmptyResponse(player, id);
|
||||||
return;
|
return;
|
@ -1,4 +1,4 @@
|
|||||||
package com.moulberry.axiom.packet;
|
package com.moulberry.axiom.packet.impl;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.RateLimiter;
|
import com.google.common.util.concurrent.RateLimiter;
|
||||||
import com.moulberry.axiom.AxiomPaper;
|
import com.moulberry.axiom.AxiomPaper;
|
||||||
@ -9,6 +9,7 @@ import com.moulberry.axiom.buffer.CompressedBlockEntity;
|
|||||||
import com.moulberry.axiom.integration.Integration;
|
import com.moulberry.axiom.integration.Integration;
|
||||||
import com.moulberry.axiom.integration.SectionPermissionChecker;
|
import com.moulberry.axiom.integration.SectionPermissionChecker;
|
||||||
import com.moulberry.axiom.integration.coreprotect.CoreProtectIntegration;
|
import com.moulberry.axiom.integration.coreprotect.CoreProtectIntegration;
|
||||||
|
import com.moulberry.axiom.packet.PacketHandler;
|
||||||
import com.moulberry.axiom.viaversion.UnknownVersionHelper;
|
import com.moulberry.axiom.viaversion.UnknownVersionHelper;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.shorts.Short2ObjectMap;
|
import it.unimi.dsi.fastutil.shorts.Short2ObjectMap;
|
||||||
@ -41,6 +42,8 @@ import net.minecraft.world.level.chunk.PalettedContainer;
|
|||||||
import net.minecraft.world.level.levelgen.Heightmap;
|
import net.minecraft.world.level.levelgen.Heightmap;
|
||||||
import net.minecraft.world.level.lighting.LightEngine;
|
import net.minecraft.world.level.lighting.LightEngine;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import xyz.jpenilla.reflectionremapper.ReflectionRemapper;
|
import xyz.jpenilla.reflectionremapper.ReflectionRemapper;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@ -48,11 +51,10 @@ import java.lang.reflect.Method;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
public class SetBlockBufferPacketListener {
|
public class SetBlockBufferPacketListener implements PacketHandler {
|
||||||
|
|
||||||
private final AxiomPaper plugin;
|
private final AxiomPaper plugin;
|
||||||
private final Method updateBlockEntityTicker;
|
private final Method updateBlockEntityTicker;
|
||||||
private final WeakHashMap<ServerPlayer, RateLimiter> packetRateLimiter = new WeakHashMap<>();
|
|
||||||
|
|
||||||
public SetBlockBufferPacketListener(AxiomPaper plugin) {
|
public SetBlockBufferPacketListener(AxiomPaper plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@ -69,8 +71,14 @@ public class SetBlockBufferPacketListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onReceive(ServerPlayer player, FriendlyByteBuf friendlyByteBuf) {
|
@Override
|
||||||
MinecraftServer server = player.getServer();
|
public boolean handleAsync() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onReceive(Player player, FriendlyByteBuf friendlyByteBuf) {
|
||||||
|
ServerPlayer serverPlayer = ((CraftPlayer)player).getHandle();
|
||||||
|
MinecraftServer server = serverPlayer.getServer();
|
||||||
if (server == null) return;
|
if (server == null) return;
|
||||||
|
|
||||||
ResourceKey<Level> worldKey = friendlyByteBuf.readResourceKey(Registries.DIMENSION);
|
ResourceKey<Level> worldKey = friendlyByteBuf.readResourceKey(Registries.DIMENSION);
|
||||||
@ -78,42 +86,42 @@ public class SetBlockBufferPacketListener {
|
|||||||
boolean continuation = friendlyByteBuf.readBoolean();
|
boolean continuation = friendlyByteBuf.readBoolean();
|
||||||
|
|
||||||
if (!continuation) {
|
if (!continuation) {
|
||||||
UnknownVersionHelper.skipTagUnknown(friendlyByteBuf, player.getBukkitEntity());
|
UnknownVersionHelper.skipTagUnknown(friendlyByteBuf, serverPlayer.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
RateLimiter rateLimiter = this.plugin.getBlockBufferRateLimiter(player.getUUID());
|
RateLimiter rateLimiter = this.plugin.getBlockBufferRateLimiter(serverPlayer.getUUID());
|
||||||
|
|
||||||
byte type = friendlyByteBuf.readByte();
|
byte type = friendlyByteBuf.readByte();
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
AtomicBoolean reachedRateLimit = new AtomicBoolean(false);
|
AtomicBoolean reachedRateLimit = new AtomicBoolean(false);
|
||||||
BlockBuffer buffer = BlockBuffer.load(friendlyByteBuf, rateLimiter, reachedRateLimit, this.plugin.getBlockRegistry(player.getUUID()));
|
BlockBuffer buffer = BlockBuffer.load(friendlyByteBuf, rateLimiter, reachedRateLimit, this.plugin.getBlockRegistry(serverPlayer.getUUID()));
|
||||||
if (reachedRateLimit.get()) {
|
if (reachedRateLimit.get()) {
|
||||||
player.sendSystemMessage(Component.literal("[Axiom] Exceeded server rate-limit of " + (int)rateLimiter.getRate() + " sections per second")
|
serverPlayer.sendSystemMessage(Component.literal("[Axiom] Exceeded server rate-limit of " + (int)rateLimiter.getRate() + " sections per second")
|
||||||
.withStyle(ChatFormatting.RED));
|
.withStyle(ChatFormatting.RED));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.plugin.logLargeBlockBufferChanges()) {
|
if (this.plugin.logLargeBlockBufferChanges()) {
|
||||||
this.plugin.getLogger().info("Player " + player.getUUID() + " modified " + buffer.entrySet().size() + " chunk sections (blocks)");
|
this.plugin.getLogger().info("Player " + serverPlayer.getUUID() + " modified " + buffer.entrySet().size() + " chunk sections (blocks)");
|
||||||
if (buffer.getTotalBlockEntities() > 0) {
|
if (buffer.getTotalBlockEntities() > 0) {
|
||||||
this.plugin.getLogger().info("Player " + player.getUUID() + " modified " + buffer.getTotalBlockEntities() + " block entities, compressed bytes = " +
|
this.plugin.getLogger().info("Player " + serverPlayer.getUUID() + " modified " + buffer.getTotalBlockEntities() + " block entities, compressed bytes = " +
|
||||||
buffer.getTotalBlockEntityBytes());
|
buffer.getTotalBlockEntityBytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
applyBlockBuffer(player, server, buffer, worldKey);
|
applyBlockBuffer(serverPlayer, server, buffer, worldKey);
|
||||||
} else if (type == 1) {
|
} else if (type == 1) {
|
||||||
AtomicBoolean reachedRateLimit = new AtomicBoolean(false);
|
AtomicBoolean reachedRateLimit = new AtomicBoolean(false);
|
||||||
BiomeBuffer buffer = BiomeBuffer.load(friendlyByteBuf, rateLimiter, reachedRateLimit);
|
BiomeBuffer buffer = BiomeBuffer.load(friendlyByteBuf, rateLimiter, reachedRateLimit);
|
||||||
if (reachedRateLimit.get()) {
|
if (reachedRateLimit.get()) {
|
||||||
player.sendSystemMessage(Component.literal("[Axiom] Exceeded server rate-limit of " + (int)rateLimiter.getRate() + " sections per second")
|
serverPlayer.sendSystemMessage(Component.literal("[Axiom] Exceeded server rate-limit of " + (int)rateLimiter.getRate() + " sections per second")
|
||||||
.withStyle(ChatFormatting.RED));
|
.withStyle(ChatFormatting.RED));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.plugin.logLargeBlockBufferChanges()) {
|
if (this.plugin.logLargeBlockBufferChanges()) {
|
||||||
this.plugin.getLogger().info("Player " + player.getUUID() + " modified " + buffer.size() + " chunk sections (biomes)");
|
this.plugin.getLogger().info("Player " + serverPlayer.getUUID() + " modified " + buffer.size() + " chunk sections (biomes)");
|
||||||
}
|
}
|
||||||
|
|
||||||
applyBiomeBuffer(player, server, buffer, worldKey);
|
applyBiomeBuffer(serverPlayer, server, buffer, worldKey);
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Unknown buffer type: " + type);
|
throw new RuntimeException("Unknown buffer type: " + type);
|
||||||
}
|
}
|
@ -1,9 +1,10 @@
|
|||||||
package com.moulberry.axiom.packet;
|
package com.moulberry.axiom.packet.impl;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.moulberry.axiom.AxiomPaper;
|
import com.moulberry.axiom.AxiomPaper;
|
||||||
import com.moulberry.axiom.integration.Integration;
|
import com.moulberry.axiom.integration.Integration;
|
||||||
import com.moulberry.axiom.integration.coreprotect.CoreProtectIntegration;
|
import com.moulberry.axiom.integration.coreprotect.CoreProtectIntegration;
|
||||||
|
import com.moulberry.axiom.packet.PacketHandler;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
@ -54,7 +55,7 @@ import java.util.Objects;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.IntFunction;
|
import java.util.function.IntFunction;
|
||||||
|
|
||||||
public class SetBlockPacketListener implements PluginMessageListener {
|
public class SetBlockPacketListener implements PacketHandler {
|
||||||
|
|
||||||
private final AxiomPaper plugin;
|
private final AxiomPaper plugin;
|
||||||
private final Method updateBlockEntityTicker;
|
private final Method updateBlockEntityTicker;
|
||||||
@ -74,22 +75,14 @@ public class SetBlockPacketListener implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) {
|
|
||||||
try {
|
|
||||||
this.process(player, message);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
player.kick(Component.text("Error while processing packet " + channel + ": " + t.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class AxiomPlacingCraftBlockState extends CraftBlockState {
|
public static class AxiomPlacingCraftBlockState extends CraftBlockState {
|
||||||
public AxiomPlacingCraftBlockState(@Nullable World world, BlockPos blockPosition, BlockState blockData) {
|
public AxiomPlacingCraftBlockState(@Nullable World world, BlockPos blockPosition, BlockState blockData) {
|
||||||
super(world, blockPosition, blockData);
|
super(world, blockPosition, blockData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void process(Player bukkitPlayer, byte[] message) {
|
@Override
|
||||||
|
public void onReceive(Player bukkitPlayer, FriendlyByteBuf friendlyByteBuf) {
|
||||||
if (!this.plugin.canUseAxiom(bukkitPlayer, "axiom.build.place")) {
|
if (!this.plugin.canUseAxiom(bukkitPlayer, "axiom.build.place")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -99,7 +92,6 @@ public class SetBlockPacketListener implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read packet
|
// Read packet
|
||||||
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(message));
|
|
||||||
IntFunction<Map<BlockPos, BlockState>> mapFunction = FriendlyByteBuf.limitValue(Maps::newLinkedHashMapWithExpectedSize, 512);
|
IntFunction<Map<BlockPos, BlockState>> mapFunction = FriendlyByteBuf.limitValue(Maps::newLinkedHashMapWithExpectedSize, 512);
|
||||||
IdMapper<BlockState> registry = this.plugin.getBlockRegistry(bukkitPlayer.getUniqueId());
|
IdMapper<BlockState> registry = this.plugin.getBlockRegistry(bukkitPlayer.getUniqueId());
|
||||||
Map<BlockPos, BlockState> blocks = friendlyByteBuf.readMap(mapFunction,
|
Map<BlockPos, BlockState> blocks = friendlyByteBuf.readMap(mapFunction,
|
@ -1,9 +1,10 @@
|
|||||||
package com.moulberry.axiom.packet;
|
package com.moulberry.axiom.packet.impl;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.moulberry.axiom.AxiomConstants;
|
import com.moulberry.axiom.AxiomConstants;
|
||||||
import com.moulberry.axiom.AxiomPaper;
|
import com.moulberry.axiom.AxiomPaper;
|
||||||
import com.moulberry.axiom.View;
|
import com.moulberry.axiom.View;
|
||||||
|
import com.moulberry.axiom.packet.PacketHandler;
|
||||||
import com.moulberry.axiom.persistence.UUIDDataType;
|
import com.moulberry.axiom.persistence.UUIDDataType;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -18,7 +19,7 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.IntFunction;
|
import java.util.function.IntFunction;
|
||||||
|
|
||||||
public class SetEditorViewsPacketListener implements PluginMessageListener {
|
public class SetEditorViewsPacketListener implements PacketHandler {
|
||||||
|
|
||||||
private final AxiomPaper plugin;
|
private final AxiomPaper plugin;
|
||||||
public SetEditorViewsPacketListener(AxiomPaper plugin) {
|
public SetEditorViewsPacketListener(AxiomPaper plugin) {
|
||||||
@ -26,20 +27,11 @@ public class SetEditorViewsPacketListener implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) {
|
public void onReceive(Player player, FriendlyByteBuf friendlyByteBuf) {
|
||||||
try {
|
|
||||||
this.process(player, message);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
player.kick(Component.text("Error while processing packet " + channel + ": " + t.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void process(Player player, byte[] message) {
|
|
||||||
if (!this.plugin.canUseAxiom(player, "axiom.editor.views")) {
|
if (!this.plugin.canUseAxiom(player, "axiom.editor.views")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(message));
|
|
||||||
UUID uuid = friendlyByteBuf.readUUID();
|
UUID uuid = friendlyByteBuf.readUUID();
|
||||||
IntFunction<List<View>> listFunction = FriendlyByteBuf.limitValue(Lists::newArrayListWithCapacity, 64);
|
IntFunction<List<View>> listFunction = FriendlyByteBuf.limitValue(Lists::newArrayListWithCapacity, 64);
|
||||||
List<View> views = friendlyByteBuf.readCollection(listFunction, View::read);
|
List<View> views = friendlyByteBuf.readCollection(listFunction, View::read);
|
@ -1,7 +1,8 @@
|
|||||||
package com.moulberry.axiom.packet;
|
package com.moulberry.axiom.packet.impl;
|
||||||
|
|
||||||
import com.moulberry.axiom.AxiomPaper;
|
import com.moulberry.axiom.AxiomPaper;
|
||||||
import com.moulberry.axiom.event.AxiomFlySpeedChangeEvent;
|
import com.moulberry.axiom.event.AxiomFlySpeedChangeEvent;
|
||||||
|
import com.moulberry.axiom.packet.PacketHandler;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
@ -11,7 +12,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class SetFlySpeedPacketListener implements PluginMessageListener {
|
public class SetFlySpeedPacketListener implements PacketHandler {
|
||||||
|
|
||||||
private final AxiomPaper plugin;
|
private final AxiomPaper plugin;
|
||||||
public SetFlySpeedPacketListener(AxiomPaper plugin) {
|
public SetFlySpeedPacketListener(AxiomPaper plugin) {
|
||||||
@ -19,20 +20,11 @@ public class SetFlySpeedPacketListener implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) {
|
public void onReceive(Player player, FriendlyByteBuf friendlyByteBuf) {
|
||||||
try {
|
|
||||||
this.process(player, message);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
player.kick(Component.text("Error while processing packet " + channel + ": " + t.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void process(Player player, byte[] message) {
|
|
||||||
if (!this.plugin.canUseAxiom(player, "axiom.player.speed")) {
|
if (!this.plugin.canUseAxiom(player, "axiom.player.speed")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(message));
|
|
||||||
float flySpeed = friendlyByteBuf.readFloat();
|
float flySpeed = friendlyByteBuf.readFloat();
|
||||||
|
|
||||||
// Call event
|
// Call event
|
@ -1,7 +1,8 @@
|
|||||||
package com.moulberry.axiom.packet;
|
package com.moulberry.axiom.packet.impl;
|
||||||
|
|
||||||
import com.moulberry.axiom.AxiomPaper;
|
import com.moulberry.axiom.AxiomPaper;
|
||||||
import com.moulberry.axiom.event.AxiomGameModeChangeEvent;
|
import com.moulberry.axiom.event.AxiomGameModeChangeEvent;
|
||||||
|
import com.moulberry.axiom.packet.PacketHandler;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
@ -13,7 +14,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class SetGamemodePacketListener implements PluginMessageListener {
|
public class SetGamemodePacketListener implements PacketHandler {
|
||||||
|
|
||||||
private final AxiomPaper plugin;
|
private final AxiomPaper plugin;
|
||||||
public SetGamemodePacketListener(AxiomPaper plugin) {
|
public SetGamemodePacketListener(AxiomPaper plugin) {
|
||||||
@ -21,20 +22,11 @@ public class SetGamemodePacketListener implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) {
|
public void onReceive(Player player, FriendlyByteBuf friendlyByteBuf) {
|
||||||
try {
|
|
||||||
this.process(player, message);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
player.kick(Component.text("Error while processing packet " + channel + ": " + t.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void process(Player player, byte[] message) {
|
|
||||||
if (!this.plugin.canUseAxiom(player, "axiom.player.gamemode")) {
|
if (!this.plugin.canUseAxiom(player, "axiom.player.gamemode")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(message));
|
|
||||||
GameType gameType = GameType.byId(friendlyByteBuf.readByte());
|
GameType gameType = GameType.byId(friendlyByteBuf.readByte());
|
||||||
|
|
||||||
// Call event
|
// Call event
|
@ -1,9 +1,9 @@
|
|||||||
package com.moulberry.axiom.packet;
|
package com.moulberry.axiom.packet.impl;
|
||||||
|
|
||||||
import com.moulberry.axiom.AxiomConstants;
|
import com.moulberry.axiom.AxiomConstants;
|
||||||
import com.moulberry.axiom.AxiomPaper;
|
import com.moulberry.axiom.AxiomPaper;
|
||||||
|
import com.moulberry.axiom.packet.PacketHandler;
|
||||||
import com.moulberry.axiom.persistence.ItemStackDataType;
|
import com.moulberry.axiom.persistence.ItemStackDataType;
|
||||||
import com.viaversion.viaversion.api.Via;
|
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
@ -18,7 +18,7 @@ import org.bukkit.persistence.PersistentDataType;
|
|||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class SetHotbarSlotPacketListener implements PluginMessageListener {
|
public class SetHotbarSlotPacketListener implements PacketHandler {
|
||||||
|
|
||||||
private final AxiomPaper plugin;
|
private final AxiomPaper plugin;
|
||||||
public SetHotbarSlotPacketListener(AxiomPaper plugin) {
|
public SetHotbarSlotPacketListener(AxiomPaper plugin) {
|
||||||
@ -26,20 +26,11 @@ public class SetHotbarSlotPacketListener implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) {
|
public void onReceive(Player player, FriendlyByteBuf friendlyByteBuf) {
|
||||||
try {
|
|
||||||
this.process(player, message);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
player.kick(Component.text("Error while processing packet " + channel + ": " + t.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void process(Player player, byte[] message) {
|
|
||||||
if (!this.plugin.canUseAxiom(player, "axiom.player.hotbar") || this.plugin.isMismatchedDataVersion(player.getUniqueId())) {
|
if (!this.plugin.canUseAxiom(player, "axiom.player.hotbar") || this.plugin.isMismatchedDataVersion(player.getUniqueId())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegistryFriendlyByteBuf friendlyByteBuf = new RegistryFriendlyByteBuf(Unpooled.wrappedBuffer(message), ((CraftPlayer)player).getHandle().registryAccess());
|
|
||||||
int index = friendlyByteBuf.readByte();
|
int index = friendlyByteBuf.readByte();
|
||||||
if (index < 0 || index >= 9*9) return;
|
if (index < 0 || index >= 9*9) return;
|
||||||
net.minecraft.world.item.ItemStack nmsStack = ItemStack.OPTIONAL_STREAM_CODEC.decode(friendlyByteBuf);
|
net.minecraft.world.item.ItemStack nmsStack = ItemStack.OPTIONAL_STREAM_CODEC.decode(friendlyByteBuf);
|
@ -1,8 +1,9 @@
|
|||||||
package com.moulberry.axiom.packet;
|
package com.moulberry.axiom.packet.impl;
|
||||||
|
|
||||||
import com.moulberry.axiom.AxiomPaper;
|
import com.moulberry.axiom.AxiomPaper;
|
||||||
import com.moulberry.axiom.event.AxiomTimeChangeEvent;
|
import com.moulberry.axiom.event.AxiomTimeChangeEvent;
|
||||||
import com.moulberry.axiom.integration.plotsquared.PlotSquaredIntegration;
|
import com.moulberry.axiom.integration.plotsquared.PlotSquaredIntegration;
|
||||||
|
import com.moulberry.axiom.packet.PacketHandler;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
@ -17,7 +18,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class SetTimePacketListener implements PluginMessageListener {
|
public class SetTimePacketListener implements PacketHandler {
|
||||||
|
|
||||||
private final AxiomPaper plugin;
|
private final AxiomPaper plugin;
|
||||||
public SetTimePacketListener(AxiomPaper plugin) {
|
public SetTimePacketListener(AxiomPaper plugin) {
|
||||||
@ -25,20 +26,11 @@ public class SetTimePacketListener implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) {
|
public void onReceive(Player player, FriendlyByteBuf friendlyByteBuf) {
|
||||||
try {
|
|
||||||
this.process(player, message);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
player.kick(Component.text("Error while processing packet " + channel + ": " + t.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void process(Player player, byte[] message) {
|
|
||||||
if (!this.plugin.canUseAxiom(player, "axiom.world.time")) {
|
if (!this.plugin.canUseAxiom(player, "axiom.world.time")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(message));
|
|
||||||
ResourceKey<Level> key = friendlyByteBuf.readResourceKey(Registries.DIMENSION);
|
ResourceKey<Level> key = friendlyByteBuf.readResourceKey(Registries.DIMENSION);
|
||||||
Integer time = friendlyByteBuf.readNullable(FriendlyByteBuf::readInt);
|
Integer time = friendlyByteBuf.readNullable(FriendlyByteBuf::readInt);
|
||||||
Boolean freezeTime = friendlyByteBuf.readNullable(FriendlyByteBuf::readBoolean);
|
Boolean freezeTime = friendlyByteBuf.readNullable(FriendlyByteBuf::readBoolean);
|
@ -1,7 +1,8 @@
|
|||||||
package com.moulberry.axiom.packet;
|
package com.moulberry.axiom.packet.impl;
|
||||||
|
|
||||||
import com.moulberry.axiom.AxiomPaper;
|
import com.moulberry.axiom.AxiomPaper;
|
||||||
import com.moulberry.axiom.integration.plotsquared.PlotSquaredIntegration;
|
import com.moulberry.axiom.integration.plotsquared.PlotSquaredIntegration;
|
||||||
|
import com.moulberry.axiom.packet.PacketHandler;
|
||||||
import com.moulberry.axiom.world_properties.server.ServerWorldPropertiesRegistry;
|
import com.moulberry.axiom.world_properties.server.ServerWorldPropertiesRegistry;
|
||||||
import com.moulberry.axiom.world_properties.server.ServerWorldPropertyHolder;
|
import com.moulberry.axiom.world_properties.server.ServerWorldPropertyHolder;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
@ -12,7 +13,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class SetWorldPropertyListener implements PluginMessageListener {
|
public class SetWorldPropertyListener implements PacketHandler {
|
||||||
|
|
||||||
private final AxiomPaper plugin;
|
private final AxiomPaper plugin;
|
||||||
public SetWorldPropertyListener(AxiomPaper plugin) {
|
public SetWorldPropertyListener(AxiomPaper plugin) {
|
||||||
@ -20,20 +21,11 @@ public class SetWorldPropertyListener implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) {
|
public void onReceive(Player player, FriendlyByteBuf friendlyByteBuf) {
|
||||||
try {
|
|
||||||
this.process(player, message);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
player.kick(Component.text("Error while processing packet " + channel + ": " + t.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void process(Player player, byte[] message) {
|
|
||||||
if (!this.plugin.canUseAxiom(player, "axiom.world.property")) {
|
if (!this.plugin.canUseAxiom(player, "axiom.world.property")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(message));
|
|
||||||
ResourceLocation id = friendlyByteBuf.readResourceLocation();
|
ResourceLocation id = friendlyByteBuf.readResourceLocation();
|
||||||
int type = friendlyByteBuf.readVarInt();
|
int type = friendlyByteBuf.readVarInt();
|
||||||
byte[] data = friendlyByteBuf.readByteArray();
|
byte[] data = friendlyByteBuf.readByteArray();
|
@ -1,11 +1,10 @@
|
|||||||
package com.moulberry.axiom.packet;
|
package com.moulberry.axiom.packet.impl;
|
||||||
|
|
||||||
import com.moulberry.axiom.AxiomPaper;
|
import com.moulberry.axiom.AxiomPaper;
|
||||||
import com.moulberry.axiom.NbtSanitization;
|
import com.moulberry.axiom.NbtSanitization;
|
||||||
import com.moulberry.axiom.integration.Integration;
|
import com.moulberry.axiom.integration.Integration;
|
||||||
import com.moulberry.axiom.integration.plotsquared.PlotSquaredIntegration;
|
import com.moulberry.axiom.packet.PacketHandler;
|
||||||
import com.moulberry.axiom.viaversion.UnknownVersionHelper;
|
import com.moulberry.axiom.viaversion.UnknownVersionHelper;
|
||||||
import com.moulberry.axiom.viaversion.ViaVersionHelper;
|
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
@ -32,7 +31,7 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
public class SpawnEntityPacketListener implements PluginMessageListener {
|
public class SpawnEntityPacketListener implements PacketHandler {
|
||||||
|
|
||||||
private final AxiomPaper plugin;
|
private final AxiomPaper plugin;
|
||||||
public SpawnEntityPacketListener(AxiomPaper plugin) {
|
public SpawnEntityPacketListener(AxiomPaper plugin) {
|
||||||
@ -46,15 +45,7 @@ public class SpawnEntityPacketListener implements PluginMessageListener {
|
|||||||
private static final Rotation[] ROTATION_VALUES = Rotation.values();
|
private static final Rotation[] ROTATION_VALUES = Rotation.values();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) {
|
public void onReceive(Player player, FriendlyByteBuf friendlyByteBuf) {
|
||||||
try {
|
|
||||||
this.process(player, message);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
player.kick(Component.text("Error while processing packet " + channel + ": " + t.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void process(Player player, byte[] message) {
|
|
||||||
if (!this.plugin.canUseAxiom(player, "axiom.entity.spawn", true)) {
|
if (!this.plugin.canUseAxiom(player, "axiom.entity.spawn", true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -63,7 +54,6 @@ public class SpawnEntityPacketListener implements PluginMessageListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(message));
|
|
||||||
List<SpawnEntry> entries = friendlyByteBuf.readCollection(FriendlyByteBuf.limitValue(ArrayList::new, 1000),
|
List<SpawnEntry> entries = friendlyByteBuf.readCollection(FriendlyByteBuf.limitValue(ArrayList::new, 1000),
|
||||||
buf -> new SpawnEntry(buf.readUUID(), buf.readDouble(), buf.readDouble(),
|
buf -> new SpawnEntry(buf.readUUID(), buf.readDouble(), buf.readDouble(),
|
||||||
buf.readDouble(), buf.readFloat(), buf.readFloat(),
|
buf.readDouble(), buf.readFloat(), buf.readFloat(),
|
@ -1,7 +1,8 @@
|
|||||||
package com.moulberry.axiom.packet;
|
package com.moulberry.axiom.packet.impl;
|
||||||
|
|
||||||
import com.moulberry.axiom.AxiomConstants;
|
import com.moulberry.axiom.AxiomConstants;
|
||||||
import com.moulberry.axiom.AxiomPaper;
|
import com.moulberry.axiom.AxiomPaper;
|
||||||
|
import com.moulberry.axiom.packet.PacketHandler;
|
||||||
import com.moulberry.axiom.persistence.ItemStackDataType;
|
import com.moulberry.axiom.persistence.ItemStackDataType;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -19,7 +20,7 @@ import org.bukkit.persistence.PersistentDataType;
|
|||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class SwitchActiveHotbarPacketListener implements PluginMessageListener {
|
public class SwitchActiveHotbarPacketListener implements PacketHandler {
|
||||||
|
|
||||||
private final AxiomPaper plugin;
|
private final AxiomPaper plugin;
|
||||||
public SwitchActiveHotbarPacketListener(AxiomPaper plugin) {
|
public SwitchActiveHotbarPacketListener(AxiomPaper plugin) {
|
||||||
@ -27,20 +28,11 @@ public class SwitchActiveHotbarPacketListener implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) {
|
public void onReceive(Player player, FriendlyByteBuf friendlyByteBuf) {
|
||||||
try {
|
|
||||||
this.process(player, message);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
player.kick(Component.text("Error while processing packet " + channel + ": " + t.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void process(Player player, byte[] message) {
|
|
||||||
if (!this.plugin.canUseAxiom(player, "axiom.player.hotbar") || this.plugin.isMismatchedDataVersion(player.getUniqueId())) {
|
if (!this.plugin.canUseAxiom(player, "axiom.player.hotbar") || this.plugin.isMismatchedDataVersion(player.getUniqueId())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegistryFriendlyByteBuf friendlyByteBuf = new RegistryFriendlyByteBuf(Unpooled.wrappedBuffer(message), ((CraftPlayer)player).getHandle().registryAccess());
|
|
||||||
int oldHotbarIndex = friendlyByteBuf.readByte();
|
int oldHotbarIndex = friendlyByteBuf.readByte();
|
||||||
int activeHotbarIndex = friendlyByteBuf.readByte();
|
int activeHotbarIndex = friendlyByteBuf.readByte();
|
||||||
|
|
@ -1,8 +1,9 @@
|
|||||||
package com.moulberry.axiom.packet;
|
package com.moulberry.axiom.packet.impl;
|
||||||
|
|
||||||
import com.moulberry.axiom.AxiomPaper;
|
import com.moulberry.axiom.AxiomPaper;
|
||||||
import com.moulberry.axiom.event.AxiomUnknownTeleportEvent;
|
import com.moulberry.axiom.event.AxiomUnknownTeleportEvent;
|
||||||
import com.moulberry.axiom.event.AxiomTeleportEvent;
|
import com.moulberry.axiom.event.AxiomTeleportEvent;
|
||||||
|
import com.moulberry.axiom.packet.PacketHandler;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
@ -16,7 +17,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class TeleportPacketListener implements PluginMessageListener {
|
public class TeleportPacketListener implements PacketHandler {
|
||||||
|
|
||||||
private final AxiomPaper plugin;
|
private final AxiomPaper plugin;
|
||||||
public TeleportPacketListener(AxiomPaper plugin) {
|
public TeleportPacketListener(AxiomPaper plugin) {
|
||||||
@ -24,20 +25,11 @@ public class TeleportPacketListener implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) {
|
public void onReceive(Player player, FriendlyByteBuf friendlyByteBuf) {
|
||||||
try {
|
|
||||||
this.process(player, message);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
player.kick(Component.text("Error while processing packet " + channel + ": " + t.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void process(Player player, byte[] message) {
|
|
||||||
if (!this.plugin.canUseAxiom(player, "axiom.world.teleport")) {
|
if (!this.plugin.canUseAxiom(player, "axiom.world.teleport")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(message));
|
|
||||||
ResourceKey<Level> resourceKey = friendlyByteBuf.readResourceKey(Registries.DIMENSION);
|
ResourceKey<Level> resourceKey = friendlyByteBuf.readResourceKey(Registries.DIMENSION);
|
||||||
double x = friendlyByteBuf.readDouble();
|
double x = friendlyByteBuf.readDouble();
|
||||||
double y = friendlyByteBuf.readDouble();
|
double y = friendlyByteBuf.readDouble();
|
@ -1,38 +1,36 @@
|
|||||||
package com.moulberry.axiom.packet;
|
package com.moulberry.axiom.packet.impl;
|
||||||
|
|
||||||
import com.moulberry.axiom.AxiomPaper;
|
import com.moulberry.axiom.AxiomPaper;
|
||||||
import com.moulberry.axiom.annotations.AnnotationUpdateAction;
|
import com.moulberry.axiom.annotations.AnnotationUpdateAction;
|
||||||
import com.moulberry.axiom.annotations.ServerAnnotations;
|
import com.moulberry.axiom.annotations.ServerAnnotations;
|
||||||
import com.moulberry.axiom.blueprint.BlueprintIo;
|
import com.moulberry.axiom.packet.PacketHandler;
|
||||||
import com.moulberry.axiom.blueprint.RawBlueprint;
|
|
||||||
import com.moulberry.axiom.blueprint.ServerBlueprintManager;
|
|
||||||
import com.moulberry.axiom.blueprint.ServerBlueprintRegistry;
|
|
||||||
import net.minecraft.SharedConstants;
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.BufferedOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class UpdateAnnotationPacketListener {
|
public class UpdateAnnotationPacketListener implements PacketHandler {
|
||||||
|
|
||||||
private final AxiomPaper plugin;
|
private final AxiomPaper plugin;
|
||||||
public UpdateAnnotationPacketListener(AxiomPaper plugin) {
|
public UpdateAnnotationPacketListener(AxiomPaper plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onReceive(ServerPlayer serverPlayer, FriendlyByteBuf friendlyByteBuf) {
|
public void onReceive(Player player, FriendlyByteBuf friendlyByteBuf) {
|
||||||
if (!this.plugin.allowAnnotations || !this.plugin.canUseAxiom(serverPlayer.getBukkitEntity(), "axiom.annotation.create")) {
|
if (!this.plugin.allowAnnotations || !this.plugin.canUseAxiom(player, "axiom.annotation.create")) {
|
||||||
friendlyByteBuf.writerIndex(friendlyByteBuf.readerIndex());
|
friendlyByteBuf.writerIndex(friendlyByteBuf.readerIndex());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.plugin.canModifyWorld(player, player.getWorld())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerPlayer serverPlayer = ((CraftPlayer)player).getHandle();
|
||||||
|
|
||||||
// Read actions
|
// Read actions
|
||||||
int length = friendlyByteBuf.readVarInt();
|
int length = friendlyByteBuf.readVarInt();
|
||||||
List<AnnotationUpdateAction> actions = new ArrayList<>(Math.min(256, length));
|
List<AnnotationUpdateAction> actions = new ArrayList<>(Math.min(256, length));
|
@ -1,14 +1,17 @@
|
|||||||
package com.moulberry.axiom.packet;
|
package com.moulberry.axiom.packet.impl;
|
||||||
|
|
||||||
import com.moulberry.axiom.AxiomPaper;
|
import com.moulberry.axiom.AxiomPaper;
|
||||||
import com.moulberry.axiom.blueprint.BlueprintIo;
|
import com.moulberry.axiom.blueprint.BlueprintIo;
|
||||||
import com.moulberry.axiom.blueprint.RawBlueprint;
|
import com.moulberry.axiom.blueprint.RawBlueprint;
|
||||||
import com.moulberry.axiom.blueprint.ServerBlueprintManager;
|
import com.moulberry.axiom.blueprint.ServerBlueprintManager;
|
||||||
import com.moulberry.axiom.blueprint.ServerBlueprintRegistry;
|
import com.moulberry.axiom.blueprint.ServerBlueprintRegistry;
|
||||||
|
import com.moulberry.axiom.packet.PacketHandler;
|
||||||
import net.minecraft.SharedConstants;
|
import net.minecraft.SharedConstants;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -16,19 +19,26 @@ import java.io.OutputStream;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
public class UploadBlueprintPacketListener {
|
public class UploadBlueprintPacketListener implements PacketHandler {
|
||||||
|
|
||||||
private final AxiomPaper plugin;
|
private final AxiomPaper plugin;
|
||||||
public UploadBlueprintPacketListener(AxiomPaper plugin) {
|
public UploadBlueprintPacketListener(AxiomPaper plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onReceive(ServerPlayer serverPlayer, FriendlyByteBuf friendlyByteBuf) {
|
@Override
|
||||||
if (!this.plugin.canUseAxiom(serverPlayer.getBukkitEntity(), "axiom.blueprint.upload")) {
|
public boolean handleAsync() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onReceive(Player player, FriendlyByteBuf friendlyByteBuf) {
|
||||||
|
if (!this.plugin.canUseAxiom(player, "axiom.blueprint.upload")) {
|
||||||
friendlyByteBuf.writerIndex(friendlyByteBuf.readerIndex());
|
friendlyByteBuf.writerIndex(friendlyByteBuf.readerIndex());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ServerPlayer serverPlayer = ((CraftPlayer)player).getHandle();
|
||||||
|
|
||||||
if (this.plugin.isMismatchedDataVersion(serverPlayer.getUUID())) {
|
if (this.plugin.isMismatchedDataVersion(serverPlayer.getUUID())) {
|
||||||
serverPlayer.sendSystemMessage(Component.literal("Axiom+ViaVersion: This feature isn't supported. Switch your client version to " + SharedConstants.VERSION_STRING + " to use this"));
|
serverPlayer.sendSystemMessage(Component.literal("Axiom+ViaVersion: This feature isn't supported. Switch your client version to " + SharedConstants.VERSION_STRING + " to use this"));
|
||||||
return;
|
return;
|
@ -17,6 +17,9 @@ blueprint-sharing: false
|
|||||||
# Allow large chunk data requests, not recommended for public servers
|
# Allow large chunk data requests, not recommended for public servers
|
||||||
allow-large-chunk-data-request: false
|
allow-large-chunk-data-request: false
|
||||||
|
|
||||||
|
# Raise the size limit for *all* packets to 2mb instead of 32kb. NOT RECOMMENDED FOR PUBLIC SERVERS
|
||||||
|
allow-large-payload-for-all-packets: 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' and 'warn'
|
# Valid actions are 'kick' and 'warn'
|
||||||
# 'warn' will give the player a warning and disable Axiom
|
# 'warn' will give the player a warning and disable Axiom
|
||||||
@ -97,4 +100,5 @@ packet-handlers:
|
|||||||
manipulate-entity: true
|
manipulate-entity: true
|
||||||
delete-entity: true
|
delete-entity: true
|
||||||
marker-nbt-request: true
|
marker-nbt-request: true
|
||||||
blueprint-request: true
|
upload-blueprint: true
|
||||||
|
annotation-update: true
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren