코드에이 문제가 있습니다. 내가 온라인으로 게임을 시작할 때 게임이 정상적으로 시작되고 카운트 다운이 멈추지 만 두 명 이상의 플레이어가 온라인 상태 일 때 게임이 시작되지 않고 하나의 플레이어 만 온라인 상태 였다면 카운트 다운이 시작됩니다. 결론이있는 사람은 누구입니까?카운트 다운이 중지되고 필요한 플레이어가 온라인 상태 일 때 게임을 시작합니다.
내 코드 :
@Override
public void run() {
if (timeUntilStart == 0) {
if (!Game.canStart()) {
if(Bukkit.getOnlinePlayers().size() <= 2) {
plugin.restartCountdown();
ChatUtilities.broadcast(ChatColor.RED + "Not enough players to start. Countdown will");
ChatUtilities.broadcast(ChatColor.RED + "restart.");
for (Player p : Bukkit.getOnlinePlayers()) p.playSound(p.getLocation(), Sound.ENDERDRAGON_WINGS, 5, 1);
}else{
if(Game.canStart()) {
if(Bukkit.getOnlinePlayers().size() >= 2) {
Game.start();
}
}
}
}
}
boolean broadcast = false;
for (Player p : Bukkit.getOnlinePlayers()) {
p.setLevel(timeUntilStart);
if (timeUntilStart < 6 || timeUntilStart == 10 || timeUntilStart == 120 ||timeUntilStart == 60 || timeUntilStart == 30) {
p.playSound(p.getLocation(), Sound.ORB_PICKUP, 5, 0);
if (timeUntilStart == 0) p.playSound(p.getLocation(), Sound.ZOMBIE_INFECT , 5, 1);
broadcast = true;
}
}
if (broadcast) ChatUtilities.broadcast(String.valueOf(timeUntilStart) + " §3Seconds until the game starts!");
{
}
timeUntilStart -= 1;
if (timeUntilStart < 0) {timeUntilStart = 0;
if(Bukkit.getOnlinePlayers().size() <= 2) {
plugin.restartCountdown();
}else{
if(Bukkit.getOnlinePlayers().size() >= 2) {
Game.start();
}
}
}
}
}
'if (Bukkit.getOnlinePlayers(). size() <= 2) {plugin.restartCountdown();을 사용하십시오. }'- 이것이 (Bukkit.getOnlinePlayers(). size() <= 1)'이면 안된다? – Pokechu22