default type = player in create command

This commit is contained in:
envizar 2024-12-29 14:29:17 +03:00
parent d1b890a912
commit dfdcc54313
2 changed files with 8 additions and 3 deletions

View file

@ -26,12 +26,18 @@ public class CreateCommand implements CommandHandler {
@Override
public void run(CommandContext context) throws CommandExecutionException {
context.setUsage(context.getLabel() + " create <id> <type>");
context.setUsage(context.getLabel() + " create <id> [<type>]");
Player player = context.ensureSenderIsPlayer();
String id = context.popString();
if (npcRegistry.getById(id) != null) context.halt(Component.text("NPC with that ID already exists.", NamedTextColor.RED));
NpcTypeImpl type = context.parse(NpcTypeImpl.class);
NpcTypeImpl type;
if (context.argSize() == 1) {
type = context.parse(NpcTypeImpl.class);
} else {
type = typeRegistry.getByName("player");
}
NpcEntryImpl entry = npcRegistry.create(id, player.getWorld(), type, new NpcLocation(player.getLocation()));
entry.enableEverything();

View file

@ -11,7 +11,6 @@ import net.kyori.adventure.text.format.NamedTextColor;
import java.util.Collections;
import java.util.List;
import java.util.Set;
public class ToggleCommand implements CommandHandler {
private final NpcRegistryImpl npcRegistry;