Arrays.asList("weave", "fabric", "magical", "mithril fabric", "ida", "mithril", "cloak", "mithril cloak", "pedinghaus", "task", "quest"),
new NotCondition(
new OrCondition(new QuestInStateCondition(mithrilcloak.getQuestSlot(), "got_mithril_thread"),
new QuestInStateCondition(mithrilcloak.getQuestSlot(), "taking_letter"),
new QuestInStateCondition(mithrilcloak.getQuestSlot(), "took_letter"),
new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "weavingfabric;")
)
),
ConversationStates.ATTENDING,
"I haven't got any quest for you now.", null);
// player says yes they brought the items needed
// we can't use the nice ChatActions here because we have to timestamp the quest slot
npc.add(
ConversationStates.SERVICE_OFFERED,
ConversationPhrases.YES_MESSAGES,
new QuestInStateCondition(mithrilcloak.getQuestSlot(), "took_letter"),
ConversationStates.ATTENDING,
null,
new ChatAction() {
public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
if (player.isEquipped("mithril thread", 40)) {
player.drop("mithril thread", 40);
npc.say("Lovely. In "
+ REQUIRED_HOURS_FABRIC + " hours your fabric will be ready.");
player.setQuest(mithrilcloak.getQuestSlot(), "weavingfabric;" + System.currentTimeMillis());
player.notifyWorldAboutChanges();
} else {
npc.say("You don't appear to have 40 spools of mithril thread with you. Sorry, I can't do anything without it.");
}
}
});
// player says they didn't bring the stuff yet
npc.add(
ConversationStates.SERVICE_OFFERED,
ConversationPhrases.NO_MESSAGES,
null,
ConversationStates.ATTENDING,
"Oh, ok, well I hope you haven't lost them, they are precious!",
null);
// player returns while fabric is still being woven, or is ready
npc.add(ConversationStates.ATTENDING,
Arrays.asList("weave", "fabric", "magical", "mithril fabric", "ida", "mithril", "cloak", "mithril cloak", "task", "quest"),
new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "weavingfabric;"),
ConversationStates.ATTENDING, null, new ChatAction() {
public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
final String[] tokens = player.getQuest(mithrilcloak.getQuestSlot()).split(";");
final long delay = REQUIRED_HOURS_FABRIC * MathHelper.MILLISECONDS_IN_ONE_HOUR;
final long timeRemaining = (Long.parseLong(tokens[1]) + delay)