mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 13:09:44 +00:00
ping will show amount of loaded chunks(+ additional stuff for ops)
This commit is contained in:
parent
9acbf518ea
commit
359f1d34c9
2 changed files with 29 additions and 4 deletions
|
|
@ -123,7 +123,7 @@ 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":
|
||||||
|
$additional = false;
|
||||||
if(!($issuer instanceof Player)){
|
if(!($issuer instanceof Player)){
|
||||||
if(isset($args[0])){
|
if(isset($args[0])){
|
||||||
goto get_ping_of_others;
|
goto get_ping_of_others;
|
||||||
|
|
@ -133,6 +133,7 @@ class PlayerAPI{
|
||||||
|
|
||||||
if(isset($args[0]) && $this->server->api->ban->isOp($issuer->iusername)){
|
if(isset($args[0]) && $this->server->api->ban->isOp($issuer->iusername)){
|
||||||
get_ping_of_others:
|
get_ping_of_others:
|
||||||
|
$additional = true;
|
||||||
$p = $this->get($args[0]);
|
$p = $this->get($args[0]);
|
||||||
if(!($p instanceof Player)){
|
if(!($p instanceof Player)){
|
||||||
return "Player with username '{$args[0]}' is not on server.";
|
return "Player with username '{$args[0]}' is not on server.";
|
||||||
|
|
@ -140,8 +141,18 @@ class PlayerAPI{
|
||||||
}else{
|
}else{
|
||||||
$p = $issuer;
|
$p = $issuer;
|
||||||
}
|
}
|
||||||
|
$ping = round($p->getLag(), 2);
|
||||||
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";
|
$pkLoss = round($p->getPacketLoss() * 100, 2);
|
||||||
|
$transfer = round($p->getBandwidth() / 1024, 2);
|
||||||
|
$additionalInfo = "";
|
||||||
|
if($additional){
|
||||||
|
$arqCnt = count($p->packetAlwaysRecoverQueue);
|
||||||
|
$rqCnt = count($p->recoveryQueue);
|
||||||
|
$emps = $p->entityMovementPacketsPerSecond;
|
||||||
|
$additionalInfo = "ARQ/RQ/EMPS: $arqCnt/$rqCnt/$emps";
|
||||||
|
}
|
||||||
|
$chunksCnt = count($p->chunkDataSent);
|
||||||
|
return "{$p->username}'s ping: {$ping}ms, packet loss {$pkLoss}%, $transfer KB/s. Chunks: $chunksCnt/256\n$additionalInfo";
|
||||||
case "gamemode":
|
case "gamemode":
|
||||||
$player = false;
|
$player = false;
|
||||||
$setgm = false;
|
$setgm = false;
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ class Player{
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $packetAlwaysRecoverQueue = [];
|
public $packetAlwaysRecoverQueue = [];
|
||||||
private $recoveryQueue = [];
|
public $recoveryQueue = [];
|
||||||
private $receiveQueue = [];
|
private $receiveQueue = [];
|
||||||
private $resendQueue = [];
|
private $resendQueue = [];
|
||||||
private $ackQueue = [];
|
private $ackQueue = [];
|
||||||
|
|
@ -93,14 +93,23 @@ class Player{
|
||||||
* @var RakNetPacket
|
* @var RakNetPacket
|
||||||
*/
|
*/
|
||||||
public $entityMovementQueue;
|
public $entityMovementQueue;
|
||||||
|
public $entityMovementQueuePrevSentCnt = 0;
|
||||||
public $entityMovementQueueLength = 0;
|
public $entityMovementQueueLength = 0;
|
||||||
|
/**
|
||||||
|
* Used only for statistic in ping command.
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
public $entityMovementPacketsPerSecond = 0;
|
||||||
|
public $lastEntityMovementPacketsPerSecondRecordedTime = 0;
|
||||||
|
|
||||||
public $blockUpdateQueue;
|
public $blockUpdateQueue;
|
||||||
public $blockUpdateQueueLength = 0;
|
public $blockUpdateQueueLength = 0;
|
||||||
|
public $blockUpdateQueuePrevSentCnt = 0;
|
||||||
public $blockUpdateQueueOrderIndex = 0;
|
public $blockUpdateQueueOrderIndex = 0;
|
||||||
|
|
||||||
public $chatMessagesQueue;
|
public $chatMessagesQueue;
|
||||||
public $chatMessagesQueueLength = 0;
|
public $chatMessagesQueueLength = 0;
|
||||||
|
public $chatMessagesQueuePrevSentCnt = 0;
|
||||||
public $chatMessagesOrderIndex = 0;
|
public $chatMessagesOrderIndex = 0;
|
||||||
public $chunkDataSent = [];
|
public $chunkDataSent = [];
|
||||||
|
|
||||||
|
|
@ -1362,6 +1371,10 @@ class Player{
|
||||||
$this->ackQueue = [];
|
$this->ackQueue = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($time - $this->lastEntityMovementPacketsPerSecondRecordedTime > 1){
|
||||||
|
$this->entityMovementPacketsPerSecond = 0;
|
||||||
|
$this->lastEntityMovementPacketsPerSecondRecordedTime = $time;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->sendingInventoryRequired){
|
if($this->sendingInventoryRequired){
|
||||||
//console("inv resent");
|
//console("inv resent");
|
||||||
|
|
@ -1597,6 +1610,7 @@ class Player{
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->entityMovementQueueLength += 6*$packets + $len;
|
$this->entityMovementQueueLength += 6*$packets + $len;
|
||||||
|
$this->entityMovementPacketsPerSecond += $packets;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue