2020-06-28 23:38:30 +00:00
|
|
|
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
|
2021-01-05 21:25:45 +00:00
|
|
|
index 0619e6d0901ecd656aebd66522c08379916a8b78..46b5d07be1e187129fa7f2dd62397ed34b4a9e15 100644
|
2020-06-28 23:38:30 +00:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
2021-01-05 21:25:45 +00:00
|
|
|
@@ -22,6 +22,7 @@ import net.minecraft.server.LightEngineThreaded;
|
|
|
|
import net.minecraft.server.MCUtil;
|
|
|
|
import net.minecraft.server.MinecraftKey;
|
|
|
|
import net.minecraft.server.MinecraftServer;
|
|
|
|
+import net.minecraft.server.NBTTagCompound;
|
|
|
|
import net.minecraft.server.PacketPlayOutLightUpdate;
|
|
|
|
import net.minecraft.server.PlayerChunk;
|
|
|
|
import net.minecraft.server.WorldServer;
|
|
|
|
@@ -36,7 +37,9 @@ import org.bukkit.command.CommandSender;
|
2020-06-28 23:38:30 +00:00
|
|
|
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;
|
2021-01-05 21:25:45 +00:00
|
|
|
@@ -59,7 +62,7 @@ import java.util.stream.Collectors;
|
2020-06-28 23:38:30 +00:00
|
|
|
|
2021-01-05 21:25:45 +00:00
|
|
|
public class PaperCommand extends Command {
|
|
|
|
private static final String BASE_PERM = "bukkit.command.paper.";
|
|
|
|
- private static final ImmutableSet<String> SUBCOMMANDS = ImmutableSet.<String>builder().add("heap", "entity", "reload", "version", "debug", "chunkinfo", "dumpwaiting", "syncloadinfo", "fixlight").build();
|
|
|
|
+ private static final ImmutableSet<String> SUBCOMMANDS = ImmutableSet.<String>builder().add("heap", "entity", "reload", "version", "debug", "chunkinfo", "dumpwaiting", "syncloadinfo", "fixlight", "dumpitem").build();
|
2020-06-28 23:38:30 +00:00
|
|
|
|
2021-01-05 21:25:45 +00:00
|
|
|
public PaperCommand(String name) {
|
|
|
|
super(name);
|
|
|
|
@@ -168,6 +171,9 @@ public class PaperCommand extends Command {
|
2020-06-28 23:38:30 +00:00
|
|
|
case "reload":
|
|
|
|
doReload(sender);
|
|
|
|
break;
|
|
|
|
+ case "dumpitem":
|
|
|
|
+ doDumpItem(sender);
|
|
|
|
+ break;
|
|
|
|
case "debug":
|
|
|
|
doDebug(sender, args);
|
|
|
|
break;
|
2021-01-05 21:25:45 +00:00
|
|
|
@@ -200,6 +206,19 @@ public class PaperCommand extends Command {
|
2020-06-28 23:38:30 +00:00
|
|
|
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) {
|
2020-12-08 02:10:22 +00:00
|
|
|
+ String nbt = org.bukkit.craftbukkit.util.CraftChatMessage.fromComponent(tag.getNbtPrettyComponent());
|
2020-06-28 23:38:30 +00:00
|
|
|
+ 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");
|
2020-12-08 02:10:22 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/NBTBase.java b/src/main/java/net/minecraft/server/NBTBase.java
|
|
|
|
index 8b9e47b4c7f5dc464fa617a59583df9e30a54045..104b820ee380083ec755c443a4a9c270e525ca45 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/NBTBase.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/NBTBase.java
|
|
|
|
@@ -24,6 +24,7 @@ public interface NBTBase {
|
|
|
|
return this.toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
+ default IChatBaseComponent getNbtPrettyComponent() { return this.l(); } // Paper - OBFHELPER
|
|
|
|
default IChatBaseComponent l() {
|
|
|
|
return this.a("", 0);
|
|
|
|
}
|