Skip to content

Commit

Permalink
Improved: AdventureCompatUtil by adding the getUsers method
Browse files Browse the repository at this point in the history
  • Loading branch information
Bram1903 committed Apr 28, 2024
1 parent 1780903 commit d5b8d9c
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;
import java.util.Optional;
import java.util.UUID;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -49,7 +50,7 @@ public void broadcastComponent(Component component, @Nullable String permission)
.map(player -> PacketEvents.getAPI().getPlayerManager().getUser(player))
.forEach(user -> user.sendMessage(component));
} else {
PacketEvents.getAPI().getProtocolManager().getUsers().forEach(user -> user.sendMessage(component));
getUsers().forEach(user -> user.sendMessage(component));
}
}

Expand All @@ -66,6 +67,15 @@ public void sendPlainMessage(CommandSender sender, Component component) {
.trim());
}

/**
* Retrieves a list of Users from the PacketEvents API.
*
* @return a Collection of Users.
*/
private Collection<User> getUsers() {
return PacketEvents.getAPI().getProtocolManager().getUsers();
}

/**
* Retrieves a PacketEvents User by UUID.
*
Expand Down

0 comments on commit d5b8d9c

Please sign in to comment.