2021-06-11 14:02:28 +02: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-06-16 02:50:38 +02:00
|
|
|
index de45163023f436d386e90e6ded5e6105ba3ecf35..8fdfcf001cf2ed6184d86ee033ede08fdf9aa5d6 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
2021-06-16 02:50:38 +02:00
|
|
|
@@ -20,6 +20,7 @@ import net.minecraft.server.level.ServerPlayer;
|
2021-06-14 10:37:14 +02:00
|
|
|
import net.minecraft.server.level.ThreadedLevelLightEngine;
|
|
|
|
import net.minecraft.world.entity.EntityType;
|
|
|
|
import net.minecraft.world.level.ChunkPos;
|
|
|
|
+import net.minecraft.network.protocol.game.ClientboundLightUpdatePacket;
|
2021-06-11 14:02:28 +02:00
|
|
|
import net.minecraft.resources.ResourceLocation;
|
|
|
|
import net.minecraft.server.MCUtil;
|
2021-06-14 10:37:14 +02:00
|
|
|
import org.apache.commons.lang3.tuple.MutablePair;
|
2021-06-16 02:50:38 +02:00
|
|
|
@@ -33,7 +34,9 @@ import org.bukkit.command.CommandSender;
|
2021-06-11 14:02:28 +02: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;
|
2021-06-16 02:50:38 +02:00
|
|
|
import java.io.FileOutputStream;
|
|
|
|
@@ -56,7 +59,7 @@ import java.util.stream.Collectors;
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
public class PaperCommand extends Command {
|
|
|
|
private static final String BASE_PERM = "bukkit.command.paper.";
|
2021-06-16 02:50:38 +02:00
|
|
|
- private static final ImmutableSet<String> SUBCOMMANDS = ImmutableSet.<String>builder().add("heap", "entity", "reload", "version", "debug", "chunkinfo", "fixlight", "syncloadinfo").build();
|
|
|
|
+ private static final ImmutableSet<String> SUBCOMMANDS = ImmutableSet.<String>builder().add("heap", "entity", "reload", "version", "debug", "chunkinfo", "fixlight", "syncloadinfo", "dumpitem").build();
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
public PaperCommand(String name) {
|
|
|
|
super(name);
|
2021-06-16 02:50:38 +02:00
|
|
|
@@ -165,6 +168,9 @@ public class PaperCommand extends Command {
|
2021-06-11 14:02:28 +02:00
|
|
|
case "reload":
|
|
|
|
doReload(sender);
|
|
|
|
break;
|
|
|
|
+ case "dumpitem":
|
|
|
|
+ doDumpItem(sender);
|
|
|
|
+ break;
|
|
|
|
case "debug":
|
|
|
|
doDebug(sender, args);
|
|
|
|
break;
|
2021-06-16 02:50:38 +02:00
|
|
|
@@ -466,6 +472,19 @@ public class PaperCommand extends Command {
|
2021-06-11 14:02:28 +02:00
|
|
|
|
2021-06-14 10:37:14 +02:00
|
|
|
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Paper config reload complete.");
|
|
|
|
}
|
2021-06-11 14:02:28 +02:00
|
|
|
+ private void doDumpItem(CommandSender sender) {
|
|
|
|
+ ItemStack itemInHand = ((CraftPlayer) sender).getItemInHand();
|
|
|
|
+ net.minecraft.world.item.ItemStack itemStack = CraftItemStack.asNMSCopy(itemInHand);
|
2021-06-14 10:37:14 +02:00
|
|
|
+ net.minecraft.nbt.CompoundTag tag = itemStack.getTag();
|
2021-06-11 14:02:28 +02:00
|
|
|
+ if (tag != null) {
|
2021-06-14 10:37:14 +02:00
|
|
|
+ net.kyori.adventure.text.Component nbtComponent = io.papermc.paper.adventure.PaperAdventure.asAdventure(net.minecraft.nbt.NbtUtils.toPrettyComponent(tag));
|
|
|
|
+ Bukkit.getConsoleSender().sendMessage(nbtComponent);
|
|
|
|
+ sender.sendMessage(nbtComponent);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ } 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");
|