9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-25 01:49:30 +00:00

添加debug指令

This commit is contained in:
XiaoMoMi
2025-07-05 02:46:36 +08:00
parent cbca13146c
commit 9dd3d51012
4 changed files with 51 additions and 1 deletions

View File

@@ -41,6 +41,7 @@ public class BukkitCommandManager extends AbstractCommandManager<CommandSender>
new DebugGetBlockInternalIdCommand(this, plugin),
new DebugAppearanceStateUsageCommand(this, plugin),
new DebugClearCooldownCommand(this, plugin),
new DebugEntityIdCommand(this, plugin),
new DebugRealStateUsageCommand(this, plugin),
new DebugItemDataCommand(this, plugin),
new DebugSetBlockCommand(this, plugin),

View File

@@ -0,0 +1,42 @@
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.World;
import org.bukkit.command.CommandSender;
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 DebugEntityIdCommand extends BukkitCommandFeature<CommandSender> {
public DebugEntityIdCommand(CraftEngineCommandManager<CommandSender> commandManager, CraftEngine plugin) {
super(commandManager, plugin);
}
@Override
public Command.Builder<? extends CommandSender> assembleCommand(CommandManager<CommandSender> manager, Command.Builder<CommandSender> builder) {
return builder
.required("world", WorldParser.worldParser())
.required("entityId", IntegerParser.integerParser())
.handler(context -> {
World world = context.get("world");
int entityId = context.get("entityId");
Object entityLookup = FastNMS.INSTANCE.method$ServerLevel$getEntityLookup(FastNMS.INSTANCE.field$CraftWorld$ServerLevel(world));
Object entity = FastNMS.INSTANCE.method$EntityLookup$get(entityLookup, entityId);
if (entity == null) {
context.sender().sendMessage("entity not found");
return;
}
context.sender().sendMessage(entity.toString());
});
}
@Override
public String getFeatureID() {
return "debug_entity_id";
}
}

View File

@@ -196,6 +196,13 @@ debug_is_chunk_persistent_loaded:
- /craftengine debug is-chunk-persistent-loaded
- /ce debug is-chunk-persistent-loaded
debug_entity_id:
enable: true
permission: ce.command.debug.debug_entity_id
usage:
- /craftengine debug entity-id
- /ce debug entity-id
debug_test:
enable: true
permission: ce.command.debug.test

View File

@@ -50,7 +50,7 @@ byte_buddy_version=1.17.5
ahocorasick_version=0.6.3
snake_yaml_version=2.4
anti_grief_version=0.18
nms_helper_version=1.0.25
nms_helper_version=1.0.26
evalex_version=3.5.0
reactive_streams_version=1.0.4
amazon_awssdk_version=2.31.23