remove players from closed game, on update

This commit is contained in:
Chiss 2014-10-11 20:30:40 +11:00
parent 961163c135
commit a2df64787f

View File

@ -91,6 +91,7 @@ public class UHC extends TeamGame
private long _createTime;
private long _serverTime;
private boolean _joinable = false;
private boolean _ended = false;
private boolean xrayDebug = false;
@ -1123,7 +1124,7 @@ public class UHC extends TeamGame
}
@EventHandler
public void setJoinable(UpdateEvent event)
public void returnToHub(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
@ -1145,25 +1146,23 @@ public class UHC extends TeamGame
}
@EventHandler
public void playerJoinable(final PlayerJoinEvent event)
public void kickPlayers(UpdateEvent event)
{
if (!_joinable || GetState() != GameState.Recruit)
if (event.getType() != UpdateType.SEC)
return;
if (!_ended)
if (_joinable)
return;
for (final Player player : UtilServer.getPlayers())
{
UtilPlayer.message(event.getPlayer(), " ");
UtilPlayer.message(event.getPlayer(), C.cGold + C.Bold + "This UHC game is not joinable yet!");
UtilPlayer.message(event.getPlayer(), " ");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cGold + C.Bold + "This UHC game is closed!");
UtilPlayer.message(player, " ");
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f);
Bukkit.getScheduler().runTaskLater(Manager.GetPlugin(), new Runnable()
{
@Override
public void run()
{
Manager.GetPortal().SendPlayerToServer(event.getPlayer(), "Lobby");
}
} , 5);
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f);
Manager.GetPortal().SendPlayerToServer(player, "Lobby");
}
}
@ -1220,7 +1219,7 @@ public class UHC extends TeamGame
}
@EventHandler(priority = EventPriority.MONITOR)
public void returnToLobby(final GameStateChangeEvent event)
public void setEnded(final GameStateChangeEvent event)
{
if (!Manager.IsRewardItems())
return;
@ -1232,15 +1231,7 @@ public class UHC extends TeamGame
{
public void run()
{
for (Player player : UtilServer.getPlayers())
{
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cGold + C.Bold + "This UHC game has ended!");
UtilPlayer.message(player, " ");
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f);
Manager.GetPortal().SendPlayerToServer(player, "Lobby");
}
_ended = true;
}
}, 360);
//Delay 18 Seconds