Paper/patches/api/0291-Add-PlayerKickEvent-causes.patch
Nassim Jahnke 71c84c8132
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD

CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor

Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00

143 lines
4.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sat, 15 May 2021 20:30:34 -0700
Subject: [PATCH] Add PlayerKickEvent causes
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index 59821aba66edbef2644bdd21646f556e773a898b..793df7533096efb0f60bddcb3e4e1575cbcc1069 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -277,6 +277,14 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* @param message kick message
*/
void kick(final net.kyori.adventure.text.@Nullable Component message);
+
+ /**
+ * Kicks player with custom kick message and cause.
+ *
+ * @param message kick message
+ * @param cause kick cause
+ */
+ void kick(final net.kyori.adventure.text.@Nullable Component message, org.bukkit.event.player.PlayerKickEvent.@NotNull Cause cause);
// Paper end
/**
diff --git a/src/main/java/org/bukkit/event/player/PlayerKickEvent.java b/src/main/java/org/bukkit/event/player/PlayerKickEvent.java
index 997b06c19a5277656521e0e298f2958c209f1da1..f7f864a2b46129e4d61bc87f3e23c343417aa094 100644
--- a/src/main/java/org/bukkit/event/player/PlayerKickEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerKickEvent.java
@@ -12,6 +12,7 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private net.kyori.adventure.text.Component leaveMessage; // Paper
private net.kyori.adventure.text.Component kickReason; // Paper
+ private final Cause cause; // Paper
private boolean cancel;
@Deprecated // Paper
@@ -19,14 +20,26 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable {
super(playerKicked);
this.kickReason = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(kickReason); // Paper
this.leaveMessage = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(leaveMessage); // Paper
+ this.cause = Cause.UNKNOWN; // Paper
this.cancel = false;
}
// Paper start
+ @Deprecated
public PlayerKickEvent(@NotNull final Player playerKicked, @NotNull final net.kyori.adventure.text.Component kickReason, @NotNull final net.kyori.adventure.text.Component leaveMessage) {
super(playerKicked);
this.kickReason = kickReason;
this.leaveMessage = leaveMessage;
this.cancel = false;
+ this.cause = Cause.UNKNOWN;
+ }
+
+ @org.jetbrains.annotations.ApiStatus.Internal
+ public PlayerKickEvent(@NotNull final Player playerKicked, @NotNull final net.kyori.adventure.text.Component kickReason, @NotNull final net.kyori.adventure.text.Component leaveMessage, @NotNull final Cause cause) {
+ super(playerKicked);
+ this.kickReason = kickReason;
+ this.leaveMessage = leaveMessage;
+ this.cancel = false;
+ this.cause = cause;
}
/**
@@ -132,4 +145,77 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable {
public static HandlerList getHandlerList() {
return handlers;
}
+ // Paper start
+ /**
+ * Gets the cause of this kick
+ *
+ * @return
+ */
+ @NotNull
+ public org.bukkit.event.player.PlayerKickEvent.Cause getCause() {
+ return cause;
+ }
+
+ public enum Cause {
+
+ PLUGIN,
+
+ WHITELIST,
+
+ BANNED,
+
+ IP_BANNED,
+
+ KICK_COMMAND,
+
+ FLYING_PLAYER,
+
+ FLYING_VEHICLE,
+
+ TIMEOUT,
+
+ IDLING,
+
+ INVALID_VEHICLE_MOVEMENT,
+
+ INVALID_PLAYER_MOVEMENT,
+
+ INVALID_ENTITY_ATTACKED,
+
+ INVALID_PAYLOAD,
+
+ SPAM,
+
+ ILLEGAL_ACTION,
+
+ ILLEGAL_CHARACTERS,
+
+ OUT_OF_ORDER_CHAT,
+
+ UNSIGNED_CHAT,
+
+ CHAT_VALIDATION_FAILED,
+
+ EXPIRED_PROFILE_PUBLIC_KEY,
+
+ INVALID_PUBLIC_KEY_SIGNATURE,
+
+ TOO_MANY_PENDING_CHATS,
+
+ SELF_INTERACTION,
+
+ DUPLICATE_LOGIN,
+
+ RESOURCE_PACK_REJECTION,
+
+ /**
+ * Spigot's restart command
+ */
+ RESTART_COMMAND,
+ /**
+ * Fallback cause
+ */
+ UNKNOWN,
+ }
+ // Paper end
}