mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 18:59:00 +00:00
PHP7 changes
This commit is contained in:
parent
7f8b39a63c
commit
b47cebb1d5
@ -127,8 +127,12 @@ namespace pocketmine {
|
|||||||
define("pocketmine\\DATA", isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR);
|
define("pocketmine\\DATA", isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR);
|
||||||
define("pocketmine\\PLUGIN_PATH", isset($opts["plugins"]) ? $opts["plugins"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR);
|
define("pocketmine\\PLUGIN_PATH", isset($opts["plugins"]) ? $opts["plugins"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
|
|
||||||
|
echo "HAHA";
|
||||||
Terminal::init();
|
Terminal::init();
|
||||||
|
|
||||||
|
echo "HAHA";
|
||||||
|
|
||||||
define("pocketmine\\ANSI", Terminal::hasFormattingCodes());
|
define("pocketmine\\ANSI", Terminal::hasFormattingCodes());
|
||||||
|
|
||||||
if(!file_exists(\pocketmine\DATA)){
|
if(!file_exists(\pocketmine\DATA)){
|
||||||
|
@ -2039,7 +2039,8 @@ class Server{
|
|||||||
$this->properties->save();
|
$this->properties->save();
|
||||||
|
|
||||||
$this->getLogger()->debug("Closing console");
|
$this->getLogger()->debug("Closing console");
|
||||||
$this->console->kill();
|
$this->console->shutdown();
|
||||||
|
$this->console->detach();
|
||||||
|
|
||||||
$this->getLogger()->debug("Stopping network interfaces");
|
$this->getLogger()->debug("Stopping network interfaces");
|
||||||
foreach($this->network->getInterfaces() as $interface){
|
foreach($this->network->getInterfaces() as $interface){
|
||||||
|
@ -25,26 +25,36 @@ use pocketmine\Thread;
|
|||||||
|
|
||||||
class CommandReader extends Thread{
|
class CommandReader extends Thread{
|
||||||
private $readline;
|
private $readline;
|
||||||
|
|
||||||
/** @var \Threaded */
|
/** @var \Threaded */
|
||||||
protected $buffer;
|
protected $buffer;
|
||||||
|
private $shutdown = false;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
$this->buffer = \ThreadedFactory::create();
|
$this->buffer = \ThreadedFactory::create();
|
||||||
$this->start();
|
$this->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function shutdown(){
|
||||||
|
$this->shutdown = true;
|
||||||
|
}
|
||||||
|
|
||||||
private function readLine(){
|
private function readLine(){
|
||||||
if(!$this->readline){
|
if(!$this->readline){
|
||||||
$line = trim(fgets(fopen("php://stdin", "r")));
|
global $stdin;
|
||||||
|
|
||||||
|
if(!is_resource($stdin)){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return trim(fgets($stdin));
|
||||||
}else{
|
}else{
|
||||||
$line = trim(readline("> "));
|
$line = trim(readline("> "));
|
||||||
if($line != ""){
|
if($line != ""){
|
||||||
readline_add_history($line);
|
readline_add_history($line);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $line;
|
return $line;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,15 +75,18 @@ class CommandReader extends Thread{
|
|||||||
if(extension_loaded("readline") and !isset($opts["disable-readline"])){
|
if(extension_loaded("readline") and !isset($opts["disable-readline"])){
|
||||||
$this->readline = true;
|
$this->readline = true;
|
||||||
}else{
|
}else{
|
||||||
|
global $stdin;
|
||||||
|
$stdin = fopen("php://stdin", "r");
|
||||||
|
stream_set_blocking($stdin, 0);
|
||||||
$this->readline = false;
|
$this->readline = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$lastLine = microtime(true);
|
$lastLine = microtime(true);
|
||||||
while(true){
|
while(!$this->shutdown){
|
||||||
if(($line = $this->readLine()) !== ""){
|
if(($line = $this->readLine()) !== ""){
|
||||||
$this->buffer[] = preg_replace("#\\x1b\\x5b([^\\x1b]*\\x7e|[\\x40-\\x50])#", "", $line);
|
$this->buffer[] = preg_replace("#\\x1b\\x5b([^\\x1b]*\\x7e|[\\x40-\\x50])#", "", $line);
|
||||||
}elseif((microtime(true) - $lastLine) <= 0.1){ //Non blocking! Sleep to save CPU
|
}elseif(!$this->shutdown and (microtime(true) - $lastLine) <= 0.1){ //Non blocking! Sleep to save CPU
|
||||||
usleep(40000);
|
usleep(10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
$lastLine = microtime(true);
|
$lastLine = microtime(true);
|
||||||
|
@ -220,7 +220,7 @@ class Utils{
|
|||||||
self::$os = "other";
|
self::$os = "other";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$os;
|
return self::$os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user