Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces new player selector functionality for command blocks by adding support for the selectors @p, @r, and @A, as well as updates some build configurations and project metadata.
- Added logic in SubcommandStartOther to resolve player selectors via the new getPlayersFromSelector method
- Updated donation URL reference and bumped dependency versions in pom.xml, along with an updated GitHub Actions build workflow
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/nl/svenar/powercamera/commands/subcommand/SubcommandStartOther.java | Added player selector logic and helper method to support @p, @r, and @A selectors |
| src/main/java/nl/svenar/powercamera/PowerCamera.java | Updated donation URL logging and removed deprecated commented code |
| pom.xml | Bumped revision version and updated dependency versions along with adding a repository |
| .github/workflows/build.yml | Replaced external workflow with explicit steps to set up JDK 21 and build using Maven |
| .github/pull_request_template.md | Modified checklist items for improved clarity |
| + "' on player: " + targetPlayer.getName()); | ||
| } else { | ||
| sendMessage(sender, ChatColor.RED + "Camera '" + cameraName + "' not found!"); | ||
| break; |
There was a problem hiding this comment.
The use of 'break' in the loop when a camera is not found might prematurely end processing of other valid target players. Consider using 'continue' to ensure all players are evaluated.
Suggested change
| break; | |
| continue; |
| // Random online player | ||
| List<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers()); | ||
| if (!players.isEmpty()) { | ||
| return List.of(players.get(new Random().nextInt(players.size()))); |
There was a problem hiding this comment.
Creating a new Random instance each time this method is called might be less efficient; consider caching a Random instance at the class level.
Suggested change
| return List.of(players.get(new Random().nextInt(players.size()))); | |
| return List.of(players.get(RANDOM.nextInt(players.size()))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The PR focuses on added the
@p,@rand@aselectors for use in command blocks using/pr startother ....@ptargets the closest player to the command block, or the sender in case it is used from the chat.@rtargets a random online player.@atargets all online players.Bumped version to
v0.9.1@Deprecated