Last active
April 25, 2020 14:44
-
-
Save deanveloper/06e67ee2d70def256453 to your computer and use it in GitHub Desktop.
Easy way to create runnable stuff in BungeeCord, compatible with lambdas as well.
This file contains 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
//JAVA 8 | |
import net.md_5.bungee.api.ProxyServer; | |
import net.md_5.bungee.api.scheduler.ScheduledTask; | |
import java.util.concurrent.TimeUnit; | |
@FunctionalInterface | |
public interface ProxyRunnable extends Runnable{ | |
default ScheduledTask runAsync(){ | |
return ProxyServer.getInstance().getScheduler().runAsync(<PLUGIN>, this); | |
} | |
default ScheduledTask runAfter(long time, TimeUnit unit){ | |
return ProxyServer.getInstance().getScheduler().schedule(<PLUGIN>, this, time, unit); | |
} | |
default ScheduledTask runAfterEvery(long time, long repeat, TimeUnit unit){ | |
return ProxyServer.getInstance().getScheduler().schedule(<PLUGIN>, this, time, repeat, unit); | |
} | |
} | |
//earlier versions | |
import net.md_5.bungee.api.ProxyServer; | |
import net.md_5.bungee.api.scheduler.ScheduledTask; | |
import java.util.concurrent.TimeUnit; | |
public abstract class ProxyRunnable implements Runnable{ | |
@Override | |
public abstract void run(); | |
public ScheduledTask runAsync(){ | |
return ProxyServer.getInstance().getScheduler().runAsync(<PLUGIN>, this); | |
} | |
public ScheduledTask runAfter(long time, TimeUnit unit){ | |
return ProxyServer.getInstance().getScheduler().schedule(<PLUGIN>, this, time, unit); | |
} | |
public ScheduledTask runAfterEvery(long time, long repeat, TimeUnit unit){ | |
return ProxyServer.getInstance().getScheduler().schedule(<PLUGIN>, this, time, repeat, unit); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment