Skip to content

Commit

Permalink
Allow /nicks to be used by all players and display player nicknames
Browse files Browse the repository at this point in the history
Signed-off-by: William Jeffcock <[email protected]>
  • Loading branch information
dentmaged committed Feb 5, 2024
1 parent d1b7514 commit 90cdb15
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import net.kyori.adventure.text.format.TextDecoration;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import tc.oc.pgm.api.integration.Integration;
import tc.oc.pgm.lib.cloud.commandframework.annotations.Argument;
import tc.oc.pgm.lib.cloud.commandframework.annotations.CommandDescription;
import tc.oc.pgm.lib.cloud.commandframework.annotations.CommandMethod;
Expand Down Expand Up @@ -386,12 +387,13 @@ public void enableNick(CommandAudience viewer, Player sender) {
@ProxiedBy("nicks")
@CommandMethod("list")
@CommandDescription("View a list of online nicked players")
@CommandPermission(CommunityPermissions.STAFF)
public void viewNicks(CommandAudience viewer) {
boolean staff = viewer.hasPermission(CommunityPermissions.STAFF);
List<Component> nickedNames =
Bukkit.getOnlinePlayers().stream()
.filter(player -> staff || Integration.isFriend(player, viewer.getPlayer()))
.filter(player -> nicks.isNicked(player.getUniqueId()))
.map(player -> PlayerComponent.player(player, NameStyle.FANCY))
.map(player -> PlayerComponent.player(player, NameStyle.VERBOSE))
.collect(Collectors.toList());

if (nickedNames.isEmpty()) {
Expand Down

0 comments on commit 90cdb15

Please sign in to comment.