Skip to content
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

[bug] The command register seems to mask the "reload" enum #29

Closed
MengHanLOVE1027 opened this issue Jul 30, 2024 · 4 comments
Closed

[bug] The command register seems to mask the "reload" enum #29

MengHanLOVE1027 opened this issue Jul 30, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@MengHanLOVE1027
Copy link

Describe the bug
"reload" appears to be blocked in the instruction enumeration

To Reproduce
Steps to reproduce the behavior:

  1. Write content in the plugin:
    (This is the code)
# 注册命令
commands = {
    # 备份主命令
    "backup": {
        "description": "test is op",
        "usages": ["/backup (init|reload)[action: OtherAction]"],
        "permissions": ["easybackuper_plugin.command.only_op"]
    }
}
# 权限组
permissions = {
    # 只有 OP 玩家才可以执行命令
    "easybackuper_plugin.command.only_op": {
        "description": "Only OP Players can use this command",
        "default": "op",
    }
}

# 处理命令
    def on_command(self, sender: CommandSender, command: Command, args: list[str]) -> bool:
        if command.name == "backup":
            if len(args) == 0:
                (It works fine here)
            else:
                # 现在是有附加参数的情况
                #  backup [init|reload]
                #       此处为 args[0]
                # 开始对其附加参数进行判断
                match args[0]:
                    case "init":
                        self.logger.info("Hello EasyBackuper!")
                        self.logger.warning(sender.name)
                    case "reload":
                        self.logger.info("Hello EasyBackuper!")
                        self.logger.warning(sender.name)
        return True
  1. Build the plugin and place it in the 'plugins' folder.
  2. Start the server.
  3. Open Minecraft.
  4. Go to the server and join it.
  5. Type /backup(There's a space here) to test (after obtaining OP status).
  6. See the result (see screenshot below).
    image
  7. There is no optional parameter enumerator for reload.
  8. Modifying the code (see below)
    # 注册命令
    commands = {
        # 备份主命令
        "backup": {
            "description": "test is op",
            "usages": ["/backup (init|reloading)[action: OtherAction]"],
            "permissions": ["easybackuper_plugin.command.only_op"]
        }
    }

...

    case "reloading":
        self.logger.info("Hello EasyBackuper!")
        self.logger.warning(sender.name)
  1. Check it out again (see below)
    image

Expected behavior
The "reload" enum displays normally. But it didn't work.

In addition, instructions can be executed directly
By the way, sorry to trouble you. :p

Screenshots
See above.

Details (please complete the following information):

  • OS: Windows 11 x64
  • Endstone Version: v0.5.0

Additional context
None.

@MengHanLOVE1027 MengHanLOVE1027 added the bug Something isn't working label Jul 30, 2024
@wu-vincent
Copy link
Member

Quick question, were you able to execute the command with reload enum even it’s not displayed on the client side?

@MengHanLOVE1027
Copy link
Author

Quick question, were you able to execute the command with reload enum even it’s not displayed on the client side?快速提问,即使它没有显示在客户端,您也能够使用 reload enum 执行命令吗?

Yes, both client and console

@smartcmd
Copy link
Contributor

这个问题我知道怎么修,等我打完bfv

@wu-vincent
Copy link
Member

Screenshot 2024-07-31 153617

Fixed in 46325a3. I can confirm this is due to the "reload" command being sent to the client while the client has no permission to execute it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants