Skip to content

Conversation

@LegendsOfXania
Copy link
Contributor

example:

jobs_farmer_no:
    slot: 20
    item:
      name: "farmer"
      material: WHEAT
    click-requirement:
      requirement:
        clicks:
          - LEFT
        success:
          - type: player_command_as_op
            commands:
              - "advancedjobs join fermier"

Executes the command as if the player were an operator, which is useful if the command cannot be executed via the console.

@alwyn974 alwyn974 requested a review from Copilot June 7, 2025 18:06
Copy link
Contributor

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

Adds a new “player_command_as_op” action that grants temporary operator permissions to a player and runs configured commands as if the player were an OP.

  • Introduces PlayerCommandAsOPAction to elevate permissions, run parsed commands, and then revoke permissions.
  • Adds PlayerCommandAsOPLoader to parse the new action configuration and wire it into the loader system.
  • Registers the new loader in ZInventoryManager alongside existing action loaders.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/main/java/fr/maxlego08/menu/requirement/actions/PlayerCommandAsOPAction.java Implements new action to run commands with elevated permissions
src/main/java/fr/maxlego08/menu/loader/actions/PlayerCommandAsOPLoader.java Registers the player_command_as_op action and its aliases
src/main/java/fr/maxlego08/menu/ZInventoryManager.java Adds registration of the new PlayerCommandAsOPLoader in the manager
Comments suppressed due to low confidence (4)

src/main/java/fr/maxlego08/menu/requirement/actions/PlayerCommandAsOPAction.java:22

  • [nitpick] The lambda parameter w is not descriptive; consider renaming it to something like world or context for clarity.
scheduler.runAtLocation(player.getLocation(), w -> papi(placeholders.parse(this.parseAndFlattenCommands(this.commands, player)), player).forEach(command -> {

src/main/java/fr/maxlego08/menu/requirement/actions/PlayerCommandAsOPAction.java:1

  • [nitpick] Public class PlayerCommandAsOPAction lacks a class-level Javadoc comment explaining its purpose and usage.
package fr.maxlego08.menu.requirement.actions;

src/main/java/fr/maxlego08/menu/requirement/actions/PlayerCommandAsOPAction.java:11

  • There are no unit tests covering the new PlayerCommandAsOPAction; consider adding tests for permission elevation and command execution paths.
public class PlayerCommandAsOPAction extends ActionHelper {

src/main/java/fr/maxlego08/menu/requirement/actions/PlayerCommandAsOPAction.java:27

  • Granting the * permission alone may not mark the player as an operator; some commands check Player.isOp(). Consider temporarily calling player.setOp(true) and reverting it after execution.
attachment.setPermission("*", true);

alwyn974 and others added 2 commits June 7, 2025 21:05
@Maxlego08 Maxlego08 merged commit fae4d1c into Maxlego08:release/rework-gradle Jun 12, 2025
2 checks 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.

3 participants