这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@dktapps
Copy link
Member

@dktapps dktapps commented Jan 30, 2023

Introduction

This PR implements #5512.

The motivation for this PR is described in #5512.

Relevant issues

Closes #5512

Changes

API changes

Behavioural changes

  • The following things are now controllable by permissions:
    • Chatting
    • Emoting
    • Placing, breaking and interacting with blocks
    • Dropping, picking up, and activating items
    • Creating new items (e.g. from the creative inventory)
    • Attacking and interacting with entities
    • Flight
    • CanPlaceOn and CanDestroy checks
    • Creative-style instabreak & destruction of indestructible blocks
  • Game modes now apply abilities by setting a permission group to true on the player.
  • Various places that previously used game mode checks (e.g. dropping items, interacting with blocks, attacking entities) now check for permissions instead.

Backwards compatibility

Should be fully backwards compatible.

Follow-up

Add further permissions for the following:

  • Opening containers
  • Remove some deprecated setters that have been migrated to permissions

Tests

This has been tested in-game.

Full list of permission changes per generated documentation

diff --git a/source/core-permissions.rst b/../minor-next/core-permissions.rst
index 019e7d9..dc3a2fe 100644
--- a/source/core-permissions.rst
+++ b/../minor-next/core-permissions.rst
@@ -3,7 +3,7 @@
 List of PocketMine-MP core permissions
 ======================================
 
-Generated from PocketMine-MP 5.35.0
+Generated from PocketMine-MP 5.35.1+dev
 
 .. list-table::
    :header-rows: 1
@@ -198,9 +198,81 @@ Generated from PocketMine-MP 5.35.0
    * - ``pocketmine.command.xp.self``
      - Allows the user to add or remove their experience
      - N/A
+   * - ``pocketmine.game.attack.entity``
+     - Allows the user to attack entities
+     - N/A
+   * - ``pocketmine.game.attack.player``
+     - Allows the user to attack other players
+     - N/A
+   * - ``pocketmine.game.block.instabreak``
+     - Allows the user to delete any block without delay, including indestructible blocks
+     - N/A
+   * - ``pocketmine.game.block.mine``
+     - Allows the user to mine blocks
+     - N/A
+   * - ``pocketmine.game.block.place``
+     - Allows the user to place blocks
+     - N/A
+   * - ``pocketmine.game.chat``
+     - Allows the user to chat
+     - N/A
+   * - ``pocketmine.game.emote``
+     - Allows the user to emote
+     - N/A
+   * - ``pocketmine.game.hidden``
+     - Makes the user unseen and unheard by other players (as in spectator game mode)
+     - N/A
+   * - ``pocketmine.game.inventory.creative``
+     - Allows the user to use the creative inventory
+     - N/A
+   * - ``pocketmine.game.inventory.drop``
+     - Allows the user to drop items
+     - N/A
+   * - ``pocketmine.game.inventory.pickup``
+     - Allows the user to pick up items
+     - N/A
+   * - ``pocketmine.game.invulnerable``
+     - Allows the user to ignore all incoming damage (except suicide)
+     - N/A
+   * - ``pocketmine.game.item.bypass.candestroy``
+     - Allows the user to bypass CanDestroy item restrictions when mining blocks
+     - N/A
+   * - ``pocketmine.game.item.bypass.canplaceon``
+     - Allows the user to bypass CanPlaceOn item restrictions when placing blocks
+     - N/A
+   * - ``pocketmine.game.move.flight``
+     - Allows the user to toggle flight mode
+     - N/A
+   * - ``pocketmine.game.move.noclip.block``
+     - Allows the user to pass through blocks
+     - N/A
+   * - ``pocketmine.game.move.noclip.entity``
+     - Allows the user to pass through entities without collision checks
+     - N/A
+   * - ``pocketmine.game.use.block``
+     - Allows the user to use functional blocks like doors
+     - N/A
+   * - ``pocketmine.game.use.entity``
+     - Allows the user to use items on entities
+     - N/A
+   * - ``pocketmine.game.use.item``
+     - Allows the user to use functional items like projectiles
+     - N/A
    * - ``pocketmine.group.console``
      - Grants all console permissions
      - :ref:`Jump<permissions_implied_by_pocketmine.group.console>`
+   * - ``pocketmine.group.gamemode.adventure``
+     - Grants all permissions for actions allowed in the Adventure game mode
+     - :ref:`Jump<permissions_implied_by_pocketmine.group.gamemode.adventure>`
+   * - ``pocketmine.group.gamemode.creative``
+     - Grants all permissions for actions allowed in the Creative game mode
+     - :ref:`Jump<permissions_implied_by_pocketmine.group.gamemode.creative>`
+   * - ``pocketmine.group.gamemode.spectator``
+     - Grants all permissions for actions allowed in the Spectator game mode
+     - :ref:`Jump<permissions_implied_by_pocketmine.group.gamemode.spectator>`
+   * - ``pocketmine.group.gamemode.survival``
+     - Grants all permissions for actions allowed in the Survival game mode
+     - :ref:`Jump<permissions_implied_by_pocketmine.group.gamemode.survival>`
    * - ``pocketmine.group.operator``
      - Grants all operator permissions
      - :ref:`Jump<permissions_implied_by_pocketmine.group.operator>`
@@ -239,6 +311,136 @@ Users granted this permission will also be granted/denied the following permissi
    * - ``pocketmine.group.operator``
      - Granted
 
+.. _permissions_implied_by_pocketmine.group.gamemode.adventure:
+
+Permissions implied by ``pocketmine.group.gamemode.adventure``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Users granted this permission will also be granted/denied the following permissions implicitly:
+
+.. list-table::
+   :header-rows: 1
+
+   * - Name
+     - Type
+   * - ``pocketmine.game.attack.entity``
+     - Granted
+   * - ``pocketmine.game.attack.player``
+     - Granted
+   * - ``pocketmine.game.block.mine``
+     - Granted
+   * - ``pocketmine.game.block.place``
+     - Granted
+   * - ``pocketmine.game.inventory.drop``
+     - Granted
+   * - ``pocketmine.game.inventory.pickup``
+     - Granted
+   * - ``pocketmine.game.use.block``
+     - Granted
+   * - ``pocketmine.game.use.entity``
+     - Granted
+   * - ``pocketmine.game.use.item``
+     - Granted
+
+.. _permissions_implied_by_pocketmine.group.gamemode.creative:
+
+Permissions implied by ``pocketmine.group.gamemode.creative``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Users granted this permission will also be granted/denied the following permissions implicitly:
+
+.. list-table::
+   :header-rows: 1
+
+   * - Name
+     - Type
+   * - ``pocketmine.game.attack.entity``
+     - Granted
+   * - ``pocketmine.game.attack.player``
+     - Granted
+   * - ``pocketmine.game.block.instabreak``
+     - Granted
+   * - ``pocketmine.game.block.mine``
+     - Granted
+   * - ``pocketmine.game.block.place``
+     - Granted
+   * - ``pocketmine.game.inventory.creative``
+     - Granted
+   * - ``pocketmine.game.inventory.drop``
+     - Granted
+   * - ``pocketmine.game.inventory.pickup``
+     - Granted
+   * - ``pocketmine.game.invulnerable``
+     - Granted
+   * - ``pocketmine.game.item.bypass.candestroy``
+     - Granted
+   * - ``pocketmine.game.item.bypass.canplaceon``
+     - Granted
+   * - ``pocketmine.game.move.flight``
+     - Granted
+   * - ``pocketmine.game.use.block``
+     - Granted
+   * - ``pocketmine.game.use.entity``
+     - Granted
+   * - ``pocketmine.game.use.item``
+     - Granted
+
+.. _permissions_implied_by_pocketmine.group.gamemode.spectator:
+
+Permissions implied by ``pocketmine.group.gamemode.spectator``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Users granted this permission will also be granted/denied the following permissions implicitly:
+
+.. list-table::
+   :header-rows: 1
+
+   * - Name
+     - Type
+   * - ``pocketmine.game.hidden``
+     - Granted
+   * - ``pocketmine.game.invulnerable``
+     - Granted
+   * - ``pocketmine.game.move.noclip.block``
+     - Granted
+   * - ``pocketmine.game.move.noclip.entity``
+     - Granted
+
+.. _permissions_implied_by_pocketmine.group.gamemode.survival:
+
+Permissions implied by ``pocketmine.group.gamemode.survival``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Users granted this permission will also be granted/denied the following permissions implicitly:
+
+.. list-table::
+   :header-rows: 1
+
+   * - Name
+     - Type
+   * - ``pocketmine.game.attack.entity``
+     - Granted
+   * - ``pocketmine.game.attack.player``
+     - Granted
+   * - ``pocketmine.game.block.mine``
+     - Granted
+   * - ``pocketmine.game.block.place``
+     - Granted
+   * - ``pocketmine.game.inventory.drop``
+     - Granted
+   * - ``pocketmine.game.inventory.pickup``
+     - Granted
+   * - ``pocketmine.game.item.bypass.candestroy``
+     - Granted
+   * - ``pocketmine.game.item.bypass.canplaceon``
+     - Granted
+   * - ``pocketmine.game.use.block``
+     - Granted
+   * - ``pocketmine.game.use.entity``
+     - Granted
+   * - ``pocketmine.game.use.item``
+     - Granted
+
 .. _permissions_implied_by_pocketmine.group.operator:
 
 Permissions implied by ``pocketmine.group.operator``
@@ -388,4 +590,8 @@ Users granted this permission will also be granted/denied the following permissi
      - Granted
    * - ``pocketmine.command.version``
      - Granted
+   * - ``pocketmine.game.chat``
+     - Granted
+   * - ``pocketmine.game.emote``
+     - Granted
 

@dktapps dktapps added Category: Core Related to internal functionality Type: Enhancement Contributes features or other improvements to PocketMine-MP Category: UI Related to the user interface (e.g. commands, terminal output) labels Jan 30, 2023
@dktapps dktapps added the Status: Blocked Depends on other changes which are yet to be completed label Nov 14, 2024
@dktapps
Copy link
Member Author

dktapps commented Nov 29, 2024

Blocking items:

  • New permissions need descriptions localizing
  • Behavioural BC break of setAllowFlight() - this can be addressed by removing the base permission during gamemode change - since we'll probably remove setAllowFlight() in major-next, this workaround is probably OK

the remaining bool flags are user input toggles, not abilities, so it doesn't make sense to move them to permissions.

permissions are intended for what the player is *allowed* to do, not what they *want* to do.
this eliminates all remaining usages of isCreative(), except for reach distance checks. Reach distance can't be migrated to a permission in an obvious way.
@dktapps
Copy link
Member Author

dktapps commented Oct 7, 2025

Sticking points I have with this:

  • "entity interact" feels non-descriptive and could mean a whole bunch of different things
  • Not sure "block delete" is obvious enough (it's for instabreak & breaking bedrock)
  • Not sure why we need a permission specifically for right-clicking players

@dktapps dktapps removed the Status: Blocked Depends on other changes which are yet to be completed label Oct 18, 2025
@dktapps dktapps marked this pull request as ready for review October 18, 2025 19:41
@dktapps dktapps requested a review from a team as a code owner October 18, 2025 19:41
pmmp-admin-bot[bot]
pmmp-admin-bot bot previously approved these changes Oct 18, 2025
@kostamax27
Copy link
Contributor

This probably doesn’t apply to this PR, maybe it’s worth creating issue for it?

It would also be useful to allow granting a player permission for a specific GameMode via the /gamemode command.

pmmp-admin-bot[bot]
pmmp-admin-bot bot previously approved these changes Oct 18, 2025
@dktapps
Copy link
Member Author

dktapps commented Oct 18, 2025

There's already an open issue for that. It's not super clear how that would be implemented at the moment.

these functions have been booby traps for a while since they don't actually do a strict game mode check by default.
In any case, most if not all uses of game mode checks can be superseded by permission checks now.

I think the only cases left uncovered are noclip-entities and spectator mode hiding (not spawned and no sounds sent).
pmmp-admin-bot[bot]
pmmp-admin-bot bot previously approved these changes Oct 19, 2025
pmmp-admin-bot[bot]
pmmp-admin-bot bot previously approved these changes Oct 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Category: Core Related to internal functionality Category: UI Related to the user interface (e.g. commands, terminal output) Type: Enhancement Contributes features or other improvements to PocketMine-MP

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants