Merge branch 'master' of github.com:PocketMine/PocketMine-MP

This commit is contained in:
Shoghi Cervantes 2014-01-13 03:35:56 +01:00
commit 6c5356fc80
7 changed files with 156 additions and 42 deletions

View File

@ -237,4 +237,9 @@ class LevelAPI{
} }
} }
public function getAll()
{
return $this->levels;
}
} }

View File

@ -402,7 +402,7 @@ class PlayerAPI{
public function spawnToAllPlayers(Player $player){ public function spawnToAllPlayers(Player $player){
foreach($this->getAll() as $p){ foreach($this->getAll() as $p){
if($p !== $player and ($p->entity instanceof Entity)){ if($p !== $player and ($p->entity instanceof Entity) and ($player->entity instanceof Entity)){
$player->entity->spawn($p); $player->entity->spawn($p);
if($p->level !== $player->level){ if($p->level !== $player->level){
$p->dataPacket(MC_MOVE_ENTITY_POSROT, array( $p->dataPacket(MC_MOVE_ENTITY_POSROT, array(

View File

@ -44,6 +44,7 @@ class Player{
private $startAction = false; private $startAction = false;
private $isSleeping = false; private $isSleeping = false;
public $data; public $data;
/** @var \Entity */
public $entity = false; public $entity = false;
public $auth = false; public $auth = false;
public $CID; public $CID;
@ -78,6 +79,8 @@ class Player{
private $chunkCount = array(); private $chunkCount = array();
private $received = array(); private $received = array();
public $realmsData = array(); public $realmsData = array();
/** @var \Level */
public $level;
public function __get($name){ public function __get($name){
if(isset($this->{$name})){ if(isset($this->{$name})){

View File

@ -280,5 +280,5 @@ mv php5/bin/php bin/php
rm -r -f php5/ >> "$DIR/install.log" 2>&1 rm -r -f php5/ >> "$DIR/install.log" 2>&1
date >> "$DIR/install.log" 2>&1 date >> "$DIR/install.log" 2>&1
echo " done!" echo " done!"
echo "[PocketMine] You should start the server now using \"./start.sh\."" echo "[PocketMine] You should start the server now using \"./start.sh.\""
echo "[PocketMine] If it doesn't work, please send the \"install.log\" file to the Bug Tracker." echo "[PocketMine] If it doesn't work, please send the \"install.log\" file to the Bug Tracker."

View File

@ -113,6 +113,10 @@ class LavaBlock extends LiquidBlock{
if($sb instanceof LavaBlock){ if($sb instanceof LavaBlock){
$tlevel = $sb->meta & 0x07; $tlevel = $sb->meta & 0x07;
if($tlevel != 0x00){ if($tlevel != 0x00){
for ($s = 0; $s <= 5; $s++) {
$ssb = $sb->getSide($s);
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 40, BLOCK_UPDATE_NORMAL);
}
$this->level->setBlock($sb, new AirBlock(), false, false, true); $this->level->setBlock($sb, new AirBlock(), false, false, true);
} }
} }
@ -120,6 +124,10 @@ class LavaBlock extends LiquidBlock{
if($b instanceof LavaBlock){ if($b instanceof LavaBlock){
$tlevel = $b->meta & 0x07; $tlevel = $b->meta & 0x07;
if($tlevel != 0x00){ if($tlevel != 0x00){
for ($s = 0; $s <= 5; $s++) {
$ssb = $sb->getSide($s);
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 40, BLOCK_UPDATE_NORMAL);
}
$this->level->setBlock($b, new AirBlock(), false, false, true); $this->level->setBlock($b, new AirBlock(), false, false, true);
} }
} }

View File

@ -119,6 +119,10 @@ class WaterBlock extends LiquidBlock{
if($sb instanceof WaterBlock){ if($sb instanceof WaterBlock){
$tlevel = $sb->meta & 0x07; $tlevel = $sb->meta & 0x07;
if($tlevel != 0x00){ if($tlevel != 0x00){
for ($s = 0; $s <= 5; $s++) {
$ssb = $sb->getSide($s);
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
}
$this->level->setBlock($sb, new AirBlock(), false, false, true); $this->level->setBlock($sb, new AirBlock(), false, false, true);
} }
} }
@ -126,6 +130,10 @@ class WaterBlock extends LiquidBlock{
if($b instanceof WaterBlock){ if($b instanceof WaterBlock){
$tlevel = $b->meta & 0x07; $tlevel = $b->meta & 0x07;
if($tlevel != 0x00){ if($tlevel != 0x00){
for ($s = 0; $s <= 5; $s++) {
$ssb = $sb->getSide($s);
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
}
$this->level->setBlock($b, new AirBlock(), false, false, true); $this->level->setBlock($b, new AirBlock(), false, false, true);
} }
} }

View File

@ -28,11 +28,29 @@ define("CONFIG_YAML", 2); // .yml, .yaml
define("CONFIG_SERIALIZED", 4); // .sl define("CONFIG_SERIALIZED", 4); // .sl
define("CONFIG_LIST", 5); // .txt, .list define("CONFIG_LIST", 5); // .txt, .list
/**
* Class Config
*
* Config Class for simple config manipulation of multiple formats.
*/
class Config{ class Config{
/**
* @var array
*/
private $config; private $config;
/**
* @var string
*/
private $file; private $file;
/**
* @var boolean
*/
private $correct; private $correct;
/**
* @var integer
*/
private $type = CONFIG_DETECT; private $type = CONFIG_DETECT;
public static $formats = array( public static $formats = array(
"properties" => CONFIG_PROPERTIES, "properties" => CONFIG_PROPERTIES,
"cnf" => CONFIG_CNF, "cnf" => CONFIG_CNF,
@ -49,6 +67,13 @@ class Config{
"txt" => CONFIG_LIST, "txt" => CONFIG_LIST,
"list" => CONFIG_LIST, "list" => CONFIG_LIST,
); );
/**
* @param string $file
* @param int $type
* @param array $default
* @param null|boolean $correct
*/
public function __construct($file, $type = CONFIG_DETECT, $default = array(), &$correct = null){ public function __construct($file, $type = CONFIG_DETECT, $default = array(), &$correct = null){
$this->load($file, $type, $default); $this->load($file, $type, $default);
$correct = $this->check(); $correct = $this->check();
@ -62,6 +87,13 @@ class Config{
$correct = $this->check(); $correct = $this->check();
} }
/**
* @param string $file
* @param int $type
* @param array $default
*
* @return boolean
*/
public function load($file, $type = CONFIG_DETECT, $default = array()){ public function load($file, $type = CONFIG_DETECT, $default = array()){
$this->correct = true; $this->correct = true;
$this->type = (int) $type; $this->type = (int) $type;
@ -119,10 +151,16 @@ class Config{
return true; return true;
} }
/**
* @return boolean
*/
public function check(){ public function check(){
return $this->correct === true; return $this->correct === true;
} }
/**
* @return boolean
*/
public function save(){ public function save(){
if($this->correct === true){ if($this->correct === true){
switch($this->type){ switch($this->type){
@ -150,22 +188,44 @@ class Config{
} }
} }
/**
* @param $k
*
* @return boolean|mixed
*/
public function &__get($k){ public function &__get($k){
return $this->get($k); return $this->get($k);
} }
/**
* @param $k
* @param $v
*/
public function __set($k, $v){ public function __set($k, $v){
return $this->set($k, $v); $this->set($k, $v);
} }
/**
* @param $k
*
* @return boolean
*/
public function __isset($k){ public function __isset($k){
return $this->exists($k); return $this->exists($k);
} }
/**
* @param $k
*/
public function __unset($k){ public function __unset($k){
return $this->remove($k); $this->remove($k);
} }
/**
* @param $k
*
* @return boolean|mixed
*/
public function &get($k){ public function &get($k){
if(isset($this->correct) and ($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;
@ -174,16 +234,23 @@ class Config{
return $this->config[$k]; return $this->config[$k];
} }
/**
* @param $k
* @param bool $v
*/
public function set($k, $v = true){ public function set($k, $v = true){
$this->config[$k] = $v; $this->config[$k] = $v;
} }
/**
* @param array $v
*/
public function setAll($v){ public function setAll($v){
$this->config = $v; $this->config = $v;
} }
/** /**
* @param mixed $k * @param $k
* @param bool $lowercase If set, searches Config in single-case / lowercase. * @param bool $lowercase If set, searches Config in single-case / lowercase.
* *
* @return boolean * @return boolean
@ -198,14 +265,28 @@ class Config{
endif; endif;
} }
/**
* @param $k
*/
public function remove($k){ public function remove($k){
unset($this->config[$k]); unset($this->config[$k]);
} }
/**
* @param bool $keys
*
* @return array
*/
public function getAll($keys = false){ public function getAll($keys = false){
return ($keys === true ? array_keys($this->config):$this->config); return ($keys === true ? array_keys($this->config):$this->config);
} }
/**
* @param $default
* @param $data
*
* @return integer
*/
private function fillDefaults($default, &$data){ private function fillDefaults($default, &$data){
$changed = 0; $changed = 0;
foreach($default as $k => $v){ foreach($default as $k => $v){
@ -222,6 +303,9 @@ class Config{
return $changed; return $changed;
} }
/**
* @param $content
*/
private function parseList($content){ private function parseList($content){
foreach(explode("\n", trim(str_replace("\r\n", "\n", $content))) as $v){ foreach(explode("\n", trim(str_replace("\r\n", "\n", $content))) as $v){
$v = trim($v); $v = trim($v);
@ -232,6 +316,9 @@ class Config{
} }
} }
/**
* @return string
*/
private function writeProperties(){ private function writeProperties(){
$content = "#Properties Config file\r\n#".date("D M j H:i:s T Y")."\r\n"; $content = "#Properties Config file\r\n#".date("D M j H:i:s T Y")."\r\n";
foreach($this->config as $k => $v){ foreach($this->config as $k => $v){
@ -245,6 +332,9 @@ class Config{
return $content; return $content;
} }
/**
* @param $content
*/
private function parseProperties($content){ private function parseProperties($content){
if(preg_match_all('/([a-zA-Z0-9\-_\.]*)=([^\r\n]*)/u', $content, $matches) > 0){ //false or 0 matches if(preg_match_all('/([a-zA-Z0-9\-_\.]*)=([^\r\n]*)/u', $content, $matches) > 0){ //false or 0 matches
foreach($matches[1] as $i => $k){ foreach($matches[1] as $i => $k){