Posibility of changing data for handlers, and canceling it

This commit is contained in:
Shoghi Cervantes Pueyo
2012-12-25 20:15:08 +01:00
parent bf24a937b2
commit 504b37cfaa
7 changed files with 72 additions and 21 deletions

View File

@ -39,9 +39,9 @@ class BlockAPI{
}
public function init(){
$this->server->addHandler("world.block.update", array($this, "updateBlockRemote"));
$this->server->addHandler("player.block.break", array($this, "blockBreak"));
$this->server->addHandler("player.block.action", array($this, "blockAction"));
$this->server->addHandler("world.block.update", array($this, "updateBlockRemote"), 1);
$this->server->addHandler("player.block.break", array($this, "blockBreak"), 1);
$this->server->addHandler("player.block.action", array($this, "blockAction"), 1);
}
public function blockBreak($data, $event){

View File

@ -29,7 +29,7 @@ class EntityAPI{
private $server;
function __construct($server){
$this->server = $server;
$this->server->addHandler("onPlayerDeath", array($this, "handle"), 1);
$this->server->addHandler("player.death", array($this, "handle"), 1);
}
public function init(){
@ -38,7 +38,7 @@ class EntityAPI{
public function handle($data, $event){
switch($event){
case "onPlayerDeath":
case "player.death":
$message = $data["name"];
if(is_numeric($data["cause"]) and isset($this->entities[$data["cause"]])){
$e = $this->api->entity->get($data["cause"]);

View File

@ -57,10 +57,10 @@ class PluginAPI extends stdClass{
}
$info[$i] = $v;
}
if(!isset($info["name"]) or !isset($info["version"]) or !isset($info["class"])){
if(!isset($info["name"]) or !isset($info["version"]) or !isset($info["class"]) or !isset($info["author"])){
console("[ERROR] [PluginAPI] Failed parsing of ".basename($file));
}
console("[INFO] [PluginAPI] Loading plugin \"".$info["name"]."\" ".$info["version"]);
console("[INFO] [PluginAPI] Loading plugin \"".$info["name"]."\" ".$info["version"]." by ".$info["author"]);
if(eval($content) === false or !class_exists($info["class"])){
console("[ERROR] [PluginAPI] Failed loading plugin");
}