Class GameplayManager
java.lang.Object
at.setup_studios.mc_milsim.gameplay.GameplayManager
The GameplayManager class manages the coordination, assignment, and interaction
of players and teams within the game. It provides methods for team creation,
player management, and team-player relationships.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddPlayerToTeam(ModPlayer player, Team newTeam) Adds a player to a specified team, handling their removal from any previous team.static voidcreateTeam(String name, int maxPlayers, net.minecraft.ChatFormatting color) Creates a new team with specified parameters.static voiddeleteTeam(Team team) Deletes a team and properly handles removal of all its players.static ModPlayergetPlayerObject(net.minecraft.server.level.ServerPlayer player) Retrieves the ModPlayers object associated with a ServerPlayer.Gets the list of all teams in the game.static voidonPlayerJoin(net.minecraft.server.level.ServerPlayer player) Handles player join event by creating a new ModPlayers object and assigning them to a team.static voidonPlayerLeave(net.minecraft.server.level.ServerPlayer player) Handles player leave event by removing them from their team and the player list.static voidremovePlayerFromTeam(ModPlayer player) Removes a player from their current team.static TeamteamWithLowestCount(ArrayList<Team> teamList) Finds the team with the lowest number of players.
-
Method Details
-
getPlayerObject
Retrieves the ModPlayers object associated with a ServerPlayer.- Parameters:
player- The ServerPlayer to get the ModPlayers object for- Returns:
- The associated ModPlayers object, or null if not found
-
onPlayerJoin
public static void onPlayerJoin(net.minecraft.server.level.ServerPlayer player) Handles player join event by creating a new ModPlayers object and assigning them to a team.- Parameters:
player- The ServerPlayer who joined the game
-
onPlayerLeave
public static void onPlayerLeave(net.minecraft.server.level.ServerPlayer player) Handles player leave event by removing them from their team and the player list.- Parameters:
player- The ServerPlayer who left the game
-
teamWithLowestCount
-
addPlayerToTeam
-
removePlayerFromTeam
Removes a player from their current team.- Parameters:
player- The player to remove from their team
-
getTeamList
-
createTeam
Creates a new team with specified parameters.- Parameters:
name- The name of the teammaxPlayers- Maximum number of players allowed in the teamcolor- ChatFormatting color for the team
-
deleteTeam
Deletes a team and properly handles removal of all its players.- Parameters:
team- The team to delete
-