Display waiting blocktext

This commit is contained in:
Sam 2018-07-03 17:09:48 +01:00 committed by Alexander Meech
parent fc94432cf5
commit 5c2d9ce4d4
5 changed files with 54 additions and 9 deletions

View File

@ -537,7 +537,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
}
else if (_gameCreationManager.getVotingManager().isVoteInProgress())
{
scoreboard.setSidebarName(C.cGreenB + "Vote ends in " + _gameCreationManager.getVotingManager().getCurrentVote().getTimer());
scoreboard.setSidebarName(C.Bold + "Vote ends in " + C.cGreenB + _gameCreationManager.getVotingManager().getCurrentVote().getTimer());
}
else
{
@ -1021,7 +1021,18 @@ public class ArcadeManager extends MiniPlugin implements IRelation
}
}
String extrainformation = "|" + _serverConfig.ServerType + "|" + (_game == null ? "Unknown" : _game.GetName()) + "|" + ((_game == null || _game.WorldData == null) ? "Unknown" : _game.WorldData.MapName);
String map = "Unknown";
if (_gameCreationManager.getVotingManager().isVoteInProgress())
{
map = "Voting";
}
else if (_game != null && _game.WorldData != null)
{
map = _game.WorldData.MapName;
}
String extrainformation = "|" + _serverConfig.ServerType + "|" + (_game == null ? "Unknown" : _game.GetName()) + "|" + map;
if (_gameHostManager.isPrivateServer() && _gameHostManager.hasPermission(Perm.FEATURED_SERVER))
{

View File

@ -185,9 +185,9 @@ public class GameCreationManager implements Listener
{
return;
}
else
else if (!Manager.GetServerConfig().MapVoting && !Manager.GetServerConfig().GameVoting || _votingManager.canStartVote())
{
System.out.println("Next Game Preference" + _nextGame);
System.out.println("Next Game Preference: " + _nextGame);
System.out.println("Map Preference: " + MapPref);
System.out.println("Gamemode Preference: " + ModePref);
}
@ -204,6 +204,11 @@ public class GameCreationManager implements Listener
// If game voting is enabled
if (Manager.GetServerConfig().GameVoting)
{
if (!_votingManager.canStartVote())
{
return;
}
List<GameType> typesToVote = new ArrayList<>(Manager.GetGameList());
// Don't let the game that was just played appear
@ -251,6 +256,11 @@ public class GameCreationManager implements Listener
// Also need to make sure a map and game haven't been selected by /game set beforehand
if (MapPref == null && _nextGame == null && Manager.GetServerConfig().MapVoting && !Manager.GetServerConfig().GameVoting)
{
if (!_votingManager.canStartVote())
{
return;
}
_nextGame = gameType;
_votingManager.callVote(new MapVote(Manager, gameType, getMapsToVote(gameType)));
return;

View File

@ -293,7 +293,7 @@ public class GameManager implements Listener
if (game.GetCountdown() != -1 && validPlayers < Manager.GetPlayerMin() && !game.GetCountdownForce())
{
game.SetCountdown(-1);
Manager.GetLobby().DisplayWaiting();
Manager.GetLobby().displayWaiting(false);
}
if (Manager.IsGameAutoStart())

View File

@ -393,7 +393,7 @@ public abstract class LobbyManager implements Listener
if (_manager.GetGame().GetMode() == null)
{
writeGameLine(" ", 1, 159, (byte) 1);
writeGameLine("", 1, Material.AIR.getId(), (byte) 0);
}
else
{
@ -402,7 +402,7 @@ public abstract class LobbyManager implements Listener
UtilServer.getPlayersCollection().forEach(this::equipActiveKit);
DisplayWaiting();
displayWaiting(false);
createKits(game);
writeTeamLine("Select", 0, 159, (byte) 15);
@ -426,8 +426,16 @@ public abstract class LobbyManager implements Listener
createTeams(game);
}
public void DisplayWaiting()
public void displayWaiting(boolean forVote)
{
if (forVote)
{
for (int i = 0; i < 3; i++)
{
writeGameLine("", i, Material.AIR.getId(), (byte) 0);
}
}
writeGameLine("waiting for players", 3, 159, (byte) 13);
}

View File

@ -46,7 +46,7 @@ public class VotingManager extends ListenerComponent implements Lifetimed
private final SimpleLifetime _lifetime;
private Vote<?> _currentVote, _finishedVote;
private boolean _colourTick;
private boolean _colourTick, _waitingForPlayers;
public VotingManager(ArcadeManager manager)
{
@ -73,6 +73,7 @@ public class VotingManager extends ListenerComponent implements Lifetimed
player.getInventory().setItem(0, _currentVote.getItemStack());
}
_waitingForPlayers = false;
_manager.GetLobby().displayVoting(vote);
activate();
@ -222,6 +223,21 @@ public class VotingManager extends ListenerComponent implements Lifetimed
return _currentVote != null;
}
public boolean canStartVote()
{
if (_manager.getValidPlayersForGameStart().size() < _manager.GetPlayerMin())
{
if (!_waitingForPlayers)
{
_waitingForPlayers = true;
_manager.GetLobby().displayWaiting(true);
}
return false;
}
return true;
}
@Override
public Lifetime getLifetime()
{