@@ -225,6 +225,7 @@ public class ConversationFactory {
|
||||
|
||||
private class NotPlayerMessagePrompt extends MessagePrompt {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getPromptText(@NotNull ConversationContext context) {
|
||||
return playerOnlyMessage;
|
||||
|
||||
@@ -19,12 +19,15 @@ public class ExactMatchConversationCanceller implements ConversationCanceller {
|
||||
this.escapeSequence = escapeSequence;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConversation(@NotNull Conversation conversation) {}
|
||||
|
||||
@Override
|
||||
public boolean cancelBasedOnInput(@NotNull ConversationContext context, @NotNull String input) {
|
||||
return input.equals(escapeSequence);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ConversationCanceller clone() {
|
||||
return new ExactMatchConversationCanceller(escapeSequence);
|
||||
|
||||
@@ -24,11 +24,13 @@ public class InactivityConversationCanceller implements ConversationCanceller {
|
||||
this.timeoutSeconds = timeoutSeconds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConversation(@NotNull Conversation conversation) {
|
||||
this.conversation = conversation;
|
||||
startTimer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cancelBasedOnInput(@NotNull ConversationContext context, @NotNull String input) {
|
||||
// Reset the inactivity timer
|
||||
stopTimer();
|
||||
@@ -36,6 +38,7 @@ public class InactivityConversationCanceller implements ConversationCanceller {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ConversationCanceller clone() {
|
||||
return new InactivityConversationCanceller(plugin, timeoutSeconds);
|
||||
@@ -46,6 +49,7 @@ public class InactivityConversationCanceller implements ConversationCanceller {
|
||||
*/
|
||||
private void startTimer() {
|
||||
taskId = plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (conversation.getState() == Conversation.ConversationState.UNSTARTED) {
|
||||
startTimer();
|
||||
|
||||
@@ -8,14 +8,17 @@ import org.jetbrains.annotations.NotNull;
|
||||
* abandoned by programmatically calling the abandon() method on it.
|
||||
*/
|
||||
public class ManuallyAbandonedConversationCanceller implements ConversationCanceller {
|
||||
@Override
|
||||
public void setConversation(@NotNull Conversation conversation) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cancelBasedOnInput(@NotNull ConversationContext context, @NotNull String input) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ConversationCanceller clone() {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
@@ -19,6 +19,7 @@ public abstract class MessagePrompt implements Prompt {
|
||||
* @param context Context information about the conversation.
|
||||
* @return Always false.
|
||||
*/
|
||||
@Override
|
||||
public boolean blocksForInput(@NotNull ConversationContext context) {
|
||||
return false;
|
||||
}
|
||||
@@ -31,6 +32,7 @@ public abstract class MessagePrompt implements Prompt {
|
||||
* @param input Ignored.
|
||||
* @return The next prompt in the prompt graph.
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public Prompt acceptInput(@NotNull ConversationContext context, @Nullable String input) {
|
||||
return getNextPrompt(context);
|
||||
|
||||
@@ -14,6 +14,7 @@ public class NullConversationPrefix implements ConversationPrefix {
|
||||
* @param context Context information about the conversation.
|
||||
* @return An empty string.
|
||||
*/
|
||||
@Override
|
||||
@NotNull
|
||||
public String getPrefix(@NotNull ConversationContext context) {
|
||||
return "";
|
||||
|
||||
@@ -34,6 +34,7 @@ public class PluginNameConversationPrefix implements ConversationPrefix {
|
||||
* @param context Context information about the conversation.
|
||||
* @return An empty string.
|
||||
*/
|
||||
@Override
|
||||
@NotNull
|
||||
public String getPrefix(@NotNull ConversationContext context) {
|
||||
return cachedPrefix;
|
||||
|
||||
@@ -14,6 +14,7 @@ public abstract class StringPrompt implements Prompt {
|
||||
* @param context Context information about the conversation.
|
||||
* @return True.
|
||||
*/
|
||||
@Override
|
||||
public boolean blocksForInput(@NotNull ConversationContext context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ public abstract class ValidatingPrompt implements Prompt {
|
||||
* @param input The input text from the user.
|
||||
* @return This prompt or the next Prompt in the prompt graph.
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public Prompt acceptInput(@NotNull ConversationContext context, @Nullable String input) {
|
||||
if (isInputValid(context, input)) {
|
||||
@@ -43,6 +44,7 @@ public abstract class ValidatingPrompt implements Prompt {
|
||||
* @param context Context information about the conversation.
|
||||
* @return True.
|
||||
*/
|
||||
@Override
|
||||
public boolean blocksForInput(@NotNull ConversationContext context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user