Created
September 1, 2014 23:24
-
-
Save DarkSeraphim/54f47a47becdcc8110dc to your computer and use it in GitHub Desktop.
Callbacks in Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public abstract class Callback<T> | |
| { | |
| public abstract void execute(T result); | |
| public final void call(Plugin plugin, T result) | |
| { | |
| if(Bukkit.isPrimaryThread()) | |
| { | |
| this.execute(result); | |
| return; | |
| } | |
| new BukkitRunnable() | |
| { | |
| @Override | |
| public void run() | |
| { | |
| Callback.this.execute(result); | |
| } | |
| }.runTask(plugin); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment