2021-06-11 14:02:28 +02:00
|
|
|
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
|
2024-06-13 16:45:27 +02:00
|
|
|
index fa4de12ba4fdce7a632923af8007e888141904c8..7c32802947fd5318009a02724c85206b250e7143 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
2024-06-13 16:45:27 +02:00
|
|
|
@@ -539,4 +539,44 @@ public final class CraftItemFactory implements ItemFactory {
|
2022-01-17 01:53:26 +01:00
|
|
|
return nms != null ? net.minecraft.locale.Language.getInstance().getOrDefault(nms.getItem().getDescriptionId(nms)) : null;
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
2023-08-06 02:21:59 +02:00
|
|
|
// Paper end - add getI18NDisplayName
|
2021-06-11 14:02:28 +02:00
|
|
|
+
|
2023-08-06 02:21:59 +02:00
|
|
|
+ // Paper start - bungee hover events
|
2021-06-11 14:02:28 +02:00
|
|
|
+ @Override
|
|
|
|
+ public net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(ItemStack itemStack) {
|
2024-04-25 05:40:32 +02:00
|
|
|
+ throw new UnsupportedOperationException("BungeeCord Chat API does not support data components");
|
|
|
|
+ /*
|
2021-06-11 14:02:28 +02:00
|
|
|
+ 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);
|
2024-04-25 05:40:32 +02:00
|
|
|
+ */
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @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));
|
|
|
|
+ }
|
2023-08-06 02:21:59 +02:00
|
|
|
+ // Paper end - bungee hover events
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|