mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-03 09:30:17 +01:00
Added Island#getMemberSet(int, boolean) to specify if we want only the specific rank or the above ranks included
This commit is contained in:
parent
f41359ce4d
commit
a045ea1a8e
@ -246,7 +246,7 @@ public class Island implements DataObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the members of this island.
|
* Returns the members of this island.
|
||||||
* It contains all players that have any rank on this island, including {@link RanksManager#BANNED},
|
* It contains all players that have any rank on this island, including {@link RanksManager#BANNED_RANK BANNED},
|
||||||
* {@link RanksManager#TRUSTED_RANK TRUSTED}, {@link RanksManager#MEMBER_RANK MEMBER}, {@link RanksManager#SUB_OWNER_RANK SUB_OWNER},
|
* {@link RanksManager#TRUSTED_RANK TRUSTED}, {@link RanksManager#MEMBER_RANK MEMBER}, {@link RanksManager#SUB_OWNER_RANK SUB_OWNER},
|
||||||
* {@link RanksManager#OWNER_RANK OWNER}, etc.
|
* {@link RanksManager#OWNER_RANK OWNER}, etc.
|
||||||
*
|
*
|
||||||
@ -265,22 +265,40 @@ public class Island implements DataObject {
|
|||||||
* @see #getMembers()
|
* @see #getMembers()
|
||||||
*/
|
*/
|
||||||
public ImmutableSet<UUID> getMemberSet(){
|
public ImmutableSet<UUID> getMemberSet(){
|
||||||
return (getMemberSet(RanksManager.MEMBER_RANK));
|
return getMemberSet(RanksManager.MEMBER_RANK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an immutable set containing the UUIDs of players with rank above that requested rank inclusive
|
* Returns an immutable set containing the UUIDs of players with rank above that requested rank inclusive
|
||||||
* @param minimumRank - minimum rank (inclusive) of members
|
* @param minimumRank minimum rank (inclusive) of members
|
||||||
* @return immutable set of UUIDs
|
* @return immutable set of UUIDs
|
||||||
* @see #getMembers()
|
* @see #getMembers()
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public @NonNull ImmutableSet<UUID> getMemberSet(@NonNull int minimumRank) {
|
public @NonNull ImmutableSet<UUID> getMemberSet(int minimumRank) {
|
||||||
Builder<UUID> result = new ImmutableSet.Builder<>();
|
Builder<UUID> result = new ImmutableSet.Builder<>();
|
||||||
members.entrySet().stream().filter(e -> e.getValue() >= minimumRank).map(Map.Entry::getKey).forEach(result::add);
|
members.entrySet().stream().filter(e -> e.getValue() >= minimumRank).map(Map.Entry::getKey).forEach(result::add);
|
||||||
return result.build();
|
return result.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an immutable set containing the UUIDs of players with rank equal or above that requested rank (inclusive).
|
||||||
|
* @param rank rank to request
|
||||||
|
* @param includeAboveRanks whether including players with rank above the requested rank or not
|
||||||
|
* @return immutable set of UUIDs
|
||||||
|
* @see #getMemberSet(int)
|
||||||
|
* @see #getMembers()
|
||||||
|
* @since 1.5.0
|
||||||
|
*/
|
||||||
|
public @NonNull ImmutableSet<UUID> getMemberSet(int rank, boolean includeAboveRanks) {
|
||||||
|
if (includeAboveRanks) {
|
||||||
|
return getMemberSet(rank);
|
||||||
|
}
|
||||||
|
Builder<UUID> result = new ImmutableSet.Builder<>();
|
||||||
|
members.entrySet().stream().filter(e -> e.getValue() == rank).map(Map.Entry::getKey).forEach(result::add);
|
||||||
|
return result.build();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the minProtectedX
|
* @return the minProtectedX
|
||||||
*/
|
*/
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package world.bentobox.bentobox.lists;
|
package world.bentobox.bentobox.lists;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.placeholders.GameModePlaceholderReplacer;
|
import world.bentobox.bentobox.api.placeholders.GameModePlaceholderReplacer;
|
||||||
import world.bentobox.bentobox.managers.RanksManager;
|
|
||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
@ -49,7 +48,7 @@ public enum GameModePlaceholder {
|
|||||||
* Displays the amount of players that are at least MEMBER on this island.
|
* Displays the amount of players that are at least MEMBER on this island.
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
ISLAND_MEMBERS_COUNT("island_members_count", (addon, user, island) -> island == null ? "" : String.valueOf(island.getMemberSet(RanksManager.MEMBER_RANK).size())),
|
ISLAND_MEMBERS_COUNT("island_members_count", (addon, user, island) -> island == null ? "" : String.valueOf(island.getMemberSet().size())),
|
||||||
/**
|
/**
|
||||||
* Displays the amount of players that are currently visiting the island.
|
* Displays the amount of players that are currently visiting the island.
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
|
Loading…
Reference in New Issue
Block a user