Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/patches/server/0443-Paper-dumpitem-command.patch

65 Zeilen
3.1 KiB
Diff

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
2022-06-10 16:15:38 +02:00
index fb2cb76e4954d9d69b4a631d6e20bdcc511b6b3f..27c350c123b4349b8b401a06f204de46c88da7ac 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
2022-06-09 23:43:27 +02:00
@@ -31,7 +31,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;
import java.io.FileOutputStream;
2022-06-09 23:43:27 +02:00
@@ -62,7 +64,7 @@ import static net.kyori.adventure.text.format.NamedTextColor.YELLOW;
2021-06-11 14:02:28 +02: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", "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);
2022-06-09 23:43:27 +02:00
@@ -176,6 +178,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;
2022-06-09 23:43:27 +02:00
@@ -489,6 +494,23 @@ public class PaperCommand extends Command {
2021-06-11 14:02:28 +02:00
2022-06-03 06:26:56 +02:00
Command.broadcastCommandMessage(sender, text("Paper config reload complete.", GREEN));
}
2021-06-11 14:02:28 +02:00
+ private void doDumpItem(CommandSender sender) {
+ if (!(sender instanceof Player)) {
+ sender.sendMessage("Only players can use this command");
+ return;
+ }
2021-06-11 14:02:28 +02:00
+ ItemStack itemInHand = ((CraftPlayer) sender).getItemInHand();
+ net.minecraft.world.item.ItemStack itemStack = CraftItemStack.asNMSCopy(itemInHand);
+ net.minecraft.nbt.CompoundTag tag = itemStack.getTag();
2021-06-11 14:02:28 +02:00
+ if (tag != null) {
+ 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");