Package org.bukkit.conversations
Class InactivityConversationCanceller
- java.lang.Object
-
- org.bukkit.conversations.InactivityConversationCanceller
-
- All Implemented Interfaces:
Cloneable
,ConversationCanceller
public class InactivityConversationCanceller extends Object implements ConversationCanceller
An InactivityConversationCanceller will cancel aConversation
after a period of inactivity by the user.
-
-
Field Summary
Fields Modifier and Type Field Description protected Conversation
conversation
protected Plugin
plugin
protected int
timeoutSeconds
-
Constructor Summary
Constructors Constructor Description InactivityConversationCanceller(@NotNull Plugin plugin, int timeoutSeconds)
Creates an InactivityConversationCanceller.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
cancelBasedOnInput(@NotNull ConversationContext context, @NotNull String input)
Cancels a conversation based on user input.protected void
cancelling(@NotNull Conversation conversation)
Subclasses of InactivityConversationCanceller can override this method to take additional actions when the inactivity timer abandons the conversation.@NotNull ConversationCanceller
clone()
Allows theConversationFactory
to duplicate this ConversationCanceller when creating a newConversation
.void
setConversation(@NotNull Conversation conversation)
Sets the conversation this ConversationCanceller can optionally cancel.
-
-
-
Field Detail
-
plugin
protected Plugin plugin
-
timeoutSeconds
protected int timeoutSeconds
-
conversation
protected Conversation conversation
-
-
Constructor Detail
-
InactivityConversationCanceller
public InactivityConversationCanceller(@NotNull @NotNull Plugin plugin, int timeoutSeconds)
Creates an InactivityConversationCanceller.- Parameters:
plugin
- The owning plugin.timeoutSeconds
- The number of seconds of inactivity to wait.
-
-
Method Detail
-
setConversation
public void setConversation(@NotNull @NotNull Conversation conversation)
Description copied from interface:ConversationCanceller
Sets the conversation this ConversationCanceller can optionally cancel.- Specified by:
setConversation
in interfaceConversationCanceller
- Parameters:
conversation
- A conversation.
-
cancelBasedOnInput
public boolean cancelBasedOnInput(@NotNull @NotNull ConversationContext context, @NotNull @NotNull String input)
Description copied from interface:ConversationCanceller
Cancels a conversation based on user input.- Specified by:
cancelBasedOnInput
in interfaceConversationCanceller
- Parameters:
context
- Context information about the conversation.input
- The input text from the user.- Returns:
- True to cancel the conversation, False otherwise.
-
clone
@NotNull public @NotNull ConversationCanceller clone()
Description copied from interface:ConversationCanceller
Allows theConversationFactory
to duplicate this ConversationCanceller when creating a newConversation
.Implementing this method should reset any internal object state.
- Specified by:
clone
in interfaceConversationCanceller
- Overrides:
clone
in classObject
- Returns:
- A clone.
-
cancelling
protected void cancelling(@NotNull @NotNull Conversation conversation)
Subclasses of InactivityConversationCanceller can override this method to take additional actions when the inactivity timer abandons the conversation.- Parameters:
conversation
- The conversation being abandoned.
-
-