mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-08 12:48:32 +00:00
Teleport command fix
This commit is contained in:
parent
53afe03a1e
commit
378506a55a
@ -47,8 +47,11 @@ class PlayerAPI{
|
|||||||
console("[INFO] Usage: /tp <player> <target>");
|
console("[INFO] Usage: /tp <player> <target>");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->teleport($name, $target);
|
if($this->teleport($name, $target)){
|
||||||
console("[INFO] \"$name\" teleported to \"$target\"");
|
console("[INFO] \"$name\" teleported to \"$target\"");
|
||||||
|
}else{
|
||||||
|
console("[ERROR] Couldn't teleport");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "tppos":
|
case "tppos":
|
||||||
$z = array_pop($params);
|
$z = array_pop($params);
|
||||||
@ -59,8 +62,11 @@ class PlayerAPI{
|
|||||||
console("[INFO] Usage: /tp <player> <x> <y> <z>");
|
console("[INFO] Usage: /tp <player> <x> <y> <z>");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->tppos($name, $x, $y, $z);
|
if($this->tppos($name, $x, $y, $z)){
|
||||||
console("[INFO] \"$name\" teleported to ($x, $y, $z)");
|
console("[INFO] \"$name\" teleported to ($x, $y, $z)");
|
||||||
|
}else{
|
||||||
|
console("[ERROR] Couldn't teleport");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "kill":
|
case "kill":
|
||||||
$player = $this->get(implode(" ", $params));
|
$player = $this->get(implode(" ", $params));
|
||||||
@ -82,15 +88,25 @@ class PlayerAPI{
|
|||||||
public function teleport($name, $target){
|
public function teleport($name, $target){
|
||||||
$target = $this->get($target);
|
$target = $this->get($target);
|
||||||
if($target !== false){
|
if($target !== false){
|
||||||
$this->tppos($name, $target->entity->x, $target->entity->y, $target->entity->z);
|
return $this->tppos($name, $target->entity->x, $target->entity->y, $target->entity->z);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tppos($name, $x, $y, $z){
|
public function tppos($name, $x, $y, $z){
|
||||||
$player = $this->get($name);
|
$player = $this->get($name);
|
||||||
if($player !== false){
|
if($player !== false){
|
||||||
$this->server->trigger("onTeleport", array("eid" => $player->eid, "x" => $x, "y" => $y, "z" => $z));
|
$this->player->dataPacket(MC_MOVE_PLAYER, array(
|
||||||
|
"eid" => $player->eid,
|
||||||
|
"x" => $player->x,
|
||||||
|
"y" => $player->y,
|
||||||
|
"z" => $player->z,
|
||||||
|
"yaw" => 0,
|
||||||
|
"pitch" => 0,
|
||||||
|
));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get($name){
|
public function get($name){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user