diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 368fa25b1..c65a7f26f 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -623,7 +623,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ public function sendCommandData(){ $pk = new AvailableCommandsPacket(); foreach($this->server->getCommandMap()->getCommands() as $name => $command){ - if(isset($pk->commandData[$command->getName()]) or $command->getName() === "help"){ + if(isset($pk->commandData[$command->getName()]) or $command->getName() === "help" or !$command->testPermissionSilent($this)){ continue; } diff --git a/src/pocketmine/event/Event.php b/src/pocketmine/event/Event.php index a1a3f176b..34d53c72e 100644 --- a/src/pocketmine/event/Event.php +++ b/src/pocketmine/event/Event.php @@ -50,7 +50,7 @@ abstract class Event{ */ public function isCancelled() : bool{ if(!($this instanceof Cancellable)){ - throw new \BadMethodCallException("Event is not Cancellable"); + throw new \BadMethodCallException(get_class($this) . " is not Cancellable"); } /** @var Event $this */ @@ -64,7 +64,7 @@ abstract class Event{ */ public function setCancelled(bool $value = true) : void{ if(!($this instanceof Cancellable)){ - throw new \BadMethodCallException("Event is not Cancellable"); + throw new \BadMethodCallException(get_class($this) . " is not Cancellable"); } /** @var Event $this */ diff --git a/src/pocketmine/network/mcpe/handler/SimpleSessionHandler.php b/src/pocketmine/network/mcpe/handler/SimpleSessionHandler.php index 885d47536..35b463645 100644 --- a/src/pocketmine/network/mcpe/handler/SimpleSessionHandler.php +++ b/src/pocketmine/network/mcpe/handler/SimpleSessionHandler.php @@ -77,6 +77,11 @@ class SimpleSessionHandler extends SessionHandler{ /** @var CraftingTransaction|null */ protected $craftingTransaction = null; + /** @var float */ + protected $lastRightClickTime = 0.0; + /** @var Vector3|null */ + protected $lastRightClickPos = null; + public function __construct(Player $player){ $this->player = $player; } @@ -184,6 +189,18 @@ class SimpleSessionHandler extends SessionHandler{ $type = $packet->trData->actionType; switch($type){ case InventoryTransactionPacket::USE_ITEM_ACTION_CLICK_BLOCK: + //TODO: start hack for client spam bug + $spamBug = ($this->lastRightClickPos !== null and + microtime(true) - $this->lastRightClickTime < 0.1 and //100ms + $this->lastRightClickPos->distanceSquared($packet->trData->clickPos) < 0.00001 //signature spam bug has 0 distance, but allow some error + ); + //get rid of continued spam if the player clicks and holds right-click + $this->lastRightClickPos = clone $packet->trData->clickPos; + $this->lastRightClickTime = microtime(true); + if($spamBug){ + return true; + } + //TODO: end hack for client spam bug $this->player->interactBlock($blockVector, $face, $packet->trData->clickPos); return true; case InventoryTransactionPacket::USE_ITEM_ACTION_BREAK_BLOCK: