Merge remote-tracking branch 'origin/master' into Faster-Network

This commit is contained in:
Shoghi Cervantes 2013-12-17 11:01:12 +01:00
commit e6aeb03ec5
7 changed files with 53 additions and 16 deletions

View File

@ -21,9 +21,16 @@
class BanAPI{ class BanAPI{
private $server; private $server;
/*
* I would use PHPDoc Template here but PHPStorm does not recognise it. - @sekjun9878
*/
/** @var Config */
private $whitelist; private $whitelist;
/** @var Config */
private $banned; private $banned;
/** @var Config */
private $ops; private $ops;
/** @var Config */
private $bannedIPs; private $bannedIPs;
private $cmdWL = array();//Command WhiteList private $cmdWL = array();//Command WhiteList
function __construct(){ function __construct(){
@ -349,10 +356,13 @@ class BanAPI{
public function isIPBanned($ip){ public function isIPBanned($ip){
if($this->server->api->dhandle("api.ban.ip.check", $ip) === false){ if($this->server->api->dhandle("api.ban.ip.check", $ip) === false){
return true; return true;
}elseif($this->bannedIPs->exists($ip)){ }elseif($this->bannedIPs->exists($ip, true)){
return true; return true;
} }
return false; else
{
return false;
}
} }
/** /**
@ -364,10 +374,13 @@ class BanAPI{
$username = strtolower($username); $username = strtolower($username);
if($this->server->api->dhandle("api.ban.check", $username) === false){ if($this->server->api->dhandle("api.ban.check", $username) === false){
return true; return true;
}elseif($this->banned->exists($username)){ }elseif($this->banned->exists($username, true)){
return true; return true;
} }
return false; else
{
return false;
}
} }
/** /**
@ -381,7 +394,7 @@ class BanAPI{
return true; return true;
}elseif($this->server->api->dhandle("api.ban.whitelist.check", $username) === false){ }elseif($this->server->api->dhandle("api.ban.whitelist.check", $username) === false){
return true; return true;
}elseif($this->whitelist->exists($username)){ }elseif($this->whitelist->exists($username, true)){
return true; return true;
} }
return false; return false;

View File

@ -169,7 +169,7 @@ define("STONE_WALL", 139);
define("COBBLESTONE_WALL", 139); define("COBBLESTONE_WALL", 139);
define("CARROT_BLOCK", 141); define("CARROT_BLOCK", 141);
define("POTATO_BLOCK", 141); define("POTATO_BLOCK", 142);
define("QUARTZ_BLOCK", 155); define("QUARTZ_BLOCK", 155);
define("QUARTZ_STAIRS", 156); define("QUARTZ_STAIRS", 156);

View File

@ -149,7 +149,7 @@ define("SPAWN_EGG", 383);
define("CARROT", 391); define("CARROT", 391);
define("CARROTS", 391); define("CARROTS", 391);
define("POTATO", 392); define("POTATO", 392);
define("POTATOES", 392); define("POTATOES", 392);//@shoghicp Why the heck do we need plural redundant Item ID here????
define("BAKED_POTATO", 393); define("BAKED_POTATO", 393);
define("BAKED_POTATOES", 393); define("BAKED_POTATOES", 393);

View File

@ -25,4 +25,15 @@ class LitPumpkinBlock extends SolidBlock{
$this->hardness = 5; $this->hardness = 5;
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$faces = array(
0 => 4,
1 => 2,
2 => 5,
3 => 3,
);
$this->meta = $faces[$player->entity->getDirection()];
$this->level->setBlock($block, $this, true, false, true);
return true;
}
} }

View File

@ -167,7 +167,7 @@ class Config{
} }
public function &get($k){ public function &get($k){
if($this->correct === false or !isset($this->config[$k])){ if(isset($this->correct) and ($this->correct === false or !isset($this->config[$k]))){
$false = false; $false = false;
return $false; return $false;
} }
@ -182,8 +182,20 @@ class Config{
$this->config = $v; $this->config = $v;
} }
public function exists($k){ /**
return isset($this->config[$k]); * @param mixed $k
* @param bool $lowercase If set, searches Config in single-case / lowercase.
*
* @return boolean
*/
public function exists($k, $lowercase = false){
if($lowercase === true)://Take this ridiculously retarded IF formatting! - @sekjun98888877777778888888888888
$k = strtolower($k);//Convert requested key to lower
$array = array_change_key_case($this->config, CASE_LOWER);//Change all keys in array to lower
return isset($array[$k]);//Find $k in modified array
else:
return isset($this->config[$k]);
endif;
} }
public function remove($k){ public function remove($k){

View File

@ -239,7 +239,7 @@ class Entity extends Position{
$time = microtime(true); $time = microtime(true);
if($this->class === ENTITY_PLAYER and ($this->player instanceof Player) and $this->player->spawned === true and $this->player->blocked !== true){ if($this->class === ENTITY_PLAYER and ($this->player instanceof Player) and $this->player->spawned === true and $this->player->blocked !== true){
foreach($this->server->api->entity->getRadius($this, 1.5, ENTITY_ITEM) as $item){ foreach($this->server->api->entity->getRadius($this, 1.5, ENTITY_ITEM) as $item){
if($item->spawntime !== -1 and ($time - $item->spawntime) >= 0.6){ if($item->spawntime > 0 and ($time - $item->spawntime) >= 0.6){
if((($this->player->gamemode & 0x01) === 1 or $this->player->hasSpace($item->type, $item->meta, $item->stack) === true) and $this->server->api->dhandle("player.pickup", array( if((($this->player->gamemode & 0x01) === 1 or $this->player->hasSpace($item->type, $item->meta, $item->stack) === true) and $this->server->api->dhandle("player.pickup", array(
"eid" => $this->player->eid, "eid" => $this->player->eid,
"player" => $this->player, "player" => $this->player,
@ -248,8 +248,9 @@ class Entity extends Position{
"meta" => $item->meta, "meta" => $item->meta,
"target" => $item->eid "target" => $item->eid
)) !== false){ )) !== false){
$item->spawntime = -1; $item->close();
$this->server->schedule(15, array($item, "close")); //$item->spawntime = 0;
//$this->server->schedule(15, array($item, "close"));
} }
} }
} }

View File

@ -46,7 +46,7 @@ class Explosion{
"level" => $this->level, "level" => $this->level,
"source" => $this->source, "source" => $this->source,
"size" => $this->size "size" => $this->size
))){ )) === false){
return false; return false;
} }