event: ensure that modifications to items expected to be readonly have no effect

this isn't a very glorious fix, but it's the best I have for now.
This commit is contained in:
Dylan K. Taylor 2022-10-07 11:33:14 +01:00
parent cd4bb91676
commit c1fbac412e
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
5 changed files with 5 additions and 5 deletions

View File

@ -72,7 +72,7 @@ class BlockBreakEvent extends BlockEvent implements Cancellable{
* Returns the item used to destroy the block. * Returns the item used to destroy the block.
*/ */
public function getItem() : Item{ public function getItem() : Item{
return $this->item; return clone $this->item;
} }
/** /**

View File

@ -65,7 +65,7 @@ class BlockPlaceEvent extends BlockEvent implements Cancellable{
* Gets the item in hand * Gets the item in hand
*/ */
public function getItem() : Item{ public function getItem() : Item{
return $this->item; return clone $this->item;
} }
public function getBlockReplaced() : Block{ public function getBlockReplaced() : Block{

View File

@ -69,7 +69,7 @@ class PlayerInteractEvent extends PlayerEvent implements Cancellable{
} }
public function getItem() : Item{ public function getItem() : Item{
return $this->item; return clone $this->item;
} }
public function getBlock() : Block{ public function getBlock() : Block{

View File

@ -60,6 +60,6 @@ class PlayerItemHeldEvent extends PlayerEvent implements Cancellable{
* Returns the item in the slot that the player is trying to equip. * Returns the item in the slot that the player is trying to equip.
*/ */
public function getItem() : Item{ public function getItem() : Item{
return $this->item; return clone $this->item;
} }
} }

View File

@ -47,7 +47,7 @@ class PlayerItemUseEvent extends PlayerEvent implements Cancellable{
* Returns the item used. * Returns the item used.
*/ */
public function getItem() : Item{ public function getItem() : Item{
return $this->item; return clone $this->item;
} }
/** /**