mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
Fixed Time, Death and more event issues
This commit is contained in:
parent
11f4096403
commit
a833d92d76
6 changed files with 96 additions and 59 deletions
|
|
@ -29,12 +29,39 @@ class EntityAPI{
|
|||
private $server;
|
||||
function __construct($server){
|
||||
$this->server = $server;
|
||||
$this->server->addHandler("onPlayerDeath", array($this, "handle"), 1);
|
||||
}
|
||||
|
||||
public function init(){
|
||||
$this->server->api->console->register("give", "Give items to a player", array($this, "commandHandler"));
|
||||
}
|
||||
|
||||
public function handle($data, $event){
|
||||
switch($event){
|
||||
case "onPlayerDeath":
|
||||
$message = $data["name"];
|
||||
if(is_numeric($data["cause"]) and isset($this->entities[$data["cause"]])){
|
||||
$e = $this->api->entity->get($data["cause"]);
|
||||
switch($e->class){
|
||||
case ENTITY_PLAYER:
|
||||
$message .= " was killed by ".$e->name;
|
||||
break;
|
||||
default:
|
||||
$message .= " was killed";
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
switch($data["cause"]){
|
||||
default:
|
||||
$message .= " was killed";
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->server->chat(false, $message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function commandHandler($cmd, $params){
|
||||
switch($cmd){
|
||||
case "give":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue