Skip to content

Conversation

@matcldr
Copy link
Contributor

@matcldr matcldr commented May 31, 2025

…oad permissions

Closes #12

@matcldr matcldr requested a review from Copilot May 31, 2025 12:27
@matcldr matcldr self-assigned this May 31, 2025
Copy link

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 improves command handling for non-player senders by providing tailored help messages and adjusting permission checks for reload commands.

  • Non-player senders now receive a different help message when no arguments are provided.
  • The "channel" command now verifies the sender is a player before execution.
  • The reload command has been modified to accept a CommandSender and conditionally perform permission checks.

case "reload" -> handleReloadCommand(player);
default -> sendHelpMessage(player);
case "channel", "ch" -> {
if (!(sender instanceof Player player)) {
Copy link

Copilot AI May 31, 2025

Choose a reason for hiding this comment

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

[nitpick] The instance-of check for Player is repeated in several branches. Consider refactoring this pattern into a helper method to reduce duplication and improve maintainability.

Suggested change
if (!(sender instanceof Player player)) {
Player player = isPlayerSender(sender);
if (player == null) {

Copilot uses AI. Check for mistakes.
private void handleReloadCommand(Player player) {
if (!player.hasPermission("remmychat.admin")) {
private void handleReloadCommand(CommandSender sender) {
if (sender instanceof Player player && !player.hasPermission("remmychat.admin")) {
Copy link

Copilot AI May 31, 2025

Choose a reason for hiding this comment

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

[nitpick] Since non-player senders bypass the permission check in handleReloadCommand, consider adding an inline comment to clarify that console or other non-player senders are intended to bypass this check.

Copilot uses AI. Check for mistakes.
@matcldr
Copy link
Contributor Author

matcldr commented May 31, 2025

Issue #12 was fixed by @matcldr and approved by our testers.

@matcldr matcldr merged commit d7d5287 into master May 31, 2025
1 check passed
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.

/remchat reload cannot be executed on console

2 participants