Paper/patches/api/0049-IllegalPacketEvent.patch

83 lines
2.4 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
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
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/IllegalPacketEvent.java
2024-02-01 10:15:57 +01:00
@@ -0,0 +1,67 @@
2021-06-11 14:02:28 +02:00
+package com.destroystokyo.paper.event.player;
+
+import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent;
2024-02-01 10:15:57 +01:00
+import org.jetbrains.annotations.ApiStatus;
2021-06-11 14:02:28 +02:00
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @deprecated Not used
+ */
+@Deprecated(since = "1.16.4")
2021-06-11 14:02:28 +02:00
+public class IllegalPacketEvent extends PlayerEvent {
2024-02-01 10:15:57 +01:00
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
2021-06-11 14:02:28 +02:00
+ @Nullable private final String type;
2024-02-01 10:15:57 +01:00
+ @Nullable private final String exceptionMessage;
2021-06-11 14:02:28 +02:00
+ @Nullable private String kickMessage;
+ private boolean shouldKick = true;
+
2024-02-01 10:15:57 +01:00
+ @ApiStatus.Internal
2021-06-11 14:02:28 +02:00
+ public IllegalPacketEvent(@NotNull Player player, @Nullable String type, @Nullable String kickMessage, @NotNull Exception e) {
+ super(player);
+ this.type = type;
+ this.kickMessage = kickMessage;
2024-02-01 10:15:57 +01:00
+ this.exceptionMessage = e.getMessage();
2021-06-11 14:02:28 +02:00
+ }
+
+ public boolean isShouldKick() {
2024-02-01 10:15:57 +01:00
+ return this.shouldKick;
2021-06-11 14:02:28 +02:00
+ }
+
+ public void setShouldKick(boolean shouldKick) {
+ this.shouldKick = shouldKick;
+ }
+
+ @Nullable
+ public String getKickMessage() {
2024-02-01 10:15:57 +01:00
+ return this.kickMessage;
2021-06-11 14:02:28 +02:00
+ }
+
+ public void setKickMessage(@Nullable String kickMessage) {
+ this.kickMessage = kickMessage;
+ }
+
+ @Nullable
+ public String getType() {
2024-02-01 10:15:57 +01:00
+ return this.type;
2021-06-11 14:02:28 +02:00
+ }
+
+ @Nullable
+ public String getExceptionMessage() {
2024-02-01 10:15:57 +01:00
+ return this.exceptionMessage;
2021-06-11 14:02:28 +02:00
+ }
+
+ @NotNull
+ public HandlerList getHandlers() {
2024-02-01 10:15:57 +01:00
+ return HANDLER_LIST;
2021-06-11 14:02:28 +02:00
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
2024-02-01 10:15:57 +01:00
+ return HANDLER_LIST;
2021-06-11 14:02:28 +02:00
+ }
+}