aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0186-IllegalPacketEvent.patch
blob: 5c439cf9059881ba9268d2e3ac484d456f7f5c72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
From d9570be2a290ff85ba97c0239f95fdaccc56d587 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 23 Jun 2016 23:33:57 -0400
Subject: [PATCH] IllegalPacketEvent

Fired for invalid data from players that represents hacking attempts

diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 51d27351d..437575003 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -56,6 +56,7 @@ import org.bukkit.inventory.CraftingInventory;
 import org.bukkit.inventory.EquipmentSlot;
 import org.bukkit.inventory.InventoryView;
 import org.bukkit.util.NumberConversions;
+import com.destroystokyo.paper.event.player.IllegalPacketEvent; // Paper
 import co.aikar.timings.MinecraftTimings; // Paper
 // CraftBukkit end
 
@@ -2236,8 +2237,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
                     CraftEventFactory.handleEditBookEvent(player, itemstack1); // CraftBukkit
                 }
             } catch (Exception exception) {
-                PlayerConnection.LOGGER.error("Couldn\'t handle book info", exception);
-                this.disconnect("Invalid book data!"); // CraftBukkit
+                IllegalPacketEvent.process(player.getBukkitEntity(), "InvalidBookEdit", "Invalid book data!", exception); // Paper
             }
         } else {
             String s1;
@@ -2286,8 +2286,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
                         CraftEventFactory.handleEditBookEvent(player, itemstack2); // CraftBukkit
                     }
                 } catch (Exception exception1) {
-                    PlayerConnection.LOGGER.error("Couldn\'t sign book", exception1);
-                    this.disconnect("Invalid book data!"); // CraftBukkit
+                    IllegalPacketEvent.process(player.getBukkitEntity(), "InvalidBookSign", "Invalid book data!", exception1); // Paper
                 }
             } else if ("MC|TrSel".equals(s)) {
                 try {
@@ -2298,8 +2297,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
                         ((ContainerMerchant) container).d(j);
                     }
                 } catch (Exception exception2) {
-                    PlayerConnection.LOGGER.error("Couldn\'t select trade", exception2);
-                    this.disconnect("Invalid trade data!"); // CraftBukkit
+                    IllegalPacketEvent.process(player.getBukkitEntity(), "InvalidTrade", "Invalid trade data!", exception2); // Paper
                 }
             } else {
                 TileEntity tileentity;
@@ -2440,8 +2438,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
                                     iinventory.update();
                                 }
                             } catch (Exception exception5) {
-                                PlayerConnection.LOGGER.error("Couldn\'t set beacon", exception5);
-                                this.disconnect("Invalid beacon data!"); // CraftBukkit
+                                IllegalPacketEvent.process(player.getBukkitEntity(), "InvalidBeacon", "Invalid beacon data!", exception5); // Paper
                             }
                         }
                     } else if ("MC|ItemName".equals(s)) {
@@ -2540,7 +2537,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
                             this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(-2, k, this.player.inventory.getItem(k)));
                             this.player.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex));
                         } catch (Exception exception7) {
-                            PlayerConnection.LOGGER.error("Couldn\'t pick item", exception7);
+                            IllegalPacketEvent.process(player.getBukkitEntity(), "InvalidPickItem", "Invalid PickItem", exception7); // Paper
                         }
                     }
                     // CraftBukkit start
-- 
2.12.2