mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-30 15:19:56 +00:00
Throw exception when a plugin tries to change the cancel event of a non-Cancellable event
This commit is contained in:
parent
825656feed
commit
a0ac660d57
@ -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;
|
||||
}
|
||||
|
||||
|
@ -33,14 +33,26 @@ class Sign extends Spawnable{
|
||||
|
||||
public function __construct(Chunk $chunk, Compound $nbt){
|
||||
$nbt["id"] = Tile::SIGN;
|
||||
if(!isset($nbt->Text1)){
|
||||
$nbt->Text1 = new String("Text1", "");
|
||||
}
|
||||
if(!isset($nbt->Text2)){
|
||||
$nbt->Text2 = new String("Text2", "");
|
||||
}
|
||||
if(!isset($nbt->Text3)){
|
||||
$nbt->Text3 = new String("Text3", "");
|
||||
}
|
||||
if(!isset($nbt->Text4)){
|
||||
$nbt->Text4 = new String("Text4", "");
|
||||
}
|
||||
parent::__construct($chunk, $nbt);
|
||||
}
|
||||
|
||||
public function setText($line1 = "", $line2 = "", $line3 = "", $line4 = ""){
|
||||
$this->namedtag->Text1 = $line1;
|
||||
$this->namedtag->Text2 = $line2;
|
||||
$this->namedtag->Text3 = $line3;
|
||||
$this->namedtag->Text4 = $line4;
|
||||
$this->namedtag->Text1 = new String("Text1", $line1);
|
||||
$this->namedtag->Text2 = new String("Text2", $line2);
|
||||
$this->namedtag->Text3 = new String("Text3", $line3);
|
||||
$this->namedtag->Text4 = new String("Text4", $line4);
|
||||
$this->spawnToAll();
|
||||
|
||||
return true;
|
||||
@ -48,10 +60,10 @@ class Sign extends Spawnable{
|
||||
|
||||
public function getText(){
|
||||
return array(
|
||||
$this->namedtag->Text1,
|
||||
$this->namedtag->Text2,
|
||||
$this->namedtag->Text3,
|
||||
$this->namedtag->Text4
|
||||
$this->namedtag["Text1"],
|
||||
$this->namedtag["Text2"],
|
||||
$this->namedtag["Text3"],
|
||||
$this->namedtag["Text4"]
|
||||
);
|
||||
}
|
||||
|
||||
@ -62,10 +74,10 @@ class Sign extends Spawnable{
|
||||
|
||||
$nbt = new NBT(NBT::LITTLE_ENDIAN);
|
||||
$nbt->setData(new Compound("", array(
|
||||
new String("Text1", $this->namedtag->Text1),
|
||||
new String("Text2", $this->namedtag->Text2),
|
||||
new String("Text3", $this->namedtag->Text3),
|
||||
new String("Text4", $this->namedtag->Text4),
|
||||
new String("Text1", $this->namedtag["Text1"]),
|
||||
new String("Text2", $this->namedtag["Text2"]),
|
||||
new String("Text3", $this->namedtag["Text4"]),
|
||||
new String("Text4", $this->namedtag["Text4"]),
|
||||
new String("id", Tile::SIGN),
|
||||
new Int("x", (int) $this->x),
|
||||
new Int("y", (int) $this->y),
|
||||
|
Loading…
x
Reference in New Issue
Block a user