Bukkit/CraftBukkit — pull request #1377 by riking (2014-05-14 21:00:39+00:00)
Title: [C] Process conversation input on the main thread. Fixes BUKKIT-5611

### Problem

The thread that the Conversation API is called on is not consistent. When the console sends a message, or another plugin calls `acceptConversationInput()`, the call is made on the main thread. But when a player chats, the call to the Conversation API is made on the network thread.

This inconsistency makes it nearly impossible for plugins to cope, as they do not know whether they should call `Scheduler.callSyncMethod()` or perform the action there -- if `BukkitScheduler.callSyncMethod().get()` is called on the main thread, **the server will deadlock**. That is not an acceptable landmine.

### Breakdown

This PR wraps the call to `Player.acceptConversationInput` in a `Waitable`. As you can see on lines 785-810 of the same file *(click top expansion on the diff twice to see)*, this is the accepted method of running something on the main thread from a network handler.

The extra local variable is required because the `s` variable is not effectively final.

### Testing
https://bukkit.atlassian.net/secure/attachment/20502/TestPlugin.jar
https://bukkit.atlassian.net/secure/attachment/20503/TestPlugin.java

This simple Conversation plugin, after running the command `/enter` to enter a conversation, nicely asks that you type 'yes'. If you don't, it cries.

It also prints out a warning to the player and the console if the `acceptInput()` method is not called on the main thread.

#### Results

- Latest build
- Console: Main thread
- Player: Different thread
- With this change
- Console: Main thread
- Player: Main thread

### JIRA
https://bukkit.atlassian.net/browse/BUKKIT-5611

*(No companion PRs)*