Skip to content

Feature/player selectors #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 2, 2025
Merged

Feature/player selectors #19

merged 5 commits into from
Jun 2, 2025

Conversation

svenar-nl
Copy link
Member

The PR focuses on added the @p, @r and @a selectors for use in command blocks using /pr startother ....

  • @p targets the closest player to the command block, or the sender in case it is used from the chat.
  • @r targets a random online player.
  • @a targets all online players.

Bumped version to v0.9.1


  • Include a human-readable description of what the pull request is trying to accomplish
  • The CI build passes

  • New automated tests have been added
  • The changes are already covered by automated tests and have been adapted
  • These manual test cases cover this change:
  • Steps for the reviewer(s) on how they can manually QA the changes:
  • This is a minor internal change; basic CI/CD coverage is enough
  • This is an incomplete feature hidden behind feature flag:
  • This is proof-of-concept / experimental code not for production / marked @Deprecated
  • No (significant) changes to production code

  • Classes and public methods have documentation (that doesn't just repeat the technical subject in English)

  • The change is unrelated to Minecraft
  • Works in Java edition
  • Works in Bedrock edition

@svenar-nl svenar-nl requested a review from Copilot June 2, 2025 21:02
@svenar-nl svenar-nl self-assigned this Jun 2, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Preview

Copilot AI Jun 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copilot uses AI. Check for mistakes.

// Random online player
List<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers());
if (!players.isEmpty()) {
return List.of(players.get(new Random().nextInt(players.size())));
Copy link
Preview

Copilot AI Jun 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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())));

Copilot uses AI. Check for mistakes.

@svenar-nl svenar-nl merged commit eb12161 into main Jun 2, 2025
1 check passed
@svenar-nl svenar-nl deleted the feature/player_selectors branch June 2, 2025 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant