Skip to content

Commit

Permalink
fix pmmp#104
Browse files Browse the repository at this point in the history
  • Loading branch information
robske110 committed Nov 19, 2016
1 parent a96b7b6 commit 73c9a69
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/pocketmine/command/CommandReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
namespace pocketmine\command;

use pocketmine\Thread;
use pocketmine\utils\Utils;

class CommandReader extends Thread{
private $readline;
Expand All @@ -34,6 +35,7 @@ public function __construct(){
$opts = getopt("", ["disable-readline"]);
$this->readline = (extension_loaded("readline") and !isset($opts["disable-readline"]));
$this->start();
echo("FROM COMMANDREADER THREAD UTILS::->".Utils::getOS()."\n");
}

public function shutdown(){
Expand All @@ -51,10 +53,16 @@ private function readLine(){
global $stdin;

if(!is_resource($stdin)){
$this->initStdin();
$this->initStdin();
}

return trim(fgets($stdin));

$fgets = fgets($stdin);

if(Utils::getOS() == "win" && $fgets === false){ //windows sucks
$this->initStdin();
}

return trim($fgets);
}else{
$line = trim(readline("> "));
if($line != ""){
Expand Down Expand Up @@ -96,7 +104,7 @@ public function run(){
$lastLine = microtime(true);
}
global $stdin;
if(is_resource($stdin)){
if(!$this->readline && is_resource($stdin)){
fclose($stdin);
}
}
Expand Down

0 comments on commit 73c9a69

Please sign in to comment.