Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. public void doAsyncQuery(final CallBack<HashMap> callBack, final Player p) {
  2. Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
  3. @Override
  4. public void run() {
  5. final HashMap<String, String> result = new HashMap<String, String>();
  6.  
  7. result.put("test", "data1");
  8. result.put("test1", "data2");
  9.  
  10. Bukkit.getScheduler().runTask(plugin, new Runnable() {
  11. @Override
  12. public void run() {
  13. @Override
  14. public void run() {
  15. callBack.onSuccess(result);
  16. }
  17. }
  18. });
  19. }
  20. });
  21. }
  22.  
  23. public interface CallBack<T> {
  24. void onSuccess(T done);
  25. void onFailure(Throwable cause);
  26. }
  27.  
  28. doAsyncQuery(new CallBack<HashMap>() {
  29.  
  30. @Override
  31. public void onSuccess(HashMap done) {
  32. System.out.println(done.get("test"));
  33. System.out.println(done.get("test2"));
  34. }
  35.  
  36. @Override
  37. public void onFailure(Throwable cause) {
  38. System.out.println("ERROR: LOADING ASYNC MYSQL DATA");
  39. }
  40.  
  41. }, p);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement