Advertisement
riking

Untitled

May 19th, 2014
540
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1.     @Override
  2.     public final Prompt acceptInput(ConversationContext context, String input) {
  3.         // BUKKIT-5611
  4.         if (!Bukkit.isPrimaryThread()) {
  5.             final ConversationContext _context = context;
  6.             final String _input = input;
  7.             Future<Prompt> future = Bukkit.getScheduler().callSyncMethod(KraftRPGPlugin.getInstance(), new Callable<Prompt>() {
  8.                 @Override
  9.                 public Prompt call() throws Exception {
  10.                     return EditorPrompt.this.acceptInput(_context, _input);
  11.                 }
  12.             });
  13.             new RuntimeException("Prompt called from non-main thread!").printStackTrace();
  14.             boolean interrupted = Thread.interrupted();
  15.             Prompt ret = null;
  16.             try {
  17.                 ret = future.get();
  18.             } catch (InterruptedException e) {
  19.                 interrupted = true;
  20.             } catch (ExecutionException e) {
  21.                 e.getCause().printStackTrace();
  22.             }
  23.             if (interrupted) Thread.currentThread().interrupt();
  24.             return ret;
  25.         }
  26.  
  27.         // Existing code here
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement