commit
1aeae3f12a
2 changed files with 33 additions and 0 deletions
|
@ -199,6 +199,7 @@ public class ZNpcsPlus extends JavaPlugin {
|
|||
.addSubcommand("teleport", new TeleportCommand())
|
||||
.addSubcommand("list", new ListCommand())
|
||||
.addSubcommand("near", new NearCommand())
|
||||
.addSubcommand("type", new TypeCommand())
|
||||
.addSubcommand("storage", new MultiCommand()
|
||||
.addSubcommand("save", new SaveAllCommand())
|
||||
.addSubcommand("load", new LoadAllCommand()))
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package lol.pyr.znpcsplus.commands;
|
||||
|
||||
import lol.pyr.director.adventure.command.CommandContext;
|
||||
import lol.pyr.director.adventure.command.CommandHandler;
|
||||
import lol.pyr.director.common.command.CommandExecutionException;
|
||||
import lol.pyr.znpcsplus.npc.NpcEntryImpl;
|
||||
import lol.pyr.znpcsplus.npc.NpcImpl;
|
||||
import lol.pyr.znpcsplus.npc.NpcRegistryImpl;
|
||||
import lol.pyr.znpcsplus.npc.NpcTypeImpl;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class TypeCommand implements CommandHandler {
|
||||
@Override
|
||||
public void run(CommandContext context) throws CommandExecutionException {
|
||||
context.setUsage(context.getLabel() + " type <id> <type>");
|
||||
NpcImpl npc = context.parse(NpcEntryImpl.class).getNpc();
|
||||
NpcTypeImpl type = context.parse(NpcTypeImpl.class);
|
||||
npc.setType(type);
|
||||
context.send(Component.text("NPC type set to " + type.getName() + ".", NamedTextColor.GREEN));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(CommandContext context) throws CommandExecutionException {
|
||||
if (context.argSize() == 1) return context.suggestCollection(NpcRegistryImpl.get().modifiableIds());
|
||||
if (context.argSize() == 2) return context.suggestStream(NpcTypeImpl.values().stream().map(NpcTypeImpl::getName));
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue