Merge branch 'release/3.5'

This commit is contained in:
Dylan K. Taylor 2018-12-31 21:52:48 +00:00
commit 3b183447b0
3 changed files with 20 additions and 3 deletions

View File

@ -623,7 +623,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
public function sendCommandData(){ public function sendCommandData(){
$pk = new AvailableCommandsPacket(); $pk = new AvailableCommandsPacket();
foreach($this->server->getCommandMap()->getCommands() as $name => $command){ 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; continue;
} }

View File

@ -50,7 +50,7 @@ abstract class Event{
*/ */
public function isCancelled() : bool{ public function isCancelled() : bool{
if(!($this instanceof Cancellable)){ if(!($this instanceof Cancellable)){
throw new \BadMethodCallException("Event is not Cancellable"); throw new \BadMethodCallException(get_class($this) . " is not Cancellable");
} }
/** @var Event $this */ /** @var Event $this */
@ -64,7 +64,7 @@ abstract class Event{
*/ */
public function setCancelled(bool $value = true) : void{ public function setCancelled(bool $value = true) : void{
if(!($this instanceof Cancellable)){ if(!($this instanceof Cancellable)){
throw new \BadMethodCallException("Event is not Cancellable"); throw new \BadMethodCallException(get_class($this) . " is not Cancellable");
} }
/** @var Event $this */ /** @var Event $this */

View File

@ -77,6 +77,11 @@ class SimpleSessionHandler extends SessionHandler{
/** @var CraftingTransaction|null */ /** @var CraftingTransaction|null */
protected $craftingTransaction = null; protected $craftingTransaction = null;
/** @var float */
protected $lastRightClickTime = 0.0;
/** @var Vector3|null */
protected $lastRightClickPos = null;
public function __construct(Player $player){ public function __construct(Player $player){
$this->player = $player; $this->player = $player;
} }
@ -184,6 +189,18 @@ class SimpleSessionHandler extends SessionHandler{
$type = $packet->trData->actionType; $type = $packet->trData->actionType;
switch($type){ switch($type){
case InventoryTransactionPacket::USE_ITEM_ACTION_CLICK_BLOCK: 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); $this->player->interactBlock($blockVector, $face, $packet->trData->clickPos);
return true; return true;
case InventoryTransactionPacket::USE_ITEM_ACTION_BREAK_BLOCK: case InventoryTransactionPacket::USE_ITEM_ACTION_BREAK_BLOCK: