Added more methods to PlayerIllegalMoveEvent

This commit is contained in:
Dylan K. Taylor 2017-10-17 16:14:41 +01:00
parent cccaade00c
commit ece37d1e19
2 changed files with 23 additions and 3 deletions

View File

@ -1504,7 +1504,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$diff = ($diffX ** 2 + $diffY ** 2 + $diffZ ** 2) / ($tickDiff ** 2);
if($this->isSurvival() and !$revert and $diff > 0.0625){
$ev = new PlayerIllegalMoveEvent($this, $newPos);
$ev = new PlayerIllegalMoveEvent($this, $newPos, new Vector3($this->lastX, $this->lastY, $this->lastZ));
$ev->setCancelled($this->allowMovementCheats);
$this->server->getPluginManager()->callEvent($ev);

View File

@ -36,14 +36,21 @@ class PlayerIllegalMoveEvent extends PlayerCheatEvent implements Cancellable{
/** @var Vector3 */
private $attemptedPosition;
/** @var Vector3 */
private $originalPosition;
/** @var Vector3 */
private $expectedPosition;
/**
* @param Player $player
* @param Vector3 $attemptedPosition
* @param Vector3 $originalPosition
*/
public function __construct(Player $player, Vector3 $attemptedPosition){
$this->attemptedPosition = $attemptedPosition;
public function __construct(Player $player, Vector3 $attemptedPosition, Vector3 $originalPosition){
$this->player = $player;
$this->attemptedPosition = $attemptedPosition;
$this->originalPosition = $originalPosition;
$this->expectedPosition = $player->asVector3();
}
/**
@ -54,4 +61,17 @@ class PlayerIllegalMoveEvent extends PlayerCheatEvent implements Cancellable{
return $this->attemptedPosition;
}
/**
* @return Vector3
*/
public function getOriginalPosition() : Vector3{
return $this->originalPosition;
}
/**
* @return Vector3
*/
public function getExpectedPosition() : Vector3{
return $this->expectedPosition;
}
}