diff --git a/src/permission/DefaultPermissionNames.php b/src/permission/DefaultPermissionNames.php index c7204047ed..bb86c134c8 100644 --- a/src/permission/DefaultPermissionNames.php +++ b/src/permission/DefaultPermissionNames.php @@ -94,6 +94,8 @@ final class DefaultPermissionNames{ public const GAME_ENTITY_ATTACK = "pocketmine.game.entity.attack"; public const GAME_ENTITY_INTERACT = "pocketmine.game.entity.interact"; public const GAME_FLIGHT = "pocketmine.game.flight"; + public const GAME_ITEM_BYPASS_CANDESTROY = "pocketmine.game.item.bypass.candestroy"; + public const GAME_ITEM_BYPASS_CANPLACEON = "pocketmine.game.item.bypass.canplaceon"; public const GAME_ITEM_CREATE = "pocketmine.game.item.create"; public const GAME_ITEM_DROP = "pocketmine.game.item.drop"; public const GAME_ITEM_PICKUP = "pocketmine.game.item.pickup"; diff --git a/src/permission/DefaultPermissions.php b/src/permission/DefaultPermissions.php index bd66cb5fb8..650fe1ae98 100644 --- a/src/permission/DefaultPermissions.php +++ b/src/permission/DefaultPermissions.php @@ -133,6 +133,11 @@ abstract class DefaultPermissions{ self::registerPermission(new Permission(Names::GAME_PLAYER_ATTACK, "Allows the user to attack other players"), [$survivalRoot, $creativeRoot, $adventureRoot]); self::registerPermission(new Permission(Names::GAME_PLAYER_INTERACT, "Allows the user to interact with other players"), [$survivalRoot, $creativeRoot, $adventureRoot]); + //TODO: maybe we should add deny inherits for the adventure group for these, instead of just granting them to the survival and creative groups + //we'll end up needing to add these to new game modes if they are added + self::registerPermission(new Permission(Names::GAME_ITEM_BYPASS_CANDESTROY, "Allows the user to bypass CanDestroy item restrictions when mining blocks"), [$survivalRoot, $creativeRoot]); + self::registerPermission(new Permission(Names::GAME_ITEM_BYPASS_CANPLACEON, "Allows the user to bypass CanPlaceOn item restrictions when placing blocks"), [$survivalRoot, $creativeRoot]); + self::registerPermission(new Permission(Names::GAME_BLOCK_DELETE, "Allows the user to delete any block without delay, including indestructible blocks"), [$creativeRoot]); self::registerPermission(new Permission(Names::GAME_ITEM_CREATE, "Allows the user to use the creative inventory"), [$creativeRoot]); self::registerPermission(new Permission(Names::GAME_FLIGHT, "Allows the user to toggle flight mode"), [$creativeRoot]); diff --git a/src/world/World.php b/src/world/World.php index 788d789746..6ed0dab2e5 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -2071,7 +2071,7 @@ class World implements ChunkManager{ $ev->cancel(); } - if($player->isAdventure(true) && !$ev->isCancelled()){ + if(!$player->hasPermission(DefaultPermissionNames::GAME_ITEM_BYPASS_CANDESTROY) && !$ev->isCancelled()){ $canBreak = false; $itemParser = LegacyStringToItemParser::getInstance(); foreach($item->getCanDestroy() as $v){ @@ -2238,7 +2238,7 @@ class World implements ChunkManager{ $ev->cancel(); } - if($player->isAdventure(true) && !$ev->isCancelled()){ + if(!$player->hasPermission(DefaultPermissionNames::GAME_ITEM_BYPASS_CANPLACEON) && !$ev->isCancelled()){ $canPlace = false; $itemParser = LegacyStringToItemParser::getInstance(); foreach($item->getCanPlaceOn() as $v){