mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 14:35:35 +00:00
Cleaned up checks for handling inventory transactions
This commit is contained in:
parent
cebb4b35f6
commit
cd44551d64
@ -2198,6 +2198,10 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function handleInventoryTransaction(InventoryTransactionPacket $packet) : bool{
|
public function handleInventoryTransaction(InventoryTransactionPacket $packet) : bool{
|
||||||
|
if(!$this->spawned or !$this->isAlive()){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->isSpectator()){
|
if($this->isSpectator()){
|
||||||
$this->sendAllInventories();
|
$this->sendAllInventories();
|
||||||
return true;
|
return true;
|
||||||
@ -2305,10 +2309,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
case InventoryTransactionPacket::USE_ITEM_ACTION_BREAK_BLOCK:
|
case InventoryTransactionPacket::USE_ITEM_ACTION_BREAK_BLOCK:
|
||||||
if($this->spawned === false or !$this->isAlive()){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->resetCraftingGridType();
|
$this->resetCraftingGridType();
|
||||||
|
|
||||||
$item = $this->inventory->getItemInHand();
|
$item = $this->inventory->getItemInHand();
|
||||||
@ -2394,7 +2394,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
$cancelled = true;
|
$cancelled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($target instanceof Entity and $this->getGamemode() !== Player::VIEW and $this->isAlive() and $target->isAlive()){
|
if($target->isAlive()){
|
||||||
if($target instanceof DroppedItem or $target instanceof Arrow){
|
if($target instanceof DroppedItem or $target instanceof Arrow){
|
||||||
$this->kick("Attempting to attack an invalid entity");
|
$this->kick("Attempting to attack an invalid entity");
|
||||||
$this->server->getLogger()->warning($this->getServer()->getLanguage()->translateString("pocketmine.player.invalidEntity", [$this->getName()]));
|
$this->server->getLogger()->warning($this->getServer()->getLanguage()->translateString("pocketmine.player.invalidEntity", [$this->getName()]));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user