SHARE
TWEET

Untitled

a guest Oct 21st, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public void doAsyncQuery(final CallBack<HashMap> callBack) {
  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.                 /* ICI TES METHODES DE RECUPERATIONS */
  8.                 result.put("test", "data1");
  9.                 result.put("test1", "data2");
  10.  
  11.                 Bukkit.getScheduler().runTask(plugin, new Runnable() {
  12.                     @Override
  13.                     public void run() {
  14.                         @Override
  15.                         public void run() {
  16.                             callBack.onSuccess(result);
  17.                         }
  18.                     }
  19.                 });
  20.             }
  21.         });
  22.     }
  23.  
  24.     public interface CallBack<T> {
  25.         void onSuccess(T done);
  26.         void onFailure(Throwable cause);
  27.     }
  28.  
  29.     doAsyncQuery(new CallBack<HashMap>() {
  30.  
  31.         @Override
  32.         public void onSuccess(HashMap done) {
  33.             System.out.println(done.get("test"));
  34.             System.out.println(done.get("test2"));
  35.         }
  36.  
  37.         @Override
  38.         public void onFailure(Throwable cause) {
  39.             System.out.println("ERROR: LOADING ASYNC MYSQL DATA");
  40.         }
  41.  
  42.     }, p);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top