mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
InventoryTransaction: prevent client-authoritative item overstacking
this cheat is often used to carry more items in the inventory, wear multiple pieces of armour in one slot, and more.
This commit is contained in:
parent
af2babec23
commit
5426b41447
@ -42,6 +42,9 @@ class DropItemAction extends InventoryAction{
|
||||
if($this->targetItem->isNull()){
|
||||
throw new TransactionValidationException("Cannot drop an empty itemstack");
|
||||
}
|
||||
if($this->targetItem->getCount() > $this->targetItem->getMaxStackSize()){
|
||||
throw new TransactionValidationException("Target item exceeds item type max stack size");
|
||||
}
|
||||
}
|
||||
|
||||
public function onPreExecute(Player $source) : bool{
|
||||
|
@ -70,6 +70,12 @@ class SlotChangeAction extends InventoryAction{
|
||||
if(!$this->inventory->getItem($this->inventorySlot)->equalsExact($this->sourceItem)){
|
||||
throw new TransactionValidationException("Slot does not contain expected original item");
|
||||
}
|
||||
if($this->targetItem->getCount() > $this->targetItem->getMaxStackSize()){
|
||||
throw new TransactionValidationException("Target item exceeds item type max stack size");
|
||||
}
|
||||
if($this->targetItem->getCount() > $this->inventory->getMaxStackSize()){
|
||||
throw new TransactionValidationException("Target item exceeds inventory max stack size");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user