mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 15:00:13 +01:00
Create HoverEvent from ItemStack Entity
add myself to MIT list Co-authored-by: Mariell <proximyst@proximyst.com> Co-authored-by: MiniDigger | Martin <admin@minidigger.dev>
This commit is contained in:
parent
21b927ed55
commit
8684dcd76e
3 changed files with 117 additions and 0 deletions
|
@ -42,4 +42,5 @@ rickyboy320 <rickw320@hotmail.com>
|
||||||
DoNotSpamPls <7570108+DoNotSpamPls@users.noreply.github.com>
|
DoNotSpamPls <7570108+DoNotSpamPls@users.noreply.github.com>
|
||||||
Josh Roy <10731363+JRoy@users.noreply.github.com>
|
Josh Roy <10731363+JRoy@users.noreply.github.com>
|
||||||
Robert Norman <spottedleaf@spottedleaf.dev>, <Spottedleaf@users.noreply.github.com>
|
Robert Norman <spottedleaf@spottedleaf.dev>, <Spottedleaf@users.noreply.github.com>
|
||||||
|
ysl3000 <yannicklamprecht@live.de>
|
||||||
```
|
```
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: ysl3000 <yannicklamprecht@live.de>
|
||||||
|
Date: Mon, 6 Jul 2020 22:17:37 +0200
|
||||||
|
Subject: [PATCH] Create HoverEvent from ItemStack Entity
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/inventory/ItemFactory.java b/src/main/java/org/bukkit/inventory/ItemFactory.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/inventory/ItemFactory.java
|
||||||
|
+++ b/src/main/java/org/bukkit/inventory/ItemFactory.java
|
||||||
|
@@ -0,0 +0,0 @@ public interface ItemFactory {
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
String getI18NDisplayName(@Nullable ItemStack item);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Creates a {@link net.md_5.bungee.api.chat.hover.content.Content} of that ItemStack for displaying.
|
||||||
|
+ *
|
||||||
|
+ * @param itemStack
|
||||||
|
+ * @return the {@link net.md_5.bungee.api.chat.hover.content.Content} of that ItemStack
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(@NotNull ItemStack itemStack);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Creates a {@link net.md_5.bungee.api.chat.hover.content.Content} of that {@link org.bukkit.entity.Entity} for displaying.
|
||||||
|
+ * Uses the display name of the entity, if present.
|
||||||
|
+ *
|
||||||
|
+ * @param entity Entity to create the HoverEvent for
|
||||||
|
+ * @return the {@link net.md_5.bungee.api.chat.hover.content.Content} of that {@link org.bukkit.entity.Entity}
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(@NotNull org.bukkit.entity.Entity entity);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Creates a {@link net.md_5.bungee.api.chat.hover.content.Content} of that {@link org.bukkit.entity.Entity} for displaying.
|
||||||
|
+ *
|
||||||
|
+ * @param entity Entity to create the HoverEvent for
|
||||||
|
+ * @param customName a custom name that should be displayed, if not passed entity name will be displayed
|
||||||
|
+ * @return the {@link net.md_5.bungee.api.chat.hover.content.Content} of that {@link org.bukkit.entity.Entity}
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(@NotNull org.bukkit.entity.Entity entity, @Nullable String customName);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Creates a {@link net.md_5.bungee.api.chat.hover.content.Content} of that {@link org.bukkit.entity.Entity} for displaying.
|
||||||
|
+ *
|
||||||
|
+ * @param entity Entity to create the HoverEvent for
|
||||||
|
+ * @param customName a custom name that should be displayed, if not passed entity name will be displayed
|
||||||
|
+ * @return the {@link net.md_5.bungee.api.chat.hover.content.Content} of that {@link org.bukkit.entity.Entity}
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(@NotNull org.bukkit.entity.Entity entity, @Nullable net.md_5.bungee.api.chat.BaseComponent customName);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Creates a {@link net.md_5.bungee.api.chat.hover.content.Content} of that {@link org.bukkit.entity.Entity} for displaying.
|
||||||
|
+ *
|
||||||
|
+ * @param entity Entity to create the HoverEvent for
|
||||||
|
+ * @param customName a custom name that should be displayed, if not passed entity name will be displayed
|
||||||
|
+ * @return the {@link net.md_5.bungee.api.chat.hover.content.Content} of that {@link org.bukkit.entity.Entity}
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(@NotNull org.bukkit.entity.Entity entity, @NotNull net.md_5.bungee.api.chat.BaseComponent[] customName);
|
||||||
|
// Paper end
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: ysl3000 <yannicklamprecht@live.de>
|
||||||
|
Date: Mon, 6 Jul 2020 22:18:04 +0200
|
||||||
|
Subject: [PATCH] Create HoverEvent from ItemStack Entity
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
||||||
|
@@ -0,0 +0,0 @@ public final class CraftItemFactory implements ItemFactory {
|
||||||
|
|
||||||
|
return nms != null ? net.minecraft.server.LocaleLanguage.getInstance().translateKey(nms.getItem().getName()) : null;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(ItemStack itemStack) {
|
||||||
|
+ net.md_5.bungee.api.chat.ItemTag itemTag = net.md_5.bungee.api.chat.ItemTag.ofNbt(CraftItemStack.asNMSCopy(itemStack).getOrCreateTag().toString());
|
||||||
|
+ return new net.md_5.bungee.api.chat.hover.content.Item(
|
||||||
|
+ itemStack.getType().getKey().toString(),
|
||||||
|
+ itemStack.getAmount(),
|
||||||
|
+ itemTag);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(org.bukkit.entity.Entity entity) {
|
||||||
|
+ return hoverContentOf(entity, org.apache.commons.lang3.StringUtils.isBlank(entity.getCustomName()) ? null : new net.md_5.bungee.api.chat.TextComponent(entity.getCustomName()));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(org.bukkit.entity.Entity entity, String customName) {
|
||||||
|
+ return hoverContentOf(entity, org.apache.commons.lang3.StringUtils.isBlank(customName) ? null : new net.md_5.bungee.api.chat.TextComponent(customName));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(org.bukkit.entity.Entity entity, net.md_5.bungee.api.chat.BaseComponent customName) {
|
||||||
|
+ return new net.md_5.bungee.api.chat.hover.content.Entity(
|
||||||
|
+ entity.getType().getKey().toString(),
|
||||||
|
+ entity.getUniqueId().toString(),
|
||||||
|
+ customName);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(org.bukkit.entity.Entity entity, net.md_5.bungee.api.chat.BaseComponent[] customName) {
|
||||||
|
+ return new net.md_5.bungee.api.chat.hover.content.Entity(
|
||||||
|
+ entity.getType().getKey().toString(),
|
||||||
|
+ entity.getUniqueId().toString(),
|
||||||
|
+ new net.md_5.bungee.api.chat.TextComponent(customName));
|
||||||
|
+ }
|
||||||
|
// Paper end
|
||||||
|
}
|
Loading…
Reference in a new issue