Paper/Spigot-Server-Patches/0514-Paper-dumpitem-command.patch
Mariell Hoversholm 654b792caf Updated Upstream (CraftBukkit)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

CraftBukkit Changes:
a339310c #755: Fix NPE when calling getInventory() for virtual EnderChests
2577f9bf Increase outdated build delay
1dabfdc8 #754: Fix pre-1.16 serialized SkullMeta being broken on 1.16+, losing textures
2020-09-27 11:04:51 -04:00

69 lines
3.1 KiB
Diff

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 a12bc81933c15606b7cde46937f504eafc4ff030..d798de637389cc5d5289a6c75304de307b01f493 100644
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
@@ -21,7 +21,9 @@ 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;
@@ -37,14 +39,14 @@ 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))
{
@@ -133,6 +135,9 @@ public class PaperCommand extends Command {
case "reload":
doReload(sender);
break;
+ case "dumpitem":
+ doDumpItem(sender);
+ break;
case "debug":
doDebug(sender, args);
break;
@@ -164,6 +169,19 @@ 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");