mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Player: move flight toggling to its own method
This commit is contained in:
parent
d8198d8130
commit
b3d8d10bec
@ -2411,6 +2411,16 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function toggleFlight(bool $fly) : void{
|
||||||
|
$ev = new PlayerToggleFlightEvent($this, $fly);
|
||||||
|
$this->server->getPluginManager()->callEvent($ev);
|
||||||
|
if($ev->isCancelled()){
|
||||||
|
$this->sendSettings();
|
||||||
|
}else{
|
||||||
|
$this->setFlying($fly);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function animate(int $action) : bool{
|
public function animate(int $action) : bool{
|
||||||
$this->server->getPluginManager()->callEvent($ev = new PlayerAnimationEvent($this, $action));
|
$this->server->getPluginManager()->callEvent($ev = new PlayerAnimationEvent($this, $action));
|
||||||
if($ev->isCancelled()){
|
if($ev->isCancelled()){
|
||||||
@ -2442,13 +2452,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
$this->kick($this->server->getLanguage()->translateString("kick.reason.cheat", ["%ability.flight"]));
|
$this->kick($this->server->getLanguage()->translateString("kick.reason.cheat", ["%ability.flight"]));
|
||||||
return true;
|
return true;
|
||||||
}elseif($isFlying !== $this->isFlying()){
|
}elseif($isFlying !== $this->isFlying()){
|
||||||
$this->server->getPluginManager()->callEvent($ev = new PlayerToggleFlightEvent($this, $isFlying));
|
$this->toggleFlight($isFlying);
|
||||||
if($ev->isCancelled()){
|
|
||||||
$this->sendSettings();
|
|
||||||
}else{
|
|
||||||
$this->flying = $ev->isFlying();
|
|
||||||
}
|
|
||||||
|
|
||||||
$handled = true;
|
$handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user