Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-14 20:10:05 +01:00
Create HoverEvent from ItemStack Entity
add myself to MIT list Co-authored-by: Mariell <proximyst@proximyst.com> Co-authored-by: MiniDigger <admin@minidigger.me>
Dieser Commit ist enthalten in:
Ursprung
da33f8bbe1
Commit
07bca94f71
@ -42,4 +42,5 @@ rickyboy320 <rickw320@hotmail.com>
|
||||
DoNotSpamPls <7570108+DoNotSpamPls@users.noreply.github.com>
|
||||
JRoy <joshroy126@gmail.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 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
|
||||
}
|
@ -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 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
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren