mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
Posibility of changing data for handlers, and canceling it
This commit is contained in:
parent
bf24a937b2
commit
504b37cfaa
7 changed files with 72 additions and 21 deletions
|
|
@ -192,20 +192,25 @@ class PocketMinecraftServer extends stdClass{
|
|||
return $this->handCnt++;
|
||||
}
|
||||
|
||||
public function handle($event, $data){
|
||||
public function handle($event, &$data){
|
||||
$this->preparedSQL->selectHandlers->reset();
|
||||
$this->preparedSQL->selectHandlers->clear();
|
||||
$this->preparedSQL->selectHandlers->bindValue(":name", $event, SQLITE3_TEXT);
|
||||
$handlers = $this->preparedSQL->selectHandlers->execute();
|
||||
if($handlers === false or $handlers === true){
|
||||
return $this->trigger($event, $data);
|
||||
}
|
||||
$result = true;
|
||||
while(false !== ($hn = $handlers->fetchArray(SQLITE3_ASSOC)) and $result !== false){
|
||||
$hnid = (int) $hn["ID"];
|
||||
$result = call_user_func($this->handlers[$hnid], $data, $event);
|
||||
if($handlers !== false and $handlers !== true){
|
||||
while(false !== ($hn = $handlers->fetchArray(SQLITE3_ASSOC)) and $result !== false){
|
||||
$handler = $this->handlers[(int) $hn["ID"]];
|
||||
if(is_array($handler)){
|
||||
$method = $handler[1];
|
||||
$result = $handler[0]->$method($data, $event);
|
||||
}else{
|
||||
$result = $handler($data, $event);
|
||||
}
|
||||
}
|
||||
}
|
||||
$handlers->finalize();
|
||||
$handlers->finalize();
|
||||
$this->trigger($event, $data);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue