Paper/patches/server/0520-Create-HoverEvent-from-ItemStack-Entity.patch
Finn Künstner a284e40c70
Updated Upstream (Bukkit/CraftBukkit) (#6848)
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:
9b45fa2f #667: Allow setting BrewEvent results
8c776ddc SPIGOT-6762: ChatPaginator.wordWrap only transfers one modifier
da372966 SPIGOT-4590, SPIGOT-6769: Clarify DamageCause documentation

CraftBukkit Changes:
cef1fda3 #947: Add missing spawn eggs for SpawnEggMeta
eb9a0f34 #945: Allow setting BrewEvent results
2021-10-31 08:34:10 +01:00

52 lines
2.7 KiB
Diff

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 c50d3cee3dfebb62ad30f8d4efe23b5c7c9f2b57..fcbd28fdeab4815c005c7dca547aee246f52fd26 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
@@ -375,5 +375,40 @@ public final class CraftItemFactory implements ItemFactory {
return nms != null ? net.minecraft.locale.Language.getInstance().getOrDefault(nms.getItem().getDescriptionId()) : 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
}