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{ 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;
} }
} }