mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 02:25:28 +01:00
120 lines
3.2 KiB
Diff
120 lines
3.2 KiB
Diff
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
|
|
--- /dev/null
|
|
+++ b/src/main/java/io/papermc/paper/event/player/PlayerNameEntityEvent.java
|
|
@@ -0,0 +1,107 @@
|
|
+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;
|
|
+import org.jetbrains.annotations.ApiStatus;
|
|
+import org.jspecify.annotations.NullMarked;
|
|
+import org.jspecify.annotations.Nullable;
|
|
+
|
|
+/**
|
|
+ * Called when the player is attempting to rename a mob
|
|
+ */
|
|
+@NullMarked
|
|
+public class PlayerNameEntityEvent extends PlayerEvent implements Cancellable {
|
|
+
|
|
+ private static final HandlerList HANDLER_LIST = new HandlerList();
|
|
+
|
|
+ private LivingEntity entity;
|
|
+ private @Nullable Component name;
|
|
+ private boolean persistent;
|
|
+
|
|
+ private boolean cancelled;
|
|
+
|
|
+ @ApiStatus.Internal
|
|
+ public PlayerNameEntityEvent(final Player player, final LivingEntity entity, final Component name, final boolean persistent) {
|
|
+ super(player);
|
|
+ this.entity = entity;
|
|
+ this.name = name;
|
|
+ this.persistent = persistent;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Gets the name to be given to the entity.
|
|
+ *
|
|
+ * @return the name
|
|
+ */
|
|
+ public @Nullable Component getName() {
|
|
+ return this.name;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Sets the name to be given to the entity.
|
|
+ *
|
|
+ * @param name the name
|
|
+ */
|
|
+ public void setName(final @Nullable Component name) {
|
|
+ this.name = name;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Gets the entity involved in this event.
|
|
+ *
|
|
+ * @return the entity
|
|
+ */
|
|
+ public LivingEntity getEntity() {
|
|
+ return this.entity;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Sets the entity involved in this event.
|
|
+ *
|
|
+ * @param entity the entity
|
|
+ */
|
|
+ public void setEntity(final LivingEntity entity) {
|
|
+ this.entity = entity;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Gets whether this will set the mob to be persistent.
|
|
+ *
|
|
+ * @return persistent
|
|
+ */
|
|
+ public boolean isPersistent() {
|
|
+ return this.persistent;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Sets whether this will set the mob to be persistent.
|
|
+ *
|
|
+ * @param persistent persistent
|
|
+ */
|
|
+ public void setPersistent(final boolean persistent) {
|
|
+ this.persistent = persistent;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isCancelled() {
|
|
+ return this.cancelled;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setCancelled(final boolean cancel) {
|
|
+ this.cancelled = cancel;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public HandlerList getHandlers() {
|
|
+ return HANDLER_LIST;
|
|
+ }
|
|
+
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return HANDLER_LIST;
|
|
+ }
|
|
+}
|