下面列出了怎么用org.bukkit.conversations.Conversation的API类实例代码及写法,或者点击链接到github查看源代码。
@EventHandler
public void onInventoryClick(InventoryClickEvent ev) {
if (ev.getInventory().getName().equals("- Teams -")) {
Player pl = (Player) ev.getWhoClicked();
ev.setCancelled(true);
if (ev.getCurrentItem().getType() == Material.DIAMOND) {
pl.closeInventory();
p.getConversationFactory("teamPrompt").buildConversation(pl).begin();
} else if (ev.getCurrentItem().getType() == Material.BEACON) {
pl.closeInventory();
Conversation c = p.getConversationFactory("playerPrompt").buildConversation(pl);
c.getContext().setSessionData("nomTeam", ChatColor.stripColor(ev.getCurrentItem().getItemMeta().getDisplayName()));
c.getContext().setSessionData("color", p.getTeam(ChatColor.stripColor(ev.getCurrentItem().getItemMeta().getDisplayName())).getChatColor());
c.begin();
}
}
}
synchronized void abandonConversation(Conversation conversation, ConversationAbandonedEvent details) {
if (!this.conversationQueue.isEmpty()) {
if (this.conversationQueue.getFirst() == conversation) {
conversation.abandon(details);
}
if (this.conversationQueue.contains(conversation)) {
this.conversationQueue.remove(conversation);
}
if (!this.conversationQueue.isEmpty()) {
this.conversationQueue.getFirst().outputNextPrompt();
}
}
}
public synchronized boolean beginConversation(Conversation conversation) {
if (!conversationQueue.contains(conversation)) {
conversationQueue.addLast(conversation);
if (conversationQueue.getFirst() == conversation) {
conversation.begin();
conversation.outputNextPrompt();
return true;
}
}
return true;
}
public synchronized void abandonConversation(Conversation conversation, ConversationAbandonedEvent details) {
if (!conversationQueue.isEmpty()) {
if (conversationQueue.getFirst() == conversation) {
conversation.abandon(details);
}
if (conversationQueue.contains(conversation)) {
conversationQueue.remove(conversation);
}
if (!conversationQueue.isEmpty()) {
conversationQueue.getFirst().outputNextPrompt();
}
}
}
public synchronized void abandonAllConversations() {
LinkedList<Conversation> oldQueue = conversationQueue;
conversationQueue = new LinkedList<Conversation>();
for (Conversation conversation : oldQueue) {
try {
conversation.abandon(new ConversationAbandonedEvent(conversation, new ManuallyAbandonedConversationCanceller()));
} catch (Throwable t) {
Bukkit.getLogger().log(Level.SEVERE, "Unexpected exception while abandoning a conversation", t);
}
}
}
public synchronized void acceptConversationInput(String input) {
if (isConversing()) {
Conversation conversation = conversationQueue.getFirst();
try {
conversation.acceptInput(input);
} catch (Throwable t) {
conversation.getContext().getPlugin().getLogger().log(Level.WARNING,
String.format("Plugin %s generated an exception whilst handling conversation input",
conversation.getContext().getPlugin().getDescription().getFullName()
), t);
}
}
}
public synchronized boolean beginConversation(Conversation conversation) {
if (!conversationQueue.contains(conversation)) {
conversationQueue.addLast(conversation);
if (conversationQueue.getFirst() == conversation) {
conversation.begin();
conversation.outputNextPrompt();
return true;
}
}
return true;
}
public synchronized void abandonConversation(Conversation conversation, ConversationAbandonedEvent details) {
if (!conversationQueue.isEmpty()) {
if (conversationQueue.getFirst() == conversation) {
conversation.abandon(details);
}
if (conversationQueue.contains(conversation)) {
conversationQueue.remove(conversation);
}
if (!conversationQueue.isEmpty()) {
conversationQueue.getFirst().outputNextPrompt();
}
}
}
public synchronized void abandonAllConversations() {
LinkedList<Conversation> oldQueue = conversationQueue;
conversationQueue = new LinkedList<Conversation>();
for(Conversation conversation : oldQueue) {
try {
conversation.abandon(new ConversationAbandonedEvent(conversation, new ManuallyAbandonedConversationCanceller()));
} catch (Throwable t) {
Bukkit.getLogger().log(Level.SEVERE, "Unexpected exception while abandoning a conversation", t);
}
}
}
synchronized boolean beginConversation(Conversation conversation) {
if (!this.conversationQueue.contains(conversation)) {
this.conversationQueue.addLast(conversation);
if (this.conversationQueue.getFirst() == conversation) {
conversation.begin();
conversation.outputNextPrompt();
return true;
}
}
return true;
}
public synchronized void abandonAllConversations() {
LinkedList<Conversation> oldQueue = this.conversationQueue;
this.conversationQueue = new LinkedList<>();
for (Conversation conversation : oldQueue) {
try {
conversation.abandon(new ConversationAbandonedEvent(conversation, new ManuallyAbandonedConversationCanceller()));
} catch (Throwable var5) {
Bukkit.getLogger().log(Level.SEVERE, "Unexpected exception while abandoning a conversation", var5);
}
}
}
synchronized void acceptConversationInput(String input) {
if (this.isConversing()) {
Conversation conversation = this.conversationQueue.getFirst();
try {
conversation.acceptInput(input);
} catch (Throwable var4) {
conversation.getContext().getPlugin().getLogger().log(Level.WARNING, String.format("Plugin %s generated an exception whilst handling conversation input", conversation.getContext().getPlugin().getDescription().getFullName()), var4);
}
}
}
@Override
public boolean beginConversation(Conversation conversation) {
return conversationTracker.beginConversation(conversation);
}
@Override
public void abandonConversation(Conversation conversation) {
conversationTracker.abandonConversation(conversation, new ConversationAbandonedEvent(conversation, new ManuallyAbandonedConversationCanceller()));
}
@Override
public void abandonConversation(Conversation conversation, ConversationAbandonedEvent details) {
conversationTracker.abandonConversation(conversation, details);
}
public boolean beginConversation(Conversation conversation) {
return conversationTracker.beginConversation(conversation);
}
public void abandonConversation(Conversation conversation) {
conversationTracker.abandonConversation(conversation, new ConversationAbandonedEvent(conversation, new ManuallyAbandonedConversationCanceller()));
}
public void abandonConversation(Conversation conversation, ConversationAbandonedEvent details) {
conversationTracker.abandonConversation(conversation, details);
}
@Override
public void abandonConversation(Conversation arg0) {
sender.abandonConversation(arg0);
}
@Override
public void abandonConversation(Conversation arg0, ConversationAbandonedEvent arg1) {
sender.abandonConversation(arg0, arg1);
}
@Override
public boolean beginConversation(Conversation arg0) {
return sender.beginConversation(arg0);
}
public boolean beginConversation(Conversation conversation) {
return conversationTracker.beginConversation(conversation);
}
public void abandonConversation(Conversation conversation) {
conversationTracker.abandonConversation(conversation, new ConversationAbandonedEvent(conversation, new ManuallyAbandonedConversationCanceller()));
}
public void abandonConversation(Conversation conversation, ConversationAbandonedEvent details) {
conversationTracker.abandonConversation(conversation, details);
}
public boolean beginConversation(Conversation conversation) {
return conversationTracker.beginConversation(conversation);
}
public void abandonConversation(Conversation conversation) {
conversationTracker.abandonConversation(conversation, new ConversationAbandonedEvent(conversation, new ManuallyAbandonedConversationCanceller()));
}
public void abandonConversation(Conversation conversation, ConversationAbandonedEvent details) {
conversationTracker.abandonConversation(conversation, details);
}
public boolean beginConversation(Conversation conversation) {
return this.conversationTracker.beginConversation(conversation);
}
public void abandonConversation(Conversation conversation) {
this.conversationTracker.abandonConversation(conversation, new ConversationAbandonedEvent(conversation, new ManuallyAbandonedConversationCanceller()));
}
public void abandonConversation(Conversation conversation, ConversationAbandonedEvent details) {
this.conversationTracker.abandonConversation(conversation, details);
}