UHPlugin
UHPlugin copied to clipboard
Add a random team generator
/uh team generate → doc
/uh team generate players <numberOfPlayersPerTeam> [flags]
/uh team random teams <numberOfTeams> [flags]
Where the flags are the following.
-
reset
: if present, the teams/players in teams are reset and the teams are completely random. Without, only players out of any team are affected; -
fancyNames
: if present, generates a name for the team, based on a list of worlds in theplugins/UHPlugin/
directory. Without, the names are «<color> <random number>
» (or only the color, if the name is available). -
noColors
: if present, all teams will be white teams. Without, a random color is chosen.
Dev's point of view: something like this.
/**
* Generates teams.
*
* @param type The way the teams are generated.
* @param count The number of player per team or the number of teams, following the generation type.
* @param reset If {@code true}, the teams/players in teams are reset and the teams are completely random. Else, only players out of any team are affected.
* @param fancyNames If {@code true}, generates a name for the team, based on a list of worlds in the `plugins/UHPlugin/` directory. Else, the names are « {color} {random number} » (or only the color, if the name is available).
* @param noColors If {@code true}, all teams will be white teams. Else, a random color is chosen.
*
* @return A list of the new teams.
*/
List<UHTeam> UHTeamManager.generate(TeamGenerationType type, int count, boolean reset, boolean fancyNames, boolean noColors);
public enum TeamGenerationType {
/**
* Given the number of players per team, this will creates the teams needed and
* adds the players in the teams to respect this count.
*
* There may be a team with less players in it, if a perfect generation is not possible.
*/
PLAYERS_IN_TEAMS,
/**
* Given the number of teams, this will creates the teams needed and
* divides the players in these teams.
*
* There may be a team with less players in it, if a perfect generation is not possible.
*/
TEAMS_FOR_PLAYERS;
}
Can we have this in the api and with another option to only randomize the players that have not currently joined a team.
with another option to only randomize the players that have not currently joined a team.
Good idea, I'll add this feature.
By the way, all these generators will be available through the API.
I added the API I'll probably use in the description of the issue.
This will be moved on the next version, because it's a nontrivial component with tests and I want to release a stable version :p .
This will be one of the first things I'll do in the 1.4.
This will be one of the first things I'll do in the 1.4.
That's what he said.
s/1.4/1.6/
In addition to the above, it would be a good idea to add configuration options so the teams are automatically generated when the game starts.