Skip to content

Instantly share code, notes, and snippets.

@DarkSeraphim
Created September 1, 2014 23:24
Show Gist options
  • Save DarkSeraphim/54f47a47becdcc8110dc to your computer and use it in GitHub Desktop.
Save DarkSeraphim/54f47a47becdcc8110dc to your computer and use it in GitHub Desktop.
Callbacks in Java
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