From 9f09c8f114a04676d342d561179758697dd355ae Mon Sep 17 00:00:00 2001 From: jhqwqmc <2110242767@qq.com> Date: Sun, 8 Jun 2025 01:10:23 +0800 Subject: [PATCH] =?UTF-8?q?feat(debug):=20=E6=B7=BB=E5=8A=A0=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=AE=9E=E4=BD=93id2uuid=E8=B0=83=E8=AF=95=E5=91=BD?= =?UTF-8?q?=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/command/BukkitCommandManager.java | 1 + .../feature/DebugEntityId2UUIDCommand.java | 59 +++++++++++++++++++ common-files/src/main/resources/commands.yml | 7 +++ gradle.properties | 2 +- 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/command/feature/DebugEntityId2UUIDCommand.java diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/command/BukkitCommandManager.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/command/BukkitCommandManager.java index 6701320b9..ccc824bd9 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/command/BukkitCommandManager.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/command/BukkitCommandManager.java @@ -48,6 +48,7 @@ public class BukkitCommandManager extends AbstractCommandManager new DebugSpawnFurnitureCommand(this, plugin), new DebugTargetBlockCommand(this, plugin), new DebugIsSectionInjectedCommand(this, plugin), + new DebugEntityId2UUIDCommand(this, plugin), new TotemAnimationCommand(this, plugin), new EnableResourceCommand(this, plugin), new DisableResourceCommand(this, plugin), diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/command/feature/DebugEntityId2UUIDCommand.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/command/feature/DebugEntityId2UUIDCommand.java new file mode 100644 index 000000000..f5bacc952 --- /dev/null +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/command/feature/DebugEntityId2UUIDCommand.java @@ -0,0 +1,59 @@ +package net.momirealms.craftengine.bukkit.plugin.command.feature; + +import net.momirealms.craftengine.bukkit.nms.FastNMS; +import net.momirealms.craftengine.bukkit.plugin.command.BukkitCommandFeature; +import net.momirealms.craftengine.core.plugin.CraftEngine; +import net.momirealms.craftengine.core.plugin.command.CraftEngineCommandManager; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Entity; +import org.incendo.cloud.Command; +import org.incendo.cloud.CommandManager; +import org.incendo.cloud.bukkit.parser.WorldParser; +import org.incendo.cloud.parser.standard.IntegerParser; + +public class DebugEntityId2UUIDCommand extends BukkitCommandFeature { + + public DebugEntityId2UUIDCommand(CraftEngineCommandManager commandManager, CraftEngine plugin) { + super(commandManager, plugin); + } + + @Override + public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { + return builder + .required("world", WorldParser.worldParser()) + .required("entityId", IntegerParser.integerParser()) + .handler(context -> { + World world = context.get("world"); + int entityId = context.get("entityId"); + Entity entity = FastNMS.INSTANCE.getBukkitEntityById(world, entityId); + if (entity == null) { + context.sender().sendMessage("entity not found"); + return; + } + Location location = entity.getLocation(); + context.sender().sendMessage( + String.format( + """ + =========================== + uuid: %s + name: %s + location: %s,%s,%s + type: %s + =========================== + """, + entity.getUniqueId(), + entity.getName(), + location.x(), location.y(), location.z(), + entity.getType() + ) + ); + }); + } + + @Override + public String getFeatureID() { + return "debug_entity_id_to_uuid"; + } +} diff --git a/common-files/src/main/resources/commands.yml b/common-files/src/main/resources/commands.yml index d600a8e7c..d7b499210 100644 --- a/common-files/src/main/resources/commands.yml +++ b/common-files/src/main/resources/commands.yml @@ -182,6 +182,13 @@ debug_clear_cooldown: - /craftengine debug clear-cooldown - /ce debug clear-cooldown +debug_entity_id_to_uuid: + enable: true + permission: ce.command.debug.entity_id_to_uuid + usage: + - /craftengine debug entity-id-to-uuid + - /ce debug entity-id-to-uuid + debug_test: enable: true permission: ce.command.debug.test diff --git a/gradle.properties b/gradle.properties index e1b0975d8..e9c2a415d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G # Project settings # Rule: [major update].[feature update].[bug fix] project_version=0.0.56.2 -config_version=34 +config_version=35 lang_version=15 project_group=net.momirealms latest_supported_version=1.21.5