aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0047-IllegalPacketEvent.patch
blob: 44c4a83198175322922584a27509aa7212b33dc4 (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
72
73
74
75
76
77
78
79
80
81
82
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 4 Dec 2016 01:19:14 -0500
Subject: [PATCH] IllegalPacketEvent

Fire an event when an illegal packet is received to let plugins handle it

Lets plugins change the kick message and if it should kick or not.

diff --git a/src/main/java/com/destroystokyo/paper/event/player/IllegalPacketEvent.java b/src/main/java/com/destroystokyo/paper/event/player/IllegalPacketEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..44637928268c3efa951c340855f7caa63519a115
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/IllegalPacketEvent.java
@@ -0,0 +1,67 @@
+package com.destroystokyo.paper.event.player;
+
+import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @deprecated Not used
+ */
+@Deprecated(since = "1.16.4")
+public class IllegalPacketEvent extends PlayerEvent {
+
+    private static final HandlerList HANDLER_LIST = new HandlerList();
+
+    @Nullable private final String type;
+    @Nullable private final String exceptionMessage;
+    @Nullable private String kickMessage;
+    private boolean shouldKick = true;
+
+    @ApiStatus.Internal
+    public IllegalPacketEvent(@NotNull Player player, @Nullable String type, @Nullable String kickMessage, @NotNull Exception e) {
+        super(player);
+        this.type = type;
+        this.kickMessage = kickMessage;
+        this.exceptionMessage = e.getMessage();
+    }
+
+    public boolean isShouldKick() {
+        return this.shouldKick;
+    }
+
+    public void setShouldKick(boolean shouldKick) {
+        this.shouldKick = shouldKick;
+    }
+
+    @Nullable
+    public String getKickMessage() {
+        return this.kickMessage;
+    }
+
+    public void setKickMessage(@Nullable String kickMessage) {
+        this.kickMessage = kickMessage;
+    }
+
+    @Nullable
+    public String getType() {
+        return this.type;
+    }
+
+    @Nullable
+    public String getExceptionMessage() {
+        return this.exceptionMessage;
+    }
+
+    @NotNull
+    public HandlerList getHandlers() {
+        return HANDLER_LIST;
+    }
+
+    @NotNull
+    public static HandlerList getHandlerList() {
+        return HANDLER_LIST;
+    }
+}