mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 21:19:44 +00:00
Fix ^^
This commit is contained in:
parent
e0727d2e57
commit
3cae25cebd
1 changed files with 18 additions and 14 deletions
|
|
@ -37,10 +37,9 @@ class ConsoleAPI{
|
||||||
|
|
||||||
public function init(){
|
public function init(){
|
||||||
if(HAS_EVENT){
|
if(HAS_EVENT){
|
||||||
$this->event = new EventBase();
|
$this->loop = new EventBase();
|
||||||
$event = new Event($this->event, STDIN, Event::READ | Event::PERSIST, array($this, "readLine"));
|
$event = new Event($this->loop, STDIN, Event::READ | Event::PERSIST, array($this, "readLine"));
|
||||||
$event->add();
|
$event->add();
|
||||||
$this->event->loop(EventBase::LOOP_NONBLOCK);
|
|
||||||
}else{
|
}else{
|
||||||
$this->event = $this->server->event("server.tick", array($this, "handle"));
|
$this->event = $this->server->event("server.tick", array($this, "handle"));
|
||||||
$this->loop = new ConsoleLoop();
|
$this->loop = new ConsoleLoop();
|
||||||
|
|
@ -70,6 +69,7 @@ class ConsoleAPI{
|
||||||
|
|
||||||
function __destruct(){
|
function __destruct(){
|
||||||
if(HAS_EVENT){
|
if(HAS_EVENT){
|
||||||
|
$this->server->deleteEvent($this->event);
|
||||||
$this->loop->stop();
|
$this->loop->stop();
|
||||||
}else{
|
}else{
|
||||||
$this->server->deleteEvent($this->event);
|
$this->server->deleteEvent($this->event);
|
||||||
|
|
@ -247,6 +247,9 @@ class ConsoleAPI{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle($time){
|
public function handle($time){
|
||||||
|
if(HAS_EVENT){
|
||||||
|
$this->loop->loop(EventBase::LOOP_NONBLOCK);
|
||||||
|
}else{
|
||||||
if($this->loop->line !== false){
|
if($this->loop->line !== false){
|
||||||
$line = trim($this->loop->line);
|
$line = trim($this->loop->line);
|
||||||
$this->loop->line = false;
|
$this->loop->line = false;
|
||||||
|
|
@ -261,6 +264,7 @@ class ConsoleAPI{
|
||||||
$this->loop->notify();
|
$this->loop->notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue