mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-10 21:45:35 +00:00
Convert adventure mode checks to permissions
This commit is contained in:
parent
57082c8148
commit
26afa97cdc
@ -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";
|
||||
|
@ -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]);
|
||||
|
@ -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){
|
||||
|
Loading…
x
Reference in New Issue
Block a user