upstream #1
2 changed files with 8 additions and 3 deletions
|
@ -26,12 +26,18 @@ public class CreateCommand implements CommandHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(CommandContext context) throws CommandExecutionException {
|
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();
|
Player player = context.ensureSenderIsPlayer();
|
||||||
|
|
||||||
String id = context.popString();
|
String id = context.popString();
|
||||||
if (npcRegistry.getById(id) != null) context.halt(Component.text("NPC with that ID already exists.", NamedTextColor.RED));
|
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()));
|
NpcEntryImpl entry = npcRegistry.create(id, player.getWorld(), type, new NpcLocation(player.getLocation()));
|
||||||
entry.enableEverything();
|
entry.enableEverything();
|
||||||
|
|
|
@ -11,7 +11,6 @@ import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class ToggleCommand implements CommandHandler {
|
public class ToggleCommand implements CommandHandler {
|
||||||
private final NpcRegistryImpl npcRegistry;
|
private final NpcRegistryImpl npcRegistry;
|
||||||
|
|
Loading…
Reference in a new issue