Paper/patches/api/0250-added-PlayerNameEntityEvent.patch

120 lines
3.2 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sun, 5 Jul 2020 00:34:24 -0700
Subject: [PATCH] added PlayerNameEntityEvent
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerNameEntityEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerNameEntityEvent.java
new file mode 100755
index 0000000000000000000000000000000000000000..fb990180d9958fe2bbe44e86aa360102f37be9ed
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/PlayerNameEntityEvent.java
@@ -0,0 +1,107 @@
2021-06-11 14:02:28 +02:00
+package io.papermc.paper.event.player;
+
+import net.kyori.adventure.text.Component;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent;
2024-02-01 10:15:57 +01:00
+import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
+import org.jspecify.annotations.Nullable;
2021-06-11 14:02:28 +02:00
+
+/**
+ * Called when the player is attempting to rename a mob
+ */
+@NullMarked
2021-06-11 14:02:28 +02:00
+public class PlayerNameEntityEvent extends PlayerEvent implements Cancellable {
+
2024-02-01 10:15:57 +01:00
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
2021-06-11 14:02:28 +02:00
+ private LivingEntity entity;
+ private @Nullable Component name;
2021-06-11 14:02:28 +02:00
+ private boolean persistent;
2024-02-01 10:15:57 +01:00
+
2021-06-11 14:02:28 +02:00
+ private boolean cancelled;
+
2024-02-01 10:15:57 +01:00
+ @ApiStatus.Internal
+ public PlayerNameEntityEvent(final Player player, final LivingEntity entity, final Component name, final boolean persistent) {
2021-06-11 14:02:28 +02:00
+ super(player);
+ this.entity = entity;
+ this.name = name;
+ this.persistent = persistent;
+ }
+
+ /**
+ * Gets the name to be given to the entity.
2024-02-01 10:15:57 +01:00
+ *
2021-06-11 14:02:28 +02:00
+ * @return the name
+ */
+ public @Nullable Component getName() {
2024-02-01 10:15:57 +01:00
+ return this.name;
2021-06-11 14:02:28 +02:00
+ }
+
+ /**
+ * Sets the name to be given to the entity.
+ *
+ * @param name the name
+ */
+ public void setName(final @Nullable Component name) {
2021-06-11 14:02:28 +02:00
+ this.name = name;
+ }
+
+ /**
+ * Gets the entity involved in this event.
+ *
+ * @return the entity
+ */
+ public LivingEntity getEntity() {
2024-02-01 10:15:57 +01:00
+ return this.entity;
2021-06-11 14:02:28 +02:00
+ }
+
+ /**
+ * Sets the entity involved in this event.
+ *
+ * @param entity the entity
+ */
+ public void setEntity(final LivingEntity entity) {
2021-06-11 14:02:28 +02:00
+ this.entity = entity;
+ }
+
+ /**
+ * Gets whether this will set the mob to be persistent.
+ *
+ * @return persistent
+ */
+ public boolean isPersistent() {
2024-02-01 10:15:57 +01:00
+ return this.persistent;
2021-06-11 14:02:28 +02:00
+ }
+
+ /**
+ * Sets whether this will set the mob to be persistent.
+ *
+ * @param persistent persistent
+ */
+ public void setPersistent(final boolean persistent) {
2021-06-11 14:02:28 +02:00
+ this.persistent = persistent;
+ }
+
+ @Override
+ public boolean isCancelled() {
2024-02-01 10:15:57 +01:00
+ return this.cancelled;
2021-06-11 14:02:28 +02:00
+ }
+
+ @Override
+ public void setCancelled(final boolean cancel) {
2021-06-11 14:02:28 +02:00
+ this.cancelled = cancel;
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
+}