mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 09:26:06 +00:00
Throw exception when a plugin tries to change the cancel event of a non-Cancellable event
This commit is contained in:
@ -46,8 +46,13 @@ abstract class Event{
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function isCancelled(){
|
||||
if(!($this instanceof Cancellable)){
|
||||
throw new \BadMethodCallException("Event is not Cancellable");
|
||||
}
|
||||
return $this->isCancelled === true;
|
||||
}
|
||||
|
||||
@ -55,8 +60,13 @@ abstract class Event{
|
||||
* @param bool $value
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function setCancelled($value = true){
|
||||
if(!($this instanceof Cancellable)){
|
||||
throw new \BadMethodCallException("Event is not Cancellable");
|
||||
}
|
||||
$this->isCancelled = (bool) $value;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user