summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorrmichela <deltahat@gmail.com>2012-03-04 13:59:45 -0500
committerEvilSeph <evilseph@gmail.com>2012-03-08 01:29:25 -0500
commite1f7e0bbe8addf46553c4a5d532a449e15d53996 (patch)
tree80c4e12cc145eefa7df690971e49adc1f0a7caec /src
parent04e4c96049bf79ebb2b0cf1792fd205761c13381 (diff)
downloadbukkit-e1f7e0bbe8addf46553c4a5d532a449e15d53996.tar
bukkit-e1f7e0bbe8addf46553c4a5d532a449e15d53996.tar.gz
bukkit-e1f7e0bbe8addf46553c4a5d532a449e15d53996.tar.lz
bukkit-e1f7e0bbe8addf46553c4a5d532a449e15d53996.tar.xz
bukkit-e1f7e0bbe8addf46553c4a5d532a449e15d53996.zip
[Bleeding] Added local echo toggle to Conversation and ConversationFactory objects. Fixes BUKKIT-1007.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/conversations/Conversation.java24
-rw-r--r--src/main/java/org/bukkit/conversations/ConversationFactory.java14
2 files changed, 37 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/conversations/Conversation.java b/src/main/java/org/bukkit/conversations/Conversation.java
index 6a202418..55592552 100644
--- a/src/main/java/org/bukkit/conversations/Conversation.java
+++ b/src/main/java/org/bukkit/conversations/Conversation.java
@@ -34,6 +34,7 @@ public class Conversation {
protected Prompt currentPrompt;
protected ConversationContext context;
protected boolean modal;
+ protected boolean localEchoEnabled;
protected ConversationPrefix prefix;
protected List<ConversationCanceller> cancellers;
@@ -58,6 +59,7 @@ public class Conversation {
this.firstPrompt = firstPrompt;
this.context = new ConversationContext(plugin, forWhom, initialSessionData);
this.modal = true;
+ this.localEchoEnabled = true;
this.prefix = new NullConversationPrefix();
this.cancellers = new ArrayList<ConversationCanceller>();
}
@@ -89,6 +91,24 @@ public class Conversation {
}
/**
+ * Gets the status of local echo for this conversation. If local echo is enabled, any text submitted to a conversation
+ * gets echoed back into the submitter's chat window.
+ * @return The status of local echo.
+ */
+ public boolean isLocalEchoEnabled() {
+ return localEchoEnabled;
+ }
+
+ /**
+ * Sets the status of local echo for this conversation. If local echo is enabled, any text submitted to a conversation
+ * gets echoed back into the submitter's chat window.
+ * @param localEchoEnabled The status of local echo.
+ */
+ public void setLocalEchoEnabled(boolean localEchoEnabled) {
+ this.localEchoEnabled = localEchoEnabled;
+ }
+
+ /**
* Gets the {@link ConversationPrefix} that prepends all output from this conversation.
* @return The ConversationPrefix in use.
*/
@@ -163,7 +183,9 @@ public class Conversation {
if (currentPrompt != null) {
// Echo the user's input
- context.getForWhom().sendRawMessage(prefix.getPrefix(context) + input);
+ if (localEchoEnabled) {
+ context.getForWhom().sendRawMessage(prefix.getPrefix(context) + input);
+ }
// Test for conversation abandonment based on input
for(ConversationCanceller canceller : cancellers) {
diff --git a/src/main/java/org/bukkit/conversations/ConversationFactory.java b/src/main/java/org/bukkit/conversations/ConversationFactory.java
index 308a302a..6eb28692 100644
--- a/src/main/java/org/bukkit/conversations/ConversationFactory.java
+++ b/src/main/java/org/bukkit/conversations/ConversationFactory.java
@@ -19,6 +19,7 @@ public class ConversationFactory {
protected Plugin plugin;
protected boolean isModal;
+ protected boolean localEchoEnabled;
protected ConversationPrefix prefix;
protected Prompt firstPrompt;
protected Map<Object, Object> initialSessionData;
@@ -32,6 +33,7 @@ public class ConversationFactory {
{
this.plugin = plugin;
isModal = true;
+ localEchoEnabled = true;
prefix = new NullConversationPrefix();
firstPrompt = Prompt.END_OF_CONVERSATION;
initialSessionData = new HashMap<Object, Object>();
@@ -54,6 +56,17 @@ public class ConversationFactory {
}
/**
+ * Sets the local echo status for all {@link Conversation}s created by this factory. If local echo is enabled,
+ * any text submitted to a conversation gets echoed back into the submitter's chat window.
+ * @param localEchoEnabled The status of local echo.
+ * @return This object.
+ */
+ public ConversationFactory withLocalEcho(boolean localEchoEnabled) {
+ this.localEchoEnabled = localEchoEnabled;
+ return this;
+ }
+
+ /**
* Sets the {@link ConversationPrefix} that prepends all output from all generated conversations.
*
* The default is a {@link NullConversationPrefix};
@@ -146,6 +159,7 @@ public class ConversationFactory {
//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