Merge branch 'master' into 0.17-chunks

This commit is contained in:
Dylan K. Taylor 2016-12-01 17:50:12 +00:00
commit ce289cbe25
13 changed files with 29 additions and 30 deletions

View File

@ -160,7 +160,7 @@ class CrashDump{
];
$error["fullFile"] = $error["file"];
$error["file"] = cleanPath($error["file"]);
$error["type"] = isset($errorConversion[$error["type"]]) ? $errorConversion[$error["type"]] : $error["type"];
$error["type"] = $errorConversion[$error["type"]] ?? $error["type"];
if(($pos = strpos($error["message"], "\n")) !== false){
$error["message"] = substr($error["message"], 0, $pos);
}

View File

@ -1153,11 +1153,12 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$pk = new SetPlayerGameTypePacket();
$pk->gamemode = $this->gamemode & 0x01;
$this->dataPacket($pk);
$this->sendSettings();
}else{
Command::broadcastCommandMessage($this, new TranslationContainer("commands.gamemode.success.self", [Server::getGamemodeString($gm)]));
}
$this->sendSettings();
$this->inventory->sendContents($this);
$this->inventory->sendContents($this->getViewers());
$this->inventory->sendHeldItem($this->hasSpawned);
@ -2105,6 +2106,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$block = $target->getSide($packet->face);
if($block->getId() === Block::FIRE){
$this->level->setBlock($block, new Air());
break;
}
$this->lastBreak = microtime(true);
break;
@ -2379,7 +2381,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
];
$damage = [
EntityDamageEvent::MODIFIER_BASE => isset($damageTable[$item->getId()]) ? $damageTable[$item->getId()] : 1,
EntityDamageEvent::MODIFIER_BASE => $damageTable[$item->getId()] ?? 1,
];
if(!$this->canInteract($target, 8)){
@ -2893,15 +2895,12 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$this->dataPacket($pk);
break;
case ProtocolInfo::SET_PLAYER_GAME_TYPE_PACKET:
if($packet->gamemode !== $this->gamemode){
if(!$this->hasPermission("pocketmine.command.gamemode")){
$pk = new SetPlayerGameTypePacket();
$pk->gamemode = $this->gamemode & 0x01;
$this->dataPacket($pk);
$this->sendSettings();
break;
}
$this->setGamemode($packet->gamemode, true);
if($packet->gamemode !== ($this->gamemode & 0x01)){
//GUI gamemode change, set it back to original for now (only possible through client bug or hack with current allowed client permissions)
$pk = new SetPlayerGameTypePacket();
$pk->gamemode = $this->gamemode & 0x01;
$this->dataPacket($pk);
$this->sendSettings();
}
break;
default:

View File

@ -272,7 +272,7 @@ class Item implements ItemIds, \JsonSerializable{
* @return Item
*/
public static function getCreativeItem(int $index){
return isset(Item::$creative[$index]) ? Item::$creative[$index] : null;
return Item::$creative[$index] ?? null;
}
public static function getCreativeItemIndex(Item $item) : int{
@ -597,7 +597,7 @@ class Item implements ItemIds, \JsonSerializable{
public function getNamedTagEntry($name){
$tag = $this->getNamedTag();
if($tag !== null){
return isset($tag->{$name}) ? $tag->{$name} : null;
return $tag->{$name} ?? null;
}
return null;

View File

@ -529,7 +529,7 @@ class Level implements ChunkManager, Metadatable{
* @return Player[]
*/
public function getChunkPlayers(int $chunkX, int $chunkZ) : array{
return isset($this->playerLoaders[$index = Level::chunkHash($chunkX, $chunkZ)]) ? $this->playerLoaders[$index] : [];
return $this->playerLoaders[Level::chunkHash($chunkX, $chunkZ)] ?? [];
}
/**
@ -541,7 +541,7 @@ class Level implements ChunkManager, Metadatable{
* @return ChunkLoader[]
*/
public function getChunkLoaders(int $chunkX, int $chunkZ) : array{
return isset($this->chunkLoaders[$index = Level::chunkHash($chunkX, $chunkZ)]) ? $this->chunkLoaders[$index] : [];
return $this->chunkLoaders[Level::chunkHash($chunkX, $chunkZ)] ?? [];
}
public function addChunkPacket(int $chunkX, int $chunkZ, DataPacket $packet){
@ -885,7 +885,7 @@ class Level implements ChunkManager, Metadatable{
$chunkZ = $loader->getZ() >> 4;
$index = Level::chunkHash($chunkX, $chunkZ);
$existingLoaders = max(0, isset($this->chunkTickList[$index]) ? $this->chunkTickList[$index] : 0);
$existingLoaders = max(0, $this->chunkTickList[$index] ?? 0);
$this->chunkTickList[$index] = $existingLoaders + 1;
for($chunk = 0; $chunk < $chunksPerLoader; ++$chunk){
$dx = mt_rand(-$randRange, $randRange);
@ -1742,7 +1742,7 @@ class Level implements ChunkManager, Metadatable{
* @return Entity
*/
public function getEntity(int $entityId){
return isset($this->entities[$entityId]) ? $this->entities[$entityId] : null;
return $this->entities[$entityId] ?? null;
}
/**
@ -1829,7 +1829,7 @@ class Level implements ChunkManager, Metadatable{
* @return Tile
*/
public function getTileById(int $tileId){
return isset($this->tiles[$tileId]) ? $this->tiles[$tileId] : null;
return $this->tiles[$tileId] ?? null;
}
/**

View File

@ -103,7 +103,7 @@ class SimpleChunkManager implements ChunkManager{
* @return Chunk|null
*/
public function getChunk(int $chunkX, int $chunkZ){
return isset($this->chunks[$index = Level::chunkHash($chunkX, $chunkZ)]) ? $this->chunks[$index] : null;
return $this->chunks[Level::chunkHash($chunkX, $chunkZ)] ?? null;
}
/**

View File

@ -62,6 +62,6 @@ abstract class LevelProviderManager{
public static function getProviderByName($name){
$name = trim(strtolower($name));
return isset(self::$providers[$name]) ? self::$providers[$name] : null;
return self::$providers[$name] ?? null;
}
}

View File

@ -311,7 +311,7 @@ class McRegion extends BaseLevelProvider{
}
public function unloadChunk($x, $z, $safe = true){
$chunk = isset($this->chunks[$index = Level::chunkHash($x, $z)]) ? $this->chunks[$index] : null;
$chunk = $this->chunks[$index = Level::chunkHash($x, $z)] ?? null;
if($chunk instanceof Chunk and $chunk->unload(false, $safe)){
unset($this->chunks[$index]);
return true;

View File

@ -87,9 +87,9 @@ class Flat extends Generator{
$this->preset = $preset;
$preset = explode(";", $preset);
$version = (int) $preset[0];
$blocks = isset($preset[1]) ? $preset[1] : "";
$biome = isset($preset[2]) ? $preset[2] : 1;
$options = isset($preset[3]) ? $preset[3] : "";
$blocks = $preset[1] ?? "";
$biome = $preset[2] ?? 1;
$options = $preset[3] ?? "";
preg_match_all('#^(([0-9]*x|)([0-9]{1,3})(|:[0-9]{0,2}))$#m', str_replace(",", "\n", $blocks), $matches);
$y = 0;
$this->structure = [];

View File

@ -107,7 +107,7 @@ abstract class Biome{
* @return Biome
*/
public static function getBiome($id){
return isset(self::$biomes[$id]) ? self::$biomes[$id] : self::$biomes[self::OCEAN];
return self::$biomes[$id] ?? self::$biomes[self::OCEAN];
}
public function clearPopulators(){

View File

@ -81,6 +81,6 @@ class BiomeSelector{
$rainfall = (int) ($this->getRainfall($x, $z) * 63);
$biomeId = $this->map[$temperature + ($rainfall << 6)];
return isset($this->biomes[$biomeId]) ? $this->biomes[$biomeId] : $this->fallback;
return $this->biomes[$biomeId] ?? $this->fallback;
}
}

View File

@ -290,7 +290,7 @@ class NBT{
throw new \Exception("Syntax error: invalid quote at offset $offset");
}
}elseif($c === "\\"){
$value .= isset($data{$offset + 1}) ? $data{$offset + 1} : "";
$value .= $data{$offset + 1} ?? "";
++$offset;
}elseif($c === "{" and !$inQuotes){
if($value !== ""){

View File

@ -68,7 +68,7 @@ class AutoUpdater{
"api_version" => $response["api_version"],
"build" => $response["build"],
"date" => $response["date"],
"details_url" => isset($response["details_url"]) ? $response["details_url"] : null,
"details_url" => $response["details_url"] ?? null,
"download_url" => $response["download_url"]
];

View File

@ -133,7 +133,7 @@ class MainLogger extends \AttachableThreadedLogger{
}else{
$type = ($errno === E_ERROR or $errno === E_USER_ERROR) ? LogLevel::ERROR : (($errno === E_USER_WARNING or $errno === E_WARNING) ? LogLevel::WARNING : LogLevel::NOTICE);
}
$errno = isset($errorConversion[$errno]) ? $errorConversion[$errno] : $errno;
$errno = $errorConversion[$errno] ?? $errno;
if(($pos = strpos($errstr, "\n")) !== false){
$errstr = substr($errstr, 0, $pos);
}