38 lines
1.4 KiB
Java
38 lines
1.4 KiB
Java
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.util.NpcLocation;
|
|
import net.kyori.adventure.text.Component;
|
|
import net.kyori.adventure.text.format.NamedTextColor;
|
|
import org.bukkit.entity.Player;
|
|
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
|
|
public class MoveCommand implements CommandHandler {
|
|
private final NpcRegistryImpl npcRegistry;
|
|
|
|
public MoveCommand(NpcRegistryImpl npcRegistry) {
|
|
this.npcRegistry = npcRegistry;
|
|
}
|
|
|
|
@Override
|
|
public void run(CommandContext context) throws CommandExecutionException {
|
|
context.setUsage(context.getLabel() + " move <id>");
|
|
Player player = context.ensureSenderIsPlayer();
|
|
NpcImpl npc = context.parse(NpcEntryImpl.class).getNpc();
|
|
npc.setLocation(new NpcLocation(player.getLocation()));
|
|
context.send(Component.text("NPC moved to your current location.", NamedTextColor.GREEN));
|
|
}
|
|
|
|
@Override
|
|
public List<String> suggest(CommandContext context) throws CommandExecutionException {
|
|
if (context.argSize() == 1) return context.suggestCollection(npcRegistry.getModifiableIds());
|
|
return Collections.emptyList();
|
|
}
|
|
}
|