mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 04:29:43 +00:00
ops/console/rcon can view coords and ping of other players now
This commit is contained in:
parent
a485d7506b
commit
38ced36e16
2 changed files with 45 additions and 10 deletions
|
|
@ -123,10 +123,25 @@ class PlayerAPI{
|
||||||
$issuer->teleport($this->server->spawn);
|
$issuer->teleport($this->server->spawn);
|
||||||
return "You were teleported to the spawn.";
|
return "You were teleported to the spawn.";
|
||||||
case "ping":
|
case "ping":
|
||||||
|
|
||||||
if(!($issuer instanceof Player)){
|
if(!($issuer instanceof Player)){
|
||||||
return "Please run this command in-game.";
|
if(isset($args[0])){
|
||||||
|
goto get_ping_of_others;
|
||||||
|
}
|
||||||
|
return "Usage: /$cmd <username>.";
|
||||||
}
|
}
|
||||||
return "ping " . round($issuer->getLag(), 2) . "ms, packet loss " . round($issuer->getPacketLoss() * 100, 2) . "%, " . round($issuer->getBandwidth() / 1024, 2) . " KB/s\n";
|
|
||||||
|
if(isset($args[0]) && $this->server->api->ban->isOp($issuer->iusername)){
|
||||||
|
get_ping_of_others:
|
||||||
|
$p = $this->get($args[0]);
|
||||||
|
if(!($p instanceof Player)){
|
||||||
|
return "Player with username '{$args[0]}' is not on server.";
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$p = $issuer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "{$p->username}'s ping: " . round($p->getLag(), 2) . "ms, packet loss " . round($p->getPacketLoss() * 100, 2) . "%, " . round($p->getBandwidth() / 1024, 2) . " KB/s\n";
|
||||||
case "gamemode":
|
case "gamemode":
|
||||||
$player = false;
|
$player = false;
|
||||||
$setgm = false;
|
$setgm = false;
|
||||||
|
|
@ -228,18 +243,37 @@ class PlayerAPI{
|
||||||
}
|
}
|
||||||
return substr($output, 0, -2) . "\n";
|
return substr($output, 0, -2) . "\n";
|
||||||
case "loc":
|
case "loc":
|
||||||
if(!($issuer instanceof Player)) return "Please run this command in-game.";
|
if(!($issuer instanceof Player)){
|
||||||
$x = round($issuer->entity->x, 1, PHP_ROUND_HALF_UP);
|
if(isset($args[0])){
|
||||||
$y = round($issuer->entity->y, 1, PHP_ROUND_HALF_UP);
|
goto get_coords_of_others;
|
||||||
$z = round($issuer->entity->z, 1, PHP_ROUND_HALF_UP);
|
}
|
||||||
$level = $issuer->entity->level->getName();
|
return "Usage: /$cmd <username>.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($args[0]) && $this->server->api->ban->isOp($issuer->iusername)){
|
||||||
|
get_coords_of_others:
|
||||||
|
$p = $this->get($args[0]);
|
||||||
|
if(!($p instanceof Player)){
|
||||||
|
return "Player with username '{$args[0]}' is not on server.";
|
||||||
|
}
|
||||||
|
$ent = $p->entity;
|
||||||
|
$username = $p->username;
|
||||||
|
}else{
|
||||||
|
$ent = $issuer->entity;
|
||||||
|
$username = $issuer->username;
|
||||||
|
}
|
||||||
|
|
||||||
|
$x = round($ent->x, 1, PHP_ROUND_HALF_UP);
|
||||||
|
$y = round($ent->y, 1, PHP_ROUND_HALF_UP);
|
||||||
|
$z = round($ent->z, 1, PHP_ROUND_HALF_UP);
|
||||||
|
$level = $ent->level->getName();
|
||||||
$compass = [0 => "X+", 1 => "Z+", 2 => "X-", 3 => "Z-", null => "null"];
|
$compass = [0 => "X+", 1 => "Z+", 2 => "X-", 3 => "Z-", null => "null"];
|
||||||
$direction = $compass[$issuer->entity->getDirection()];
|
$direction = $compass[$ent->getDirection()];
|
||||||
|
|
||||||
$xChunk = $x >> 4;
|
$xChunk = $x >> 4;
|
||||||
$zChunk = $z >> 4;
|
$zChunk = $z >> 4;
|
||||||
|
|
||||||
return "Your coordinates: X: $x ($xChunk), Y: $y, Z: $z ($zChunk), world: $level.\nDirection: $direction";
|
return "$username's coordinates: X: $x ($xChunk), Y: $y, Z: $z ($zChunk), world: $level.\nDirection: $direction";
|
||||||
}
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ class Player{
|
||||||
private $ip;
|
private $ip;
|
||||||
private $port;
|
private $port;
|
||||||
private $counter = [0, 0, 0, 0];
|
private $counter = [0, 0, 0, 0];
|
||||||
private $username;
|
public $username;
|
||||||
public $iusername;
|
public $iusername;
|
||||||
private $eid = false;
|
private $eid = false;
|
||||||
private $startAction = false;
|
private $startAction = false;
|
||||||
|
|
@ -1132,6 +1132,7 @@ class Player{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function makeInvisibleForOnePlayer(Player $player){
|
public function makeInvisibleForOnePlayer(Player $player){
|
||||||
$pk = new RemoveEntityPacket;
|
$pk = new RemoveEntityPacket;
|
||||||
$pk->eid = $this->entity->eid;
|
$pk->eid = $this->entity->eid;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue