Added entity hover in chat

This commit is contained in:
Felix Cravic 2020-08-02 13:56:25 +02:00
parent 865c5992e9
commit 1b324624b9

View File

@ -2,7 +2,9 @@ package net.minestom.server.chat;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.minestom.server.entity.Entity; import net.minestom.server.entity.Entity;
import net.minestom.server.entity.EntityType;
import net.minestom.server.item.ItemStack; import net.minestom.server.item.ItemStack;
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
/** /**
* Represent a hover event for a specific portion of the message * Represent a hover event for a specific portion of the message
@ -68,7 +70,8 @@ public class ChatHoverEvent {
* @return the chat hover event * @return the chat hover event
*/ */
public static ChatHoverEvent showItem(ItemStack itemStack) { public static ChatHoverEvent showItem(ItemStack itemStack) {
return new ChatHoverEvent("show_item", itemStack.toNBT().toSNBT()); final String json = itemStack.toNBT().toSNBT();
return new ChatHoverEvent("show_item", json);
} }
/** /**
@ -78,15 +81,9 @@ public class ChatHoverEvent {
* @return the chat hover event * @return the chat hover event
*/ */
public static ChatHoverEvent showEntity(Entity entity) { public static ChatHoverEvent showEntity(Entity entity) {
// TODO NBTCompound compound = new NBTCompound()
/*final String id = entity.getUuid().toString(); .setString("id", entity.getUuid().toString())
final String type = EntityType.fromId(entity.getEntityType()) .setString("type", EntityType.fromId(entity.getEntityType()).getNamespaceID());
.getNamespaceID().replace("minecraft:", ""); return new ChatHoverEvent("show_entity", compound.toSNBT());
JsonObject object = new JsonObject();
object.addProperty("id", id);
object.addProperty("type", type);
return new ChatHoverEvent("show_entity", object);*/
throw new UnsupportedOperationException("Entity hover isn't implemented yet");
} }
} }