Initial commit
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package net.crankedpvp.voyages.tasks;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.TimeUtils;
|
||||
import net.crankedpvp.voyages.struct.room.VoyageRoom;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class VoyageRoomTimeLeftTask extends BukkitRunnable {
|
||||
|
||||
private static final List<Integer> WHEN_TO_DISPLAY_TITLE = Arrays.asList(300, 120, 60, 30, 15, 10, 5, 4, 3, 2, 1);
|
||||
private final VoyageRoom<?> voyageRoom;
|
||||
private int timeLeft;
|
||||
|
||||
public VoyageRoomTimeLeftTask(VoyageRoom<?> voyageRoom) {
|
||||
this.timeLeft = voyageRoom.getDurationOfRoomInSeconds();
|
||||
this.voyageRoom = voyageRoom;
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
if (timeLeft == 0) {
|
||||
this.voyageRoom.stopVoyageRoom();
|
||||
this.voyageRoom.nextRoom();
|
||||
return;
|
||||
}
|
||||
|
||||
if (WHEN_TO_DISPLAY_TITLE.contains(timeLeft))
|
||||
this.voyageRoom.sendMessageToAllParticipants("&a&lVoyages &8➥ &7" + TimeUtils.formatSeconds(this.timeLeft) + " left before the end of this room.");
|
||||
|
||||
this.decrementTimeLeft();
|
||||
}
|
||||
|
||||
public void decrementTimeLeft() {
|
||||
this.timeLeft--;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user