Add only_list_players_in_same_group option (true by default)

This commit is contained in:
William 2023-03-23 22:14:31 +00:00
parent 6007cdddb3
commit dbf5509a9a
No known key found for this signature in database
2 changed files with 10 additions and 2 deletions

View File

@ -49,6 +49,11 @@ public class Settings {
@YamlComment("The formats to use for the fallback group.") @YamlComment("The formats to use for the fallback group.")
private String fallbackGroup = "default"; private String fallbackGroup = "default";
@Getter
@YamlKey("only_list_players_in_same_group")
@YamlComment("Only show other players on a server that is part of the same server group as the player.")
private boolean onlyListPlayersInSameGroup = true;
@YamlKey("enable_papi_hook") @YamlKey("enable_papi_hook")
private boolean enablePapiHook = true; private boolean enablePapiHook = true;

View File

@ -73,9 +73,12 @@ public class PlayerTabList {
final Map<String, String> playerRoles = new HashMap<>(); final Map<String, String> playerRoles = new HashMap<>();
for (TabPlayer player : players) { for (TabPlayer player : players) {
if (serversInGroup.isPresent() && !serversInGroup.get().contains(player.getServerName())) { // Skip players on other servers if the setting is enabled
continue; // Skip players on other servers if (plugin.getSettings().isOnlyListPlayersInSameGroup() && serversInGroup.isPresent()
&& !serversInGroup.get().contains(player.getServerName())) {
continue;
} }
playerRoles.put(player.getPlayer().getUsername(), player.getTeamName(plugin)); playerRoles.put(player.getPlayer().getUsername(), player.getTeamName(plugin));
tabList.getEntries().stream() tabList.getEntries().stream()
.filter(e -> e.getProfile().getId().equals(player.getPlayer().getUniqueId())).findFirst() .filter(e -> e.getProfile().getId().equals(player.getPlayer().getUniqueId())).findFirst()