/** * Constructs a {@link Conversation} in accordance with the defaults set * for this factory. * * @param forWhom The entity for whom the new conversation is mediating. * @return A new conversation. */ public Conversation buildConversation(Conversable forWhom) { //Abort conversation construction if we aren't supposed to talk to non-players if (playerOnlyMessage != null && !(forWhom instanceof Player)) { return new Conversation(plugin, forWhom, new NotPlayerMessagePrompt()); } //Clone any initial session data Map<Object, Object> copiedInitialSessionData = new HashMap<Object, Object>(); copiedInitialSessionData.putAll(initialSessionData); //Build and return a conversation Conversation conversation = new Conversation(plugin, forWhom, firstPrompt, copiedInitialSessionData); conversation.setModal(isModal); conversation.setLocalEchoEnabled(localEchoEnabled); conversation.setPrefix(prefix); //Clone the conversation cancellers for (ConversationCanceller canceller : cancellers) { conversation.addConversationCanceller(canceller.clone()); } //Add the ConversationAbandonedListeners for (ConversationAbandonedListener listener : abandonedListeners) { conversation.addConversationAbandonedListener(listener); } return conversation; }
/** * Constructs a {@link Conversation} in accordance with the defaults set * for this factory. * * @param forWhom The entity for whom the new conversation is mediating. * @return A new conversation. */ public Conversation buildConversation(Conversable forWhom) { //Abort conversation construction if we aren't supposed to talk to non-players if (playerOnlyMessage != null && !(forWhom instanceof Player)) { return new Conversation(plugin, forWhom, new NotPlayerMessagePrompt()); } //Clone any initial session data Map<Object, Object> copiedInitialSessionData = new HashMap<Object, Object>(); copiedInitialSessionData.putAll(initialSessionData); //Build and return a conversation Conversation conversation = new Conversation(plugin, forWhom, firstPrompt, copiedInitialSessionData); conversation.setModal(isModal); conversation.setLocalEchoEnabled(localEchoEnabled); conversation.setPrefix(prefix); //Clone the conversation cancellers for (ConversationCanceller canceller : cancellers) { conversation.addConversationCanceller(canceller.clone()); } //Add the ConversationAbandonedListeners for (ConversationAbandonedListener listener : abandonedListeners) { conversation.addConversationAbandonedListener(listener); } return conversation; }