DumpMemoryCommand: removed token annoyance, use date/time to identify memory dumps by default

This commit is contained in:
Dylan K. Taylor 2018-03-18 12:17:31 +00:00
parent 357674cb54
commit c243daabe1

View File

@ -27,13 +27,11 @@ use pocketmine\command\CommandSender;
class DumpMemoryCommand extends VanillaCommand{
private static $executions = 0;
public function __construct(string $name){
parent::__construct(
$name,
"Dumps the memory",
"/$name <TOKEN (run once to get it)> [path]"
"/$name [path]"
);
$this->setPermission("pocketmine.command.dumpmemory");
}
@ -43,16 +41,7 @@ class DumpMemoryCommand extends VanillaCommand{
return true;
}
$token = strtoupper(substr(sha1(BOOTUP_RANDOM . ":" . $sender->getServer()->getServerUniqueId() . ":" . self::$executions), 6, 6));
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);
$sender->getServer()->getMemoryManager()->dumpServerMemory($args[0] ?? ($sender->getServer()->getDataPath() . "/memory_dumps/" . date("D_M_j-H.i.s-T_Y")), 48, 80);
return true;
}
}