mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2025-02-17 21:02:12 +01:00
Added timer to ready signs
This commit is contained in:
parent
d8b128f013
commit
1ddf0df88a
@ -22,13 +22,15 @@ import io.github.dre2n.dungeonsxl.game.Game;
|
||||
import io.github.dre2n.dungeonsxl.game.GameType;
|
||||
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
||||
import io.github.dre2n.dungeonsxl.util.ProgressBar;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import io.github.dre2n.itemsxl.util.commons.util.NumberUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
/**
|
||||
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
||||
@ -38,6 +40,7 @@ public class ReadySign extends DSign {
|
||||
private DSignType type = DSignTypeDefault.READY;
|
||||
|
||||
private GameType gameType;
|
||||
private double autoStart = -1;
|
||||
|
||||
public ReadySign(Sign sign, String[] lines, GameWorld gameWorld) {
|
||||
super(sign, lines, gameWorld);
|
||||
@ -58,6 +61,21 @@ public class ReadySign extends DSign {
|
||||
this.gameType = gameType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the time until the game starts automatically; -1 for no auto start
|
||||
*/
|
||||
public double getTimeToAutoStart() {
|
||||
return autoStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param time
|
||||
* the time in seconds until the game starts automatically; -1 for no auto start
|
||||
*/
|
||||
public void setTimeToAutoStart(double time) {
|
||||
autoStart = time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check() {
|
||||
return true;
|
||||
@ -72,6 +90,10 @@ public class ReadySign extends DSign {
|
||||
gameType = GameTypeDefault.DEFAULT;
|
||||
}
|
||||
|
||||
if (!lines[2].isEmpty()) {
|
||||
autoStart = NumberUtil.parseDouble(lines[2], -1);
|
||||
}
|
||||
|
||||
if (!getTriggers().isEmpty()) {
|
||||
getSign().getBlock().setType(Material.AIR);
|
||||
return;
|
||||
@ -93,15 +115,25 @@ public class ReadySign extends DSign {
|
||||
@Override
|
||||
public boolean onPlayerTrigger(Player player) {
|
||||
ready(DGamePlayer.getByPlayer(player));
|
||||
|
||||
if (autoStart >= 0) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
onTrigger();
|
||||
}
|
||||
}.runTaskLater(plugin, (long) (autoStart * 20));
|
||||
|
||||
ProgressBar.sendProgressBar(getGame().getPlayers(), (int) Math.ceil(autoStart));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrigger() {
|
||||
for (DGroup dGroup : Game.getByGameWorld(getGameWorld()).getDGroups()) {
|
||||
for (Player player : dGroup.getPlayers()) {
|
||||
ready(DGamePlayer.getByPlayer(player));
|
||||
}
|
||||
for (Player player : Game.getByGameWorld(getGameWorld()).getPlayers()) {
|
||||
ready(DGamePlayer.getByPlayer(player));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user