ZNPCsPlus/plugin/src/main/java/lol/pyr/znpcsplus/parsers/NpcEntryParser.java

27 lines
941 B
Java
Raw Normal View History

2023-05-21 11:33:18 +00:00
package lol.pyr.znpcsplus.parsers;
2023-05-10 15:01:14 +00:00
import lol.pyr.director.adventure.command.CommandContext;
import lol.pyr.director.adventure.parse.ParserType;
import lol.pyr.director.common.command.CommandExecutionException;
import lol.pyr.director.common.message.Message;
import lol.pyr.znpcsplus.npc.NpcEntryImpl;
import lol.pyr.znpcsplus.npc.NpcRegistryImpl;
import java.util.Deque;
public class NpcEntryParser extends ParserType<NpcEntryImpl> {
private final NpcRegistryImpl npcRegistry;
public NpcEntryParser(NpcRegistryImpl npcRegistry, Message<CommandContext> message) {
2023-05-10 15:01:14 +00:00
super(message);
this.npcRegistry = npcRegistry;
2023-05-10 15:01:14 +00:00
}
@Override
public NpcEntryImpl parse(Deque<String> deque) throws CommandExecutionException {
NpcEntryImpl entry = npcRegistry.get(deque.pop());
2023-05-10 15:01:14 +00:00
if (entry == null || !entry.isAllowCommandModification()) throw new CommandExecutionException();
return entry;
}
}