mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-30 23:29:54 +00:00
Consistent fluency for block property setters
This commit is contained in:
parent
3d4470ed8d
commit
7399e6944e
@ -137,13 +137,15 @@ class Banner extends Transparent{
|
||||
/**
|
||||
* @param Deque|BannerPattern[] $patterns
|
||||
* @phpstan-param Deque<BannerPattern> $patterns
|
||||
* @return $this
|
||||
*/
|
||||
public function setPatterns(Deque $patterns) : void{
|
||||
public function setPatterns(Deque $patterns) : self{
|
||||
$checked = $patterns->filter(function($v) : bool{ return $v instanceof BannerPattern; });
|
||||
if($checked->count() !== $patterns->count()){
|
||||
throw new \TypeError("Deque must only contain " . BannerPattern::class . " objects");
|
||||
}
|
||||
$this->patterns = $checked;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,8 +104,10 @@ class Bed extends Transparent{
|
||||
return $this->occupied;
|
||||
}
|
||||
|
||||
public function setOccupied(bool $occupied = true) : void{
|
||||
/** @return $this */
|
||||
public function setOccupied(bool $occupied = true) : self{
|
||||
$this->occupied = $occupied;
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function getOtherHalfSide() : int{
|
||||
|
@ -81,13 +81,15 @@ class FlowerPot extends Flowable{
|
||||
return $this->plant;
|
||||
}
|
||||
|
||||
public function setPlant(?Block $plant) : void{
|
||||
/** @return $this */
|
||||
public function setPlant(?Block $plant) : self{
|
||||
if($plant === null or $plant instanceof Air){
|
||||
$this->plant = null;
|
||||
}else{
|
||||
$this->plant = clone $plant;
|
||||
}
|
||||
$this->occupied = $this->plant !== null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function canAddPlant(Block $block) : bool{
|
||||
|
@ -91,29 +91,35 @@ class ItemFrame extends Flowable{
|
||||
return $this->framedItem !== null ? clone $this->framedItem : null;
|
||||
}
|
||||
|
||||
public function setFramedItem(?Item $item) : void{
|
||||
/** @return $this */
|
||||
public function setFramedItem(?Item $item) : self{
|
||||
if($item === null or $item->isNull()){
|
||||
$this->framedItem = null;
|
||||
$this->itemRotation = 0;
|
||||
}else{
|
||||
$this->framedItem = clone $item;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getItemRotation() : int{
|
||||
return $this->itemRotation;
|
||||
}
|
||||
|
||||
public function setItemRotation(int $itemRotation) : void{
|
||||
/** @return $this */
|
||||
public function setItemRotation(int $itemRotation) : self{
|
||||
$this->itemRotation = $itemRotation;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getItemDropChance() : float{
|
||||
return $this->itemDropChance;
|
||||
}
|
||||
|
||||
public function setItemDropChance(float $itemDropChance) : void{
|
||||
/** @return $this */
|
||||
public function setItemDropChance(float $itemDropChance) : self{
|
||||
$this->itemDropChance = $itemDropChance;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
|
@ -54,12 +54,14 @@ class NetherPortal extends Transparent{
|
||||
|
||||
/**
|
||||
* @throws \InvalidArgumentException
|
||||
* @return $this
|
||||
*/
|
||||
public function setAxis(int $axis) : void{
|
||||
public function setAxis(int $axis) : self{
|
||||
if($axis !== Facing::AXIS_X and $axis !== Facing::AXIS_Z){
|
||||
throw new \InvalidArgumentException("Invalid axis");
|
||||
}
|
||||
$this->axis = $axis;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLightLevel() : int{
|
||||
|
@ -62,11 +62,13 @@ class Note extends Opaque{
|
||||
return $this->pitch;
|
||||
}
|
||||
|
||||
public function setPitch(int $pitch) : void{
|
||||
/** @return $this */
|
||||
public function setPitch(int $pitch) : self{
|
||||
if($pitch < self::MIN_PITCH or $pitch > self::MAX_PITCH){
|
||||
throw new \InvalidArgumentException("Pitch must be in range " . self::MIN_PITCH . " - " . self::MAX_PITCH);
|
||||
}
|
||||
$this->pitch = $pitch;
|
||||
return $this;
|
||||
}
|
||||
|
||||
//TODO
|
||||
|
@ -90,24 +90,30 @@ class RedstoneComparator extends Flowable{
|
||||
return $this->isSubtractMode;
|
||||
}
|
||||
|
||||
public function setSubtractMode(bool $isSubtractMode) : void{
|
||||
/** @return $this */
|
||||
public function setSubtractMode(bool $isSubtractMode) : self{
|
||||
$this->isSubtractMode = $isSubtractMode;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isPowered() : bool{
|
||||
return $this->powered;
|
||||
}
|
||||
|
||||
public function setPowered(bool $powered) : void{
|
||||
/** @return $this */
|
||||
public function setPowered(bool $powered) : self{
|
||||
$this->powered = $powered;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSignalStrength() : int{
|
||||
return $this->signalStrength;
|
||||
}
|
||||
|
||||
public function setSignalStrength(int $signalStrength) : void{
|
||||
/** @return $this */
|
||||
public function setSignalStrength(int $signalStrength) : self{
|
||||
$this->signalStrength = $signalStrength;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,8 +140,10 @@ class Sign extends Transparent{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
public function setText(SignText $text) : void{
|
||||
/** @return $this */
|
||||
public function setText(SignText $text) : self{
|
||||
$this->text = $text;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user