check if sender is a player in paper dumpitem command, closes #5858

Dieser Commit ist enthalten in:
MiniDigger 2021-06-17 20:13:55 +02:00
Ursprung d04c22dddf
Commit 2cbdb174b7

Datei anzeigen

@ -6,7 +6,7 @@ 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 de45163023f436d386e90e6ded5e6105ba3ecf35..8fdfcf001cf2ed6184d86ee033ede08fdf9aa5d6 100644
index de45163023f436d386e90e6ded5e6105ba3ecf35..160f3cdee21d8a3aa2ed726a7fbfce460dff26f3 100644
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
@@ -20,6 +20,7 @@ import net.minecraft.server.level.ServerPlayer;
@ -46,11 +46,15 @@ index de45163023f436d386e90e6ded5e6105ba3ecf35..8fdfcf001cf2ed6184d86ee033ede08f
case "debug":
doDebug(sender, args);
break;
@@ -466,6 +472,19 @@ public class PaperCommand extends Command {
@@ -466,6 +472,23 @@ public class PaperCommand extends Command {
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Paper config reload complete.");
}
+ private void doDumpItem(CommandSender sender) {
+ if (!(sender instanceof Player)) {
+ sender.sendMessage("Only players can use this command");
+ return;
+ }
+ ItemStack itemInHand = ((CraftPlayer) sender).getItemInHand();
+ net.minecraft.world.item.ItemStack itemStack = CraftItemStack.asNMSCopy(itemInHand);
+ net.minecraft.nbt.CompoundTag tag = itemStack.getTag();