Created
February 23, 2014 03:15
-
-
Save avafloww/9166315 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.forairan.bukkit.test.conversationcrash; | |
import org.bukkit.conversations.Conversation; | |
import org.bukkit.conversations.ConversationAbandonedEvent; | |
import org.bukkit.conversations.ConversationAbandonedListener; | |
import org.bukkit.conversations.ConversationContext; | |
import org.bukkit.conversations.ConversationFactory; | |
import org.bukkit.conversations.NullConversationPrefix; | |
import org.bukkit.conversations.Prompt; | |
import org.bukkit.event.EventHandler; | |
import org.bukkit.event.Listener; | |
import org.bukkit.event.player.PlayerJoinEvent; | |
import org.bukkit.plugin.java.JavaPlugin; | |
/** | |
* | |
*/ | |
public class CrashTestPlugin extends JavaPlugin implements Listener { | |
@Override | |
public void onEnable() { | |
getServer().getPluginManager().registerEvents(this, this); | |
} | |
@EventHandler | |
public void onJoin(PlayerJoinEvent event) { | |
Conversation conv = new ConversationFactory(this) | |
.withFirstPrompt(new Prompt() { | |
public String getPromptText(ConversationContext cc) { | |
return "Conversation started. Disconnect now and watch the server console."; | |
} | |
public boolean blocksForInput(ConversationContext cc) { | |
return true; | |
} | |
public Prompt acceptInput(ConversationContext cc, String string) { | |
return this; | |
} | |
}) | |
.withPrefix(new NullConversationPrefix()) | |
.addConversationAbandonedListener(new ConversationAbandonedListener() { | |
public void conversationAbandoned(ConversationAbandonedEvent cae) { | |
throw new RuntimeException("Exception test in ConversationAbandonedEvent"); | |
} | |
}) | |
.buildConversation(event.getPlayer()); | |
conv.begin(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment