Added permission for emoting

This commit is contained in:
Dylan K. Taylor 2024-12-01 16:50:26 +00:00
parent 0bbd4af496
commit ac1e70cd96
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
3 changed files with 5 additions and 0 deletions

View File

@ -91,6 +91,7 @@ final class DefaultPermissionNames{
public const GAME_BLOCK_MINE = "pocketmine.game.block.mine";
public const GAME_BLOCK_PLACE = "pocketmine.game.block.place";
public const GAME_CHAT = "pocketmine.game.chat";
public const GAME_EMOTE = "pocketmine.game.emote";
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";

View File

@ -116,6 +116,7 @@ abstract class DefaultPermissions{
self::registerPermission(new Permission(Names::COMMAND_XP_SELF, l10n::pocketmine_permission_command_xp_self()), [$operatorRoot]);
self::registerPermission(new Permission(Names::GAME_CHAT, "Allows the user to chat"), [$everyoneRoot]);
self::registerPermission(new Permission(Names::GAME_EMOTE, "Allows the user to emote"), [$everyoneRoot]);
$survivalRoot = self::registerPermission(new Permission(Names::GROUP_GAMEMODE_SURVIVAL));
$creativeRoot = self::registerPermission(new Permission(Names::GROUP_GAMEMODE_CREATIVE));

View File

@ -2067,6 +2067,9 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
if($currentTick - $this->lastEmoteTick > 5){
$this->lastEmoteTick = $currentTick;
$event = new PlayerEmoteEvent($this, $emoteId);
if(!$this->hasPermission(DefaultPermissionNames::GAME_EMOTE)){
$event->cancel();
}
$event->call();
if(!$event->isCancelled()){
$emoteId = $event->getEmoteId();