mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-19 00:55:42 +01:00
4e958e229f
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: zml <zml@stellardrift.ca> Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com>
52 lines
2.7 KiB
Diff
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 bf8a8cad248583c900eacfaf54e30f0a60e1dc54..c79623339cfe8fb8484bcc2a8c3eb119b9e83093 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
|
@@ -360,5 +360,40 @@ 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
|
|
}
|