default type = player in create command
This commit is contained in:
parent
d1b890a912
commit
dfdcc54313
2 changed files with 8 additions and 3 deletions
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue