mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-05 19:37:17 +00:00
Added INT32_MIN and INT32_MAX constants and an exception throw for out-of-range effect amplifiers
This commit is contained in:
parent
1bf18ba8d2
commit
313fdb9e87
@ -22,6 +22,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace {
|
||||
const INT32_MIN = -0x80000000;
|
||||
const INT32_MAX = 0x7fffffff;
|
||||
|
||||
function safe_var_dump(){
|
||||
static $cnt = 0;
|
||||
foreach(func_get_args() as $var){
|
||||
|
@ -174,7 +174,10 @@ class Effect{
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDuration($ticks){
|
||||
public function setDuration(int $ticks){
|
||||
if($ticks < 0 or $ticks > INT32_MAX){
|
||||
throw new \InvalidArgumentException("Effect duration must be in range of 0 - " . INT32_MAX);
|
||||
}
|
||||
$this->duration = $ticks;
|
||||
return $this;
|
||||
}
|
||||
@ -248,7 +251,7 @@ class Effect{
|
||||
* @return $this
|
||||
*/
|
||||
public function setAmplifier(int $amplifier){
|
||||
$this->amplifier = $amplifier & 0xff;
|
||||
$this->amplifier = ($amplifier & 0xff);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user