mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-05 11:27:07 +00:00
Use first-class closures in more places
This commit is contained in:
parent
537721fe7d
commit
914dd90b3d
@ -1009,7 +1009,7 @@ class Server{
|
||||
|
||||
$this->playerDataProvider = new DatFilePlayerDataProvider(Path::join($this->dataPath, "players"));
|
||||
|
||||
register_shutdown_function([$this, "crashDump"]);
|
||||
register_shutdown_function($this->crashDump(...));
|
||||
|
||||
$loadErrorCount = 0;
|
||||
$this->pluginManager->loadPlugins($this->pluginPath, $loadErrorCount);
|
||||
|
@ -116,9 +116,7 @@ class InventoryManager{
|
||||
$this->addComplex(UIInventorySlotOffset::CURSOR, $this->player->getCursorInventory());
|
||||
$this->addComplex(UIInventorySlotOffset::CRAFTING2X2_INPUT, $this->player->getCraftingGrid());
|
||||
|
||||
$this->player->getInventory()->getHeldItemIndexChangeListeners()->add(function() : void{
|
||||
$this->syncSelectedHotbarSlot();
|
||||
});
|
||||
$this->player->getInventory()->getHeldItemIndexChangeListeners()->add($this->syncSelectedHotbarSlot(...));
|
||||
}
|
||||
|
||||
private function associateIdWithInventory(int $id, Inventory $inventory) : void{
|
||||
|
@ -197,7 +197,7 @@ class NetworkSession{
|
||||
|
||||
$this->setHandler(new SessionStartPacketHandler(
|
||||
$this,
|
||||
fn() => $this->onSessionStartSuccess()
|
||||
$this->onSessionStartSuccess(...)
|
||||
));
|
||||
|
||||
$this->manager->add($this);
|
||||
@ -787,9 +787,7 @@ class NetworkSession{
|
||||
|
||||
$this->cipher = EncryptionContext::fakeGCM($encryptionKey);
|
||||
|
||||
$this->setHandler(new HandshakePacketHandler(function() : void{
|
||||
$this->onServerLoginSuccess();
|
||||
}));
|
||||
$this->setHandler(new HandshakePacketHandler($this->onServerLoginSuccess(...)));
|
||||
$this->logger->debug("Enabled encryption");
|
||||
}));
|
||||
}else{
|
||||
@ -818,9 +816,7 @@ class NetworkSession{
|
||||
public function notifyTerrainReady() : void{
|
||||
$this->logger->debug("Sending spawn notification, waiting for spawn response");
|
||||
$this->sendDataPacket(PlayStatusPacket::create(PlayStatusPacket::PLAYER_SPAWN));
|
||||
$this->setHandler(new SpawnResponsePacketHandler(function() : void{
|
||||
$this->onClientSpawnResponse();
|
||||
}));
|
||||
$this->setHandler(new SpawnResponsePacketHandler($this->onClientSpawnResponse(...)));
|
||||
}
|
||||
|
||||
private function onClientSpawnResponse() : void{
|
||||
|
12
src/network/mcpe/cache/CraftingDataCache.php
vendored
12
src/network/mcpe/cache/CraftingDataCache.php
vendored
@ -95,12 +95,8 @@ final class CraftingDataCache{
|
||||
$recipesWithTypeIds[] = new ProtocolShapelessRecipe(
|
||||
CraftingDataPacket::ENTRY_SHAPELESS,
|
||||
Binary::writeInt($index),
|
||||
array_map(function(RecipeIngredient $item) use ($converter) : ProtocolRecipeIngredient{
|
||||
return $converter->coreRecipeIngredientToNet($item);
|
||||
}, $recipe->getIngredientList()),
|
||||
array_map(function(Item $item) use ($converter) : ItemStack{
|
||||
return $converter->coreItemStackToNet($item);
|
||||
}, $recipe->getResults()),
|
||||
array_map($converter->coreRecipeIngredientToNet(...), $recipe->getIngredientList()),
|
||||
array_map($converter->coreItemStackToNet(...), $recipe->getResults()),
|
||||
$nullUUID,
|
||||
$typeTag,
|
||||
50,
|
||||
@ -118,9 +114,7 @@ final class CraftingDataCache{
|
||||
CraftingDataPacket::ENTRY_SHAPED,
|
||||
Binary::writeInt($index),
|
||||
$inputs,
|
||||
array_map(function(Item $item) use ($converter) : ItemStack{
|
||||
return $converter->coreItemStackToNet($item);
|
||||
}, $recipe->getResults()),
|
||||
array_map($converter->coreItemStackToNet(...), $recipe->getResults()),
|
||||
$nullUUID,
|
||||
CraftingRecipeBlockName::CRAFTING_TABLE,
|
||||
50,
|
||||
|
@ -121,8 +121,6 @@ trait RegistryTrait{
|
||||
*/
|
||||
private static function _registryGetAll() : array{
|
||||
self::checkInit();
|
||||
return array_map(function(object $o) : object{
|
||||
return self::preprocessMember($o);
|
||||
}, self::$members);
|
||||
return array_map(self::preprocessMember(...), self::$members);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user