Skip to content

Commit

Permalink
refactor: move hasTeamRank() to OnlineUser for better access (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
Snabeldier authored Jan 19, 2025
1 parent 5904e89 commit c77ff75
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
27 changes: 18 additions & 9 deletions src/main/java/minevalley/core/api/users/OnlineUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import minevalley.core.api.users.enums.Fraction;
import minevalley.core.api.users.enums.McVersion;
import minevalley.core.api.users.enums.TabListView;
import minevalley.core.api.users.enums.TeamRank;
import minevalley.core.api.users.exceptions.UserNotPermittedException;
import minevalley.core.api.utils.ChatHandler;
import minevalley.core.api.utils.ClickableMessage;
Expand Down Expand Up @@ -179,25 +180,33 @@ default void closeInventory() {
*/
void leaveFractionService() throws IllegalStateException;

// TeamRank
/**
* Gets if the player has any type of team-rank.
*
* @return true, if the user is part of the server-team (and in team-service)
*/
@Contract(pure = true)
boolean isTeamler();

/**
* Gets whether the user has any of the listed team-ranks.
*
* @param ranks list of team-ranks to be checked for
* @return true, if the user has one of the ranks
*/
@Contract(pure = true)
boolean hasTeamRank(@Nonnull TeamRank... ranks);

/**
* Gets the team-member object of this user.
*
* @return team-member object
* @throws UserNotPermittedException if the user is no team-member
* @see #isTeamler()
*/
@Nonnull
TeamMember team() throws UserNotPermittedException;

/**
* Gets if the player has any type of team-rank.
*
* @return true, if the user is part of the server-team (and in team-service)
*/
@Contract(pure = true)
boolean isTeamler();

/**
* Lets the user enter the team-service. If the user isn't teamler, nothing happens.
*/
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/minevalley/core/api/users/TeamMember.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ public interface TeamMember extends OnlineUser {
@Contract(pure = true)
boolean isDisplayedAsTeamler();

/**
* Gets whether the user has any of the listed team-ranks.
*
* @param ranks list of team-ranks to be checked for
* @return true, if the user has one of the ranks
*/
@Contract(pure = true)
boolean hasTeamRank(@Nonnull TeamRank... ranks);

/**
* Gets whether the user is allowed to use a general-key
*
Expand Down

0 comments on commit c77ff75

Please sign in to comment.