Skip to content

Instantly share code, notes, and snippets.

@WesJD
Created March 29, 2016 01:53
Show Gist options
  • Save WesJD/66f9384cc9757cac23bf to your computer and use it in GitHub Desktop.
Save WesJD/66f9384cc9757cac23bf to your computer and use it in GitHub Desktop.
Easy announcements.
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