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){
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);
if($p->level !== $player->level){
$p->dataPacket(MC_MOVE_ENTITY_POSROT, array(

View File

@ -44,6 +44,7 @@ class Player{
private $startAction = false;
private $isSleeping = false;
public $data;
/** @var \Entity */
public $entity = false;
public $auth = false;
public $CID;
@ -78,6 +79,8 @@ class Player{
private $chunkCount = array();
private $received = array();
public $realmsData = array();
/** @var \Level */
public $level;
public function __get($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
date >> "$DIR/install.log" 2>&1
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."

View File

@ -113,6 +113,10 @@ class LavaBlock extends LiquidBlock{
if($sb instanceof LavaBlock){
$tlevel = $sb->meta & 0x07;
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);
}
}
@ -120,6 +124,10 @@ class LavaBlock extends LiquidBlock{
if($b instanceof LavaBlock){
$tlevel = $b->meta & 0x07;
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);
}
}

View File

@ -119,6 +119,10 @@ class WaterBlock extends LiquidBlock{
if($sb instanceof WaterBlock){
$tlevel = $sb->meta & 0x07;
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);
}
}
@ -126,6 +130,10 @@ class WaterBlock extends LiquidBlock{
if($b instanceof WaterBlock){
$tlevel = $b->meta & 0x07;
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);
}
}

View File

@ -28,11 +28,29 @@ define("CONFIG_YAML", 2); // .yml, .yaml
define("CONFIG_SERIALIZED", 4); // .sl
define("CONFIG_LIST", 5); // .txt, .list
/**
* Class Config
*
* Config Class for simple config manipulation of multiple formats.
*/
class Config{
private $config;
private $file;
private $correct;
private $type = CONFIG_DETECT;
/**
* @var array
*/
private $config;
/**
* @var string
*/
private $file;
/**
* @var boolean
*/
private $correct;
/**
* @var integer
*/
private $type = CONFIG_DETECT;
public static $formats = array(
"properties" => CONFIG_PROPERTIES,
"cnf" => CONFIG_CNF,
@ -49,7 +67,14 @@ class Config{
"txt" => CONFIG_LIST,
"list" => CONFIG_LIST,
);
public function __construct($file, $type = CONFIG_DETECT, $default = array(), &$correct = null){
/**
* @param string $file
* @param int $type
* @param array $default
* @param null|boolean $correct
*/
public function __construct($file, $type = CONFIG_DETECT, $default = array(), &$correct = null){
$this->load($file, $type, $default);
$correct = $this->check();
}
@ -61,8 +86,15 @@ class Config{
$this->load($this->file);
$correct = $this->check();
}
public function load($file, $type = CONFIG_DETECT, $default = array()){
/**
* @param string $file
* @param int $type
* @param array $default
*
* @return boolean
*/
public function load($file, $type = CONFIG_DETECT, $default = array()){
$this->correct = true;
$this->type = (int) $type;
$this->file = $file;
@ -118,12 +150,18 @@ class Config{
}
return true;
}
public function check(){
/**
* @return boolean
*/
public function check(){
return $this->correct === true;
}
public function save(){
/**
* @return boolean
*/
public function save(){
if($this->correct === true){
switch($this->type){
case CONFIG_PROPERTIES:
@ -149,41 +187,70 @@ class Config{
return false;
}
}
public function &__get($k){
/**
* @param $k
*
* @return boolean|mixed
*/
public function &__get($k){
return $this->get($k);
}
public function __set($k, $v){
return $this->set($k, $v);
/**
* @param $k
* @param $v
*/
public function __set($k, $v){
$this->set($k, $v);
}
public function __isset($k){
/**
* @param $k
*
* @return boolean
*/
public function __isset($k){
return $this->exists($k);
}
public function __unset($k){
return $this->remove($k);
/**
* @param $k
*/
public function __unset($k){
$this->remove($k);
}
public function &get($k){
/**
* @param $k
*
* @return boolean|mixed
*/
public function &get($k){
if(isset($this->correct) and ($this->correct === false or !isset($this->config[$k]))){
$false = false;
return $false;
}
return $this->config[$k];
}
public function set($k, $v = true){
/**
* @param $k
* @param bool $v
*/
public function set($k, $v = true){
$this->config[$k] = $v;
}
public function setAll($v){
/**
* @param array $v
*/
public function setAll($v){
$this->config = $v;
}
/**
* @param mixed $k
* @param $k
* @param bool $lowercase If set, searches Config in single-case / lowercase.
*
* @return boolean
@ -197,16 +264,30 @@ class Config{
return isset($this->config[$k]);
endif;
}
public function remove($k){
/**
* @param $k
*/
public function remove($k){
unset($this->config[$k]);
}
public function getAll($keys = false){
/**
* @param bool $keys
*
* @return array
*/
public function getAll($keys = false){
return ($keys === true ? array_keys($this->config):$this->config);
}
private function fillDefaults($default, &$data){
/**
* @param $default
* @param $data
*
* @return integer
*/
private function fillDefaults($default, &$data){
$changed = 0;
foreach($default as $k => $v){
if(is_array($v)){
@ -222,7 +303,10 @@ class Config{
return $changed;
}
private function parseList($content){
/**
* @param $content
*/
private function parseList($content){
foreach(explode("\n", trim(str_replace("\r\n", "\n", $content))) as $v){
$v = trim($v);
if($v == ""){
@ -231,8 +315,11 @@ class Config{
$this->config[$v] = true;
}
}
private function writeProperties(){
/**
* @return string
*/
private function writeProperties(){
$content = "#Properties Config file\r\n#".date("D M j H:i:s T Y")."\r\n";
foreach($this->config as $k => $v){
if(is_bool($v) === true){
@ -244,8 +331,11 @@ class Config{
}
return $content;
}
private function parseProperties($content){
/**
* @param $content
*/
private function parseProperties($content){
if(preg_match_all('/([a-zA-Z0-9\-_\.]*)=([^\r\n]*)/u', $content, $matches) > 0){ //false or 0 matches
foreach($matches[1] as $i => $k){
$v = trim($matches[2][$i]);