mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 14:35:35 +00:00
DumpMemoryCommand: removed token annoyance, use date/time to identify memory dumps by default
This commit is contained in:
parent
357674cb54
commit
c243daabe1
@ -27,13 +27,11 @@ use pocketmine\command\CommandSender;
|
|||||||
|
|
||||||
class DumpMemoryCommand extends VanillaCommand{
|
class DumpMemoryCommand extends VanillaCommand{
|
||||||
|
|
||||||
private static $executions = 0;
|
|
||||||
|
|
||||||
public function __construct(string $name){
|
public function __construct(string $name){
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
$name,
|
$name,
|
||||||
"Dumps the memory",
|
"Dumps the memory",
|
||||||
"/$name <TOKEN (run once to get it)> [path]"
|
"/$name [path]"
|
||||||
);
|
);
|
||||||
$this->setPermission("pocketmine.command.dumpmemory");
|
$this->setPermission("pocketmine.command.dumpmemory");
|
||||||
}
|
}
|
||||||
@ -43,16 +41,7 @@ class DumpMemoryCommand extends VanillaCommand{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$token = strtoupper(substr(sha1(BOOTUP_RANDOM . ":" . $sender->getServer()->getServerUniqueId() . ":" . self::$executions), 6, 6));
|
$sender->getServer()->getMemoryManager()->dumpServerMemory($args[0] ?? ($sender->getServer()->getDataPath() . "/memory_dumps/" . date("D_M_j-H.i.s-T_Y")), 48, 80);
|
||||||
|
|
||||||
if(count($args) < 1 or strtoupper($args[0]) !== $token){
|
|
||||||
$sender->sendMessage("Usage: /" . $this->getName() . " " . $token);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
++self::$executions;
|
|
||||||
|
|
||||||
$sender->getServer()->getMemoryManager()->dumpServerMemory($args[1] ?? ($sender->getServer()->getDataPath() . "/memory_dumps/$token"), 48, 80);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user