Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void doAsyncQuery(final CallBack<HashMap> callBack) {
- Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
- @Override
- public void run() {
- final HashMap<String, String> result = new HashMap<String, String>();
- /* ICI TES METHODES DE RECUPERATIONS */
- result.put("test", "data1");
- result.put("test1", "data2");
- Bukkit.getScheduler().runTask(plugin, new Runnable() {
- @Override
- public void run() {
- @Override
- public void run() {
- callBack.onSuccess(result);
- }
- }
- });
- }
- });
- }
- public interface CallBack<T> {
- void onSuccess(T done);
- void onFailure(Throwable cause);
- }
- doAsyncQuery(new CallBack<HashMap>() {
- @Override
- public void onSuccess(HashMap done) {
- System.out.println(done.get("test"));
- System.out.println(done.get("test2"));
- }
- @Override
- public void onFailure(Throwable cause) {
- System.out.println("ERROR: LOADING ASYNC MYSQL DATA");
- }
- }, p);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement