From bc0095b99a0dfd7b32ae3f74126c64d37092d8ce Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 28 Jun 2020 19:38:30 -0400
Subject: [PATCH] Add /paper dumpitem command

Allows inspecting an items NBT at ease of the item in the players hand.
---
 .../Paper-dumpitem-command.patch              | 68 +++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 Spigot-Server-Patches/Paper-dumpitem-command.patch

diff --git a/Spigot-Server-Patches/Paper-dumpitem-command.patch b/Spigot-Server-Patches/Paper-dumpitem-command.patch
new file mode 100644
index 0000000000..a3f6f7a6dd
--- /dev/null
+++ b/Spigot-Server-Patches/Paper-dumpitem-command.patch
@@ -0,0 +1,68 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Aikar <aikar@aikar.co>
+Date: Sun, 28 Jun 2020 19:27:20 -0400
+Subject: [PATCH] Paper dumpitem command
+
+Let's you quickly view the item in your hands NBT data
+
+diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
+index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
+--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
++++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
+@@ -0,0 +0,0 @@ import org.bukkit.command.CommandSender;
+ import org.bukkit.craftbukkit.CraftServer;
+ import org.bukkit.craftbukkit.CraftWorld;
+ import org.bukkit.craftbukkit.entity.CraftPlayer;
++import org.bukkit.craftbukkit.inventory.CraftItemStack;
+ import org.bukkit.entity.Player;
++import org.bukkit.inventory.ItemStack;
+ 
+ import java.io.File;
+ import java.io.FileOutputStream;
+@@ -0,0 +0,0 @@ public class PaperCommand extends Command {
+     public PaperCommand(String name) {
+         super(name);
+         this.description = "Paper related commands";
+-        this.usageMessage = "/paper [heap | entity | reload | version | debug | dumpwaiting | chunkinfo | syncloadinfo | fixlight]";
++        this.usageMessage = "/paper [heap | entity | reload | version | debug | dumpwaiting | chunkinfo | syncloadinfo | fixlight | dumpitem]";
+         this.setPermission("bukkit.command.paper");
+     }
+ 
+     @Override
+     public List<String> tabComplete(CommandSender sender, String alias, String[] args, Location location) throws IllegalArgumentException {
+         if (args.length <= 1)
+-            return getListMatchingLast(args, "heap", "entity", "reload", "version", "debug", "dumpwaiting", "chunkinfo", "syncloadinfo", "fixlight");
++            return getListMatchingLast(args, "heap", "entity", "reload", "version", "debug", "dumpwaiting", "chunkinfo", "syncloadinfo", "fixlight", "dumpitem");
+ 
+         switch (args[0].toLowerCase(Locale.ENGLISH))
+         {
+@@ -0,0 +0,0 @@ public class PaperCommand extends Command {
+             case "reload":
+                 doReload(sender);
+                 break;
++            case "dumpitem":
++                doDumpItem(sender);
++                break;
+             case "debug":
+                 doDebug(sender, args);
+                 break;
+@@ -0,0 +0,0 @@ public class PaperCommand extends Command {
+         return true;
+     }
+ 
++    private void doDumpItem(CommandSender sender) {
++        ItemStack itemInHand = ((CraftPlayer) sender).getItemInHand();
++        net.minecraft.server.ItemStack itemStack = CraftItemStack.asNMSCopy(itemInHand);
++        NBTTagCompound tag = itemStack.getTag();
++        if (tag != null) {
++            String nbt = tag.toString();
++            Bukkit.getConsoleSender().sendMessage(nbt);
++            sender.sendMessage(nbt);
++        } else {
++            sender.sendMessage("Item does not have NBT");
++        }
++    }
++
+     private void doFixLight(CommandSender sender, String[] args) {
+         if (!(sender instanceof Player)) {
+             sender.sendMessage("Only players can use this command");