Fix being kicked in survival for block picking - Fixes #3277

This commit is contained in:
Aikar 2020-05-02 13:32:03 -04:00
parent 4d20537e6e
commit a9e20e5f62
No known key found for this signature in database
GPG Key ID: 401ADFC9891FAAFE
3 changed files with 13 additions and 11 deletions

View File

@ -1,11 +1,11 @@
From 12be987716c0516e0300b7e3b79bfa064747d46c Mon Sep 17 00:00:00 2001 From d06bf34ea56dcddd270b687ffadcf28b0011f514 Mon Sep 17 00:00:00 2001
From: Mark Vainomaa <mikroskeem@mikroskeem.eu> From: Mark Vainomaa <mikroskeem@mikroskeem.eu>
Date: Fri, 1 May 2020 17:39:02 +0300 Date: Fri, 1 May 2020 17:39:02 +0300
Subject: [PATCH] Expose game version Subject: [PATCH] Expose game version
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index b9973406..d4af3a1d 100644 index ea3e5d6fa..95ad01226 100644
--- a/src/main/java/org/bukkit/Bukkit.java --- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java
@@ -118,6 +118,18 @@ public final class Bukkit { @@ -118,6 +118,18 @@ public final class Bukkit {
@ -28,7 +28,7 @@ index b9973406..d4af3a1d 100644
* Gets a view of all currently logged in players. This {@linkplain * Gets a view of all currently logged in players. This {@linkplain
* Collections#unmodifiableCollection(Collection) view} is a reused * Collections#unmodifiableCollection(Collection) view} is a reused
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 80f9abdc..08817f02 100644 index 9ceaac0e8..c3fb1c271 100644
--- a/src/main/java/org/bukkit/Server.java --- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java
@@ -97,6 +97,16 @@ public interface Server extends PluginMessageRecipient { @@ -97,6 +97,16 @@ public interface Server extends PluginMessageRecipient {
@ -49,4 +49,5 @@ index 80f9abdc..08817f02 100644
* Gets a view of all currently logged in players. This {@linkplain * Gets a view of all currently logged in players. This {@linkplain
* Collections#unmodifiableCollection(Collection) view} is a reused * Collections#unmodifiableCollection(Collection) view} is a reused
-- --
2.25.1 2.26.2

View File

@ -1,11 +1,11 @@
From 35b2b6df0265e4e0743a0456cfa2c3ec73bbe7da Mon Sep 17 00:00:00 2001 From 954203816cd42cff061c4a633ad346bd3dab5073 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Sat, 2 May 2020 03:09:46 -0400 Date: Sat, 2 May 2020 03:09:46 -0400
Subject: [PATCH] Validate PickItem Packet and kick for invalid Subject: [PATCH] Validate PickItem Packet and kick for invalid
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 38ec22f4c0..60c3af4d64 100644 index 38ec22f4c0..2d83db9b22 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java --- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -683,7 +683,14 @@ public class PlayerConnection implements PacketListenerPlayIn { @@ -683,7 +683,14 @@ public class PlayerConnection implements PacketListenerPlayIn {
@ -14,7 +14,7 @@ index 38ec22f4c0..60c3af4d64 100644
PlayerConnectionUtils.ensureMainThread(packetplayinpickitem, this, this.player.getWorldServer()); PlayerConnectionUtils.ensureMainThread(packetplayinpickitem, this, this.player.getWorldServer());
- this.player.inventory.c(packetplayinpickitem.b()); - this.player.inventory.c(packetplayinpickitem.b());
+ // Paper start - validate pick item position + // Paper start - validate pick item position
+ if (!(packetplayinpickitem.b() >= 0 && packetplayinpickitem.b() < PlayerInventory.getHotbarSize())) { + if (!(packetplayinpickitem.b() >= 0 && packetplayinpickitem.b() < this.player.inventory.items.size())) {
+ PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getDisplayName().getString()); + PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getDisplayName().getString());
+ this.disconnect("Invalid hotbar selection (Hacking?)"); + this.disconnect("Invalid hotbar selection (Hacking?)");
+ return; + return;

View File

@ -1,14 +1,14 @@
From af32f51b7d7f78c747834086cecc8e87c6180a97 Mon Sep 17 00:00:00 2001 From fb892b50f8ea61b6b898cc2d86769fe3bbfa2fb8 Mon Sep 17 00:00:00 2001
From: Mark Vainomaa <mikroskeem@mikroskeem.eu> From: Mark Vainomaa <mikroskeem@mikroskeem.eu>
Date: Fri, 1 May 2020 17:39:26 +0300 Date: Fri, 1 May 2020 17:39:26 +0300
Subject: [PATCH] Expose game version Subject: [PATCH] Expose game version
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index b9a398bc5..5bd6f2a88 100644 index f49193d9d7..1647c09756 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -488,6 +488,13 @@ public final class CraftServer implements Server { @@ -489,6 +489,13 @@ public final class CraftServer implements Server {
return bukkitVersion; return bukkitVersion;
} }
@ -23,4 +23,5 @@ index b9a398bc5..5bd6f2a88 100644
public List<CraftPlayer> getOnlinePlayers() { public List<CraftPlayer> getOnlinePlayers() {
return this.playerView; return this.playerView;
-- --
2.25.1 2.26.2