Created
March 29, 2016 01:53
-
-
Save WesJD/66f9384cc9757cac23bf to your computer and use it in GitHub Desktop.
Easy announcements.
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
public class Announcer { | |
private final String[] announcements; | |
private final int secondsBetween; | |
private BukkitTask announcementTask; | |
public Announcer(int secondsBetween, String... announcements) { | |
this.secondsBetween = secondsBetween; | |
this.announcements = announcements; | |
run(); | |
} | |
public void run() { | |
announcementTask = new BukkitRunnable() { | |
int last = 0; | |
public void run() { | |
Bukkit.broadcastMessage(announcements[last++]); | |
if(last == announcements.length) last = 0; | |
} | |
}.runTaskTimer(BSCore.getInstance(), 20L, 20L * secondsBetween); | |
} | |
public void cancel() { | |
announcementTask.cancel(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment