mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-04 00:59:51 +00:00
Merge branch 'master' into 0.17-chunks
This commit is contained in:
commit
ce289cbe25
@ -160,7 +160,7 @@ class CrashDump{
|
|||||||
];
|
];
|
||||||
$error["fullFile"] = $error["file"];
|
$error["fullFile"] = $error["file"];
|
||||||
$error["file"] = cleanPath($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){
|
if(($pos = strpos($error["message"], "\n")) !== false){
|
||||||
$error["message"] = substr($error["message"], 0, $pos);
|
$error["message"] = substr($error["message"], 0, $pos);
|
||||||
}
|
}
|
||||||
|
@ -1153,11 +1153,12 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
$pk = new SetPlayerGameTypePacket();
|
$pk = new SetPlayerGameTypePacket();
|
||||||
$pk->gamemode = $this->gamemode & 0x01;
|
$pk->gamemode = $this->gamemode & 0x01;
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);
|
||||||
$this->sendSettings();
|
|
||||||
}else{
|
}else{
|
||||||
Command::broadcastCommandMessage($this, new TranslationContainer("commands.gamemode.success.self", [Server::getGamemodeString($gm)]));
|
Command::broadcastCommandMessage($this, new TranslationContainer("commands.gamemode.success.self", [Server::getGamemodeString($gm)]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->sendSettings();
|
||||||
|
|
||||||
$this->inventory->sendContents($this);
|
$this->inventory->sendContents($this);
|
||||||
$this->inventory->sendContents($this->getViewers());
|
$this->inventory->sendContents($this->getViewers());
|
||||||
$this->inventory->sendHeldItem($this->hasSpawned);
|
$this->inventory->sendHeldItem($this->hasSpawned);
|
||||||
@ -2105,6 +2106,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
$block = $target->getSide($packet->face);
|
$block = $target->getSide($packet->face);
|
||||||
if($block->getId() === Block::FIRE){
|
if($block->getId() === Block::FIRE){
|
||||||
$this->level->setBlock($block, new Air());
|
$this->level->setBlock($block, new Air());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
$this->lastBreak = microtime(true);
|
$this->lastBreak = microtime(true);
|
||||||
break;
|
break;
|
||||||
@ -2379,7 +2381,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
];
|
];
|
||||||
|
|
||||||
$damage = [
|
$damage = [
|
||||||
EntityDamageEvent::MODIFIER_BASE => isset($damageTable[$item->getId()]) ? $damageTable[$item->getId()] : 1,
|
EntityDamageEvent::MODIFIER_BASE => $damageTable[$item->getId()] ?? 1,
|
||||||
];
|
];
|
||||||
|
|
||||||
if(!$this->canInteract($target, 8)){
|
if(!$this->canInteract($target, 8)){
|
||||||
@ -2893,15 +2895,12 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);
|
||||||
break;
|
break;
|
||||||
case ProtocolInfo::SET_PLAYER_GAME_TYPE_PACKET:
|
case ProtocolInfo::SET_PLAYER_GAME_TYPE_PACKET:
|
||||||
if($packet->gamemode !== $this->gamemode){
|
if($packet->gamemode !== ($this->gamemode & 0x01)){
|
||||||
if(!$this->hasPermission("pocketmine.command.gamemode")){
|
//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 = new SetPlayerGameTypePacket();
|
||||||
$pk->gamemode = $this->gamemode & 0x01;
|
$pk->gamemode = $this->gamemode & 0x01;
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);
|
||||||
$this->sendSettings();
|
$this->sendSettings();
|
||||||
break;
|
|
||||||
}
|
|
||||||
$this->setGamemode($packet->gamemode, true);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -272,7 +272,7 @@ class Item implements ItemIds, \JsonSerializable{
|
|||||||
* @return Item
|
* @return Item
|
||||||
*/
|
*/
|
||||||
public static function getCreativeItem(int $index){
|
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{
|
public static function getCreativeItemIndex(Item $item) : int{
|
||||||
@ -597,7 +597,7 @@ class Item implements ItemIds, \JsonSerializable{
|
|||||||
public function getNamedTagEntry($name){
|
public function getNamedTagEntry($name){
|
||||||
$tag = $this->getNamedTag();
|
$tag = $this->getNamedTag();
|
||||||
if($tag !== null){
|
if($tag !== null){
|
||||||
return isset($tag->{$name}) ? $tag->{$name} : null;
|
return $tag->{$name} ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -529,7 +529,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
* @return Player[]
|
* @return Player[]
|
||||||
*/
|
*/
|
||||||
public function getChunkPlayers(int $chunkX, int $chunkZ) : array{
|
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[]
|
* @return ChunkLoader[]
|
||||||
*/
|
*/
|
||||||
public function getChunkLoaders(int $chunkX, int $chunkZ) : array{
|
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){
|
public function addChunkPacket(int $chunkX, int $chunkZ, DataPacket $packet){
|
||||||
@ -885,7 +885,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
$chunkZ = $loader->getZ() >> 4;
|
$chunkZ = $loader->getZ() >> 4;
|
||||||
|
|
||||||
$index = Level::chunkHash($chunkX, $chunkZ);
|
$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;
|
$this->chunkTickList[$index] = $existingLoaders + 1;
|
||||||
for($chunk = 0; $chunk < $chunksPerLoader; ++$chunk){
|
for($chunk = 0; $chunk < $chunksPerLoader; ++$chunk){
|
||||||
$dx = mt_rand(-$randRange, $randRange);
|
$dx = mt_rand(-$randRange, $randRange);
|
||||||
@ -1742,7 +1742,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
* @return Entity
|
* @return Entity
|
||||||
*/
|
*/
|
||||||
public function getEntity(int $entityId){
|
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
|
* @return Tile
|
||||||
*/
|
*/
|
||||||
public function getTileById(int $tileId){
|
public function getTileById(int $tileId){
|
||||||
return isset($this->tiles[$tileId]) ? $this->tiles[$tileId] : null;
|
return $this->tiles[$tileId] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,7 +103,7 @@ class SimpleChunkManager implements ChunkManager{
|
|||||||
* @return Chunk|null
|
* @return Chunk|null
|
||||||
*/
|
*/
|
||||||
public function getChunk(int $chunkX, int $chunkZ){
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,6 +62,6 @@ abstract class LevelProviderManager{
|
|||||||
public static function getProviderByName($name){
|
public static function getProviderByName($name){
|
||||||
$name = trim(strtolower($name));
|
$name = trim(strtolower($name));
|
||||||
|
|
||||||
return isset(self::$providers[$name]) ? self::$providers[$name] : null;
|
return self::$providers[$name] ?? null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -311,7 +311,7 @@ class McRegion extends BaseLevelProvider{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function unloadChunk($x, $z, $safe = true){
|
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)){
|
if($chunk instanceof Chunk and $chunk->unload(false, $safe)){
|
||||||
unset($this->chunks[$index]);
|
unset($this->chunks[$index]);
|
||||||
return true;
|
return true;
|
||||||
|
@ -87,9 +87,9 @@ class Flat extends Generator{
|
|||||||
$this->preset = $preset;
|
$this->preset = $preset;
|
||||||
$preset = explode(";", $preset);
|
$preset = explode(";", $preset);
|
||||||
$version = (int) $preset[0];
|
$version = (int) $preset[0];
|
||||||
$blocks = isset($preset[1]) ? $preset[1] : "";
|
$blocks = $preset[1] ?? "";
|
||||||
$biome = isset($preset[2]) ? $preset[2] : 1;
|
$biome = $preset[2] ?? 1;
|
||||||
$options = isset($preset[3]) ? $preset[3] : "";
|
$options = $preset[3] ?? "";
|
||||||
preg_match_all('#^(([0-9]*x|)([0-9]{1,3})(|:[0-9]{0,2}))$#m', str_replace(",", "\n", $blocks), $matches);
|
preg_match_all('#^(([0-9]*x|)([0-9]{1,3})(|:[0-9]{0,2}))$#m', str_replace(",", "\n", $blocks), $matches);
|
||||||
$y = 0;
|
$y = 0;
|
||||||
$this->structure = [];
|
$this->structure = [];
|
||||||
|
@ -107,7 +107,7 @@ abstract class Biome{
|
|||||||
* @return Biome
|
* @return Biome
|
||||||
*/
|
*/
|
||||||
public static function getBiome($id){
|
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(){
|
public function clearPopulators(){
|
||||||
|
@ -81,6 +81,6 @@ class BiomeSelector{
|
|||||||
$rainfall = (int) ($this->getRainfall($x, $z) * 63);
|
$rainfall = (int) ($this->getRainfall($x, $z) * 63);
|
||||||
|
|
||||||
$biomeId = $this->map[$temperature + ($rainfall << 6)];
|
$biomeId = $this->map[$temperature + ($rainfall << 6)];
|
||||||
return isset($this->biomes[$biomeId]) ? $this->biomes[$biomeId] : $this->fallback;
|
return $this->biomes[$biomeId] ?? $this->fallback;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -290,7 +290,7 @@ class NBT{
|
|||||||
throw new \Exception("Syntax error: invalid quote at offset $offset");
|
throw new \Exception("Syntax error: invalid quote at offset $offset");
|
||||||
}
|
}
|
||||||
}elseif($c === "\\"){
|
}elseif($c === "\\"){
|
||||||
$value .= isset($data{$offset + 1}) ? $data{$offset + 1} : "";
|
$value .= $data{$offset + 1} ?? "";
|
||||||
++$offset;
|
++$offset;
|
||||||
}elseif($c === "{" and !$inQuotes){
|
}elseif($c === "{" and !$inQuotes){
|
||||||
if($value !== ""){
|
if($value !== ""){
|
||||||
|
@ -68,7 +68,7 @@ class AutoUpdater{
|
|||||||
"api_version" => $response["api_version"],
|
"api_version" => $response["api_version"],
|
||||||
"build" => $response["build"],
|
"build" => $response["build"],
|
||||||
"date" => $response["date"],
|
"date" => $response["date"],
|
||||||
"details_url" => isset($response["details_url"]) ? $response["details_url"] : null,
|
"details_url" => $response["details_url"] ?? null,
|
||||||
"download_url" => $response["download_url"]
|
"download_url" => $response["download_url"]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ class MainLogger extends \AttachableThreadedLogger{
|
|||||||
}else{
|
}else{
|
||||||
$type = ($errno === E_ERROR or $errno === E_USER_ERROR) ? LogLevel::ERROR : (($errno === E_USER_WARNING or $errno === E_WARNING) ? LogLevel::WARNING : LogLevel::NOTICE);
|
$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){
|
if(($pos = strpos($errstr, "\n")) !== false){
|
||||||
$errstr = substr($errstr, 0, $pos);
|
$errstr = substr($errstr, 0, $pos);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user