diff --git a/LICENSE.md b/LICENSE.md index 2f63bde760..88621689a7 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -42,4 +42,5 @@ rickyboy320 DoNotSpamPls <7570108+DoNotSpamPls@users.noreply.github.com> JRoy Robert Norman , +ysl3000 ``` diff --git a/Spigot-API-Patches/0225-Create-HoverEvent-from-ItemStack-Entity.patch b/Spigot-API-Patches/0225-Create-HoverEvent-from-ItemStack-Entity.patch new file mode 100644 index 0000000000..af82fe1fd5 --- /dev/null +++ b/Spigot-API-Patches/0225-Create-HoverEvent-from-ItemStack-Entity.patch @@ -0,0 +1,65 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: ysl3000 +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 03ba2265908d35bded0f38ed31187e5500e1b1f0..3f23927e58e0ccf8cf04d4beb4d83346e3f84730 100644 +--- a/src/main/java/org/bukkit/inventory/ItemFactory.java ++++ b/src/main/java/org/bukkit/inventory/ItemFactory.java +@@ -165,5 +165,54 @@ 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 + } diff --git a/Spigot-Server-Patches/0575-Create-HoverEvent-from-ItemStack-Entity.patch b/Spigot-Server-Patches/0575-Create-HoverEvent-from-ItemStack-Entity.patch new file mode 100644 index 0000000000..cd8bb51188 --- /dev/null +++ b/Spigot-Server-Patches/0575-Create-HoverEvent-from-ItemStack-Entity.patch @@ -0,0 +1,51 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: ysl3000 +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 1c3e6e0c9abe681bf9e7305a74a68c1506ad8d0c..af84813c703813ec3a6ca89ff437d89e31a9100f 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +@@ -352,5 +352,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 + }