Skip to content

Commit

Permalink
[UPDATE] Changed List<> to ArrayList<>. Removed the exception NotInTe…
Browse files Browse the repository at this point in the history
…amException.
  • Loading branch information
nl1x committed Feb 10, 2024
1 parent 68f8862 commit c834074
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions src/fr/hashktek/spigot/hashboard/HashTeam.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
package fr.hashktek.spigot.hashboard;

import fr.hashktek.spigot.hashboard.exceptions.AlreadyInTeamException;
import fr.hashktek.spigot.hashboard.exceptions.NotInTeamException;
import fr.hashktek.spigot.hashboard.exceptions.StrangeException;
import fr.hashktek.spigot.hashboard.exceptions.TeamSizeException;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Team;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public class HashTeam
{

private Team boardTeam;

private final List<UUID> playersUUID;
private final ArrayList<UUID> playersUUID;

private final String tablistPriority;

Expand Down Expand Up @@ -71,9 +69,9 @@ public void add(Player player) throws AlreadyInTeamException, TeamSizeException,
{
UUID playerUUID = player.getUniqueId();

if (playersUUID.size() == teamSize)
if (this.getLength() == teamSize)
throw new TeamSizeException("The team '" + this.tablistPriority + "' is full.");
else if (playersUUID.size() > teamSize)
else if (this.getLength() > teamSize)
throw new StrangeException("The team '" + this.tablistPriority + "' is more than full. (WTF ?)");

if (this.has(playerUUID))
Expand All @@ -88,19 +86,13 @@ else if (playersUUID.size() > teamSize)
/**
* Remove a player from the team.
* @param player The player to remove from the team.
* @throws NotInTeamException If the player is not in the team.
*/
public void remove(Player player) throws NotInTeamException
public void remove(Player player)
{
UUID playerUUID = player.getUniqueId();

if (!this.has(playerUUID))
throw new NotInTeamException(
"The player with UUID '" + playerUUID + "' is not in the team."
);

this.playersUUID.remove(playerUUID);
this.boardTeam.removeEntry(player.getName());
if (this.playersUUID.remove(playerUUID))
this.boardTeam.removeEntry(player.getName());
}

/**
Expand Down Expand Up @@ -136,7 +128,7 @@ public void setBoard(HashBoard board)
* Get the UUID of the players present in the team.
* @return The list of UUID of the players present in the team.
*/
public List<UUID> getPlayersUUID()
public ArrayList<UUID> getPlayersUUID()
{
return this.playersUUID;
}
Expand Down

0 comments on commit c834074

Please sign in to comment.