mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
Make interaction leniency distance configurable
The server validates incoming interaction packets by ensuring the player sending them is inside their interaction range. For this, the server adds a magic value, by default 1.0, to the original interaction range to account for latency issues. This value however may be too low in high latency environments. The patch exposes a new configuration option to configure said value.
This commit is contained in:
parent
91b690c240
commit
15c4f72cf0
1 changed files with 17 additions and 15 deletions
|
@ -1558,12 +1558,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
return optional;
|
return optional;
|
||||||
@@ -1564,8 +2394,119 @@
|
@@ -1566,6 +2396,117 @@
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
+ }
|
}
|
||||||
+
|
|
||||||
+ // CraftBukkit start - add method
|
+ // CraftBukkit start - add method
|
||||||
+ public void chat(String s, PlayerChatMessage original, boolean async) {
|
+ public void chat(String s, PlayerChatMessage original, boolean async) {
|
||||||
+ if (s.isEmpty() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) {
|
+ if (s.isEmpty() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) {
|
||||||
|
@ -1656,8 +1654,8 @@
|
||||||
+ this.server.console.sendMessage(s);
|
+ this.server.console.sendMessage(s);
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
}
|
+ }
|
||||||
|
+
|
||||||
+ @Deprecated // Paper
|
+ @Deprecated // Paper
|
||||||
+ public void handleCommand(String s) { // Paper - private -> public
|
+ public void handleCommand(String s) { // Paper - private -> public
|
||||||
+ // Paper start - Remove all this old duplicated logic
|
+ // Paper start - Remove all this old duplicated logic
|
||||||
|
@ -1842,10 +1840,12 @@
|
||||||
this.send(new ClientboundPlayerChatPacket(message.link().sender(), message.link().index(), message.signature(), message.signedBody().pack(this.messageSignatureCache), message.unsignedContent(), message.filterMask(), params));
|
this.send(new ClientboundPlayerChatPacket(message.link().sender(), message.link().index(), message.signature(), message.signedBody().pack(this.messageSignatureCache), message.unsignedContent(), message.filterMask(), params));
|
||||||
this.addPendingMessage(message);
|
this.addPendingMessage(message);
|
||||||
}
|
}
|
||||||
@@ -1703,6 +2740,18 @@
|
@@ -1701,7 +2738,19 @@
|
||||||
return this.connection.getRemoteAddress();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public SocketAddress getRemoteAddress() {
|
||||||
|
return this.connection.getRemoteAddress();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ // Spigot Start
|
+ // Spigot Start
|
||||||
+ public SocketAddress getRawAddress()
|
+ public SocketAddress getRawAddress()
|
||||||
+ {
|
+ {
|
||||||
|
@ -1855,12 +1855,11 @@
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - Unix domain socket support
|
+ // Paper end - Unix domain socket support
|
||||||
+ return this.connection.channel.remoteAddress();
|
+ return this.connection.channel.remoteAddress();
|
||||||
+ }
|
}
|
||||||
+ // Spigot End
|
+ // Spigot End
|
||||||
+
|
|
||||||
public void switchToConfig() {
|
public void switchToConfig() {
|
||||||
this.waitingForSwitchToConfig = true;
|
this.waitingForSwitchToConfig = true;
|
||||||
this.removePlayerFromWorld();
|
|
||||||
@@ -1718,9 +2767,17 @@
|
@@ -1718,9 +2767,17 @@
|
||||||
@Override
|
@Override
|
||||||
public void handleInteract(ServerboundInteractPacket packet) {
|
public void handleInteract(ServerboundInteractPacket packet) {
|
||||||
|
@ -1879,9 +1878,12 @@
|
||||||
|
|
||||||
this.player.resetLastActionTime();
|
this.player.resetLastActionTime();
|
||||||
this.player.setShiftKeyDown(packet.isUsingSecondaryAction());
|
this.player.setShiftKeyDown(packet.isUsingSecondaryAction());
|
||||||
@@ -1733,20 +2790,59 @@
|
@@ -1731,22 +2788,61 @@
|
||||||
|
|
||||||
if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) {
|
AABB axisalignedbb = entity.getBoundingBox();
|
||||||
|
|
||||||
|
- if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) {
|
||||||
|
+ if (this.player.canInteractWithEntity(axisalignedbb, io.papermc.paper.configuration.GlobalConfiguration.get().misc.clientInteractionLeniencyDistance.or(3.0D))) { // Paper - configurable lenience value for interact range
|
||||||
packet.dispatch(new ServerboundInteractPacket.Handler() {
|
packet.dispatch(new ServerboundInteractPacket.Handler() {
|
||||||
- private void performInteraction(InteractionHand hand, ServerGamePacketListenerImpl.EntityInteraction action) {
|
- private void performInteraction(InteractionHand hand, ServerGamePacketListenerImpl.EntityInteraction action) {
|
||||||
- ItemStack itemstack = ServerGamePacketListenerImpl.this.player.getItemInHand(hand);
|
- ItemStack itemstack = ServerGamePacketListenerImpl.this.player.getItemInHand(hand);
|
||||||
|
|
Loading…
Reference in a new issue