mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-04 09:10:00 +00:00
network: explicitly specify @return void
This commit is contained in:
parent
ca86ec2ec2
commit
b42966f61b
@ -37,6 +37,8 @@ interface AdvancedSourceInterface extends SourceInterface{
|
|||||||
*
|
*
|
||||||
* @param string $address
|
* @param string $address
|
||||||
* @param int $timeout Seconds
|
* @param int $timeout Seconds
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function blockAddress(string $address, int $timeout = 300);
|
public function blockAddress(string $address, int $timeout = 300);
|
||||||
|
|
||||||
@ -44,11 +46,15 @@ interface AdvancedSourceInterface extends SourceInterface{
|
|||||||
* Unblocks a previously-blocked address.
|
* Unblocks a previously-blocked address.
|
||||||
*
|
*
|
||||||
* @param string $address
|
* @param string $address
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function unblockAddress(string $address);
|
public function unblockAddress(string $address);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Network $network
|
* @param Network $network
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setNetwork(Network $network);
|
public function setNetwork(Network $network);
|
||||||
|
|
||||||
@ -58,6 +64,8 @@ interface AdvancedSourceInterface extends SourceInterface{
|
|||||||
* @param string $address
|
* @param string $address
|
||||||
* @param int $port
|
* @param int $port
|
||||||
* @param string $payload
|
* @param string $payload
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function sendRawPacket(string $address, int $port, string $payload);
|
public function sendRawPacket(string $address, int $port, string $payload);
|
||||||
|
|
||||||
|
@ -64,6 +64,8 @@ class Network{
|
|||||||
/**
|
/**
|
||||||
* @param float $upload
|
* @param float $upload
|
||||||
* @param float $download
|
* @param float $download
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function addStatistics($upload, $download){
|
public function addStatistics($upload, $download){
|
||||||
$this->upload += $upload;
|
$this->upload += $upload;
|
||||||
@ -84,6 +86,9 @@ class Network{
|
|||||||
return $this->download;
|
return $this->download;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function resetStatistics(){
|
public function resetStatistics(){
|
||||||
$this->upload = 0;
|
$this->upload = 0;
|
||||||
$this->download = 0;
|
$this->download = 0;
|
||||||
@ -96,6 +101,9 @@ class Network{
|
|||||||
return $this->interfaces;
|
return $this->interfaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function processInterfaces(){
|
public function processInterfaces(){
|
||||||
foreach($this->interfaces as $interface){
|
foreach($this->interfaces as $interface){
|
||||||
$interface->process();
|
$interface->process();
|
||||||
@ -105,6 +113,8 @@ class Network{
|
|||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
* @param SourceInterface $interface
|
* @param SourceInterface $interface
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function processInterface(SourceInterface $interface) : void{
|
public function processInterface(SourceInterface $interface) : void{
|
||||||
$interface->process();
|
$interface->process();
|
||||||
@ -112,6 +122,8 @@ class Network{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param SourceInterface $interface
|
* @param SourceInterface $interface
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function registerInterface(SourceInterface $interface){
|
public function registerInterface(SourceInterface $interface){
|
||||||
$ev = new NetworkInterfaceRegisterEvent($interface);
|
$ev = new NetworkInterfaceRegisterEvent($interface);
|
||||||
@ -129,6 +141,8 @@ class Network{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param SourceInterface $interface
|
* @param SourceInterface $interface
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function unregisterInterface(SourceInterface $interface){
|
public function unregisterInterface(SourceInterface $interface){
|
||||||
(new NetworkInterfaceUnregisterEvent($interface))->call();
|
(new NetworkInterfaceUnregisterEvent($interface))->call();
|
||||||
@ -139,6 +153,8 @@ class Network{
|
|||||||
* Sets the server name shown on each interface Query
|
* Sets the server name shown on each interface Query
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setName(string $name){
|
public function setName(string $name){
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
@ -154,6 +170,9 @@ class Network{
|
|||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function updateName(){
|
public function updateName(){
|
||||||
foreach($this->interfaces as $interface){
|
foreach($this->interfaces as $interface){
|
||||||
$interface->setName($this->name);
|
$interface->setName($this->name);
|
||||||
@ -171,6 +190,8 @@ class Network{
|
|||||||
* @param string $address
|
* @param string $address
|
||||||
* @param int $port
|
* @param int $port
|
||||||
* @param string $payload
|
* @param string $payload
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function sendPacket(string $address, int $port, string $payload){
|
public function sendPacket(string $address, int $port, string $payload){
|
||||||
foreach($this->advancedInterfaces as $interface){
|
foreach($this->advancedInterfaces as $interface){
|
||||||
@ -183,6 +204,8 @@ class Network{
|
|||||||
*
|
*
|
||||||
* @param string $address
|
* @param string $address
|
||||||
* @param int $timeout
|
* @param int $timeout
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function blockAddress(string $address, int $timeout = 300){
|
public function blockAddress(string $address, int $timeout = 300){
|
||||||
foreach($this->advancedInterfaces as $interface){
|
foreach($this->advancedInterfaces as $interface){
|
||||||
@ -190,6 +213,11 @@ class Network{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $address
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function unblockAddress(string $address){
|
public function unblockAddress(string $address){
|
||||||
foreach($this->advancedInterfaces as $interface){
|
foreach($this->advancedInterfaces as $interface){
|
||||||
$interface->unblockAddress($address);
|
$interface->unblockAddress($address);
|
||||||
|
@ -36,6 +36,8 @@ interface SourceInterface{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs actions needed to start the interface after it is registered.
|
* Performs actions needed to start the interface after it is registered.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function start();
|
public function start();
|
||||||
|
|
||||||
@ -56,11 +58,15 @@ interface SourceInterface{
|
|||||||
*
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @param string $reason
|
* @param string $reason
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function close(Player $player, string $reason = "unknown reason");
|
public function close(Player $player, string $reason = "unknown reason");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $name
|
* @param string $name
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setName(string $name);
|
public function setName(string $name);
|
||||||
|
|
||||||
@ -71,12 +77,16 @@ interface SourceInterface{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gracefully shuts down the network interface.
|
* Gracefully shuts down the network interface.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function shutdown();
|
public function shutdown();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
* Shuts down the network interface in an emergency situation, such as due to a crash.
|
* Shuts down the network interface in an emergency situation, such as due to a crash.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function emergencyShutdown();
|
public function emergencyShutdown();
|
||||||
|
|
||||||
|
@ -103,6 +103,11 @@ class NetworkBinaryStream extends BinaryStream{
|
|||||||
return new SkinData($skinId, $skinResourcePatch, $skinData, $animations, $capeData, $geometryData, $animationData, $premium, $persona, $capeOnClassic, $capeId);
|
return new SkinData($skinId, $skinResourcePatch, $skinData, $animations, $capeData, $geometryData, $animationData, $premium, $persona, $capeOnClassic, $capeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param SkinData $skin
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function putSkin(SkinData $skin){
|
public function putSkin(SkinData $skin){
|
||||||
$this->putString($skin->getSkinId());
|
$this->putString($skin->getSkinId());
|
||||||
$this->putString($skin->getResourcePatch());
|
$this->putString($skin->getResourcePatch());
|
||||||
|
@ -169,6 +169,11 @@ use pocketmine\network\mcpe\protocol\VideoStreamConnectPacket;
|
|||||||
|
|
||||||
abstract class NetworkSession{
|
abstract class NetworkSession{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param DataPacket $packet
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
abstract public function handleDataPacket(DataPacket $packet);
|
abstract public function handleDataPacket(DataPacket $packet);
|
||||||
|
|
||||||
public function handleLogin(LoginPacket $packet) : bool{
|
public function handleLogin(LoginPacket $packet) : bool{
|
||||||
|
@ -219,6 +219,8 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bool $name
|
* @param bool $name
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setPortCheck($name){
|
public function setPortCheck($name){
|
||||||
$this->interface->sendOption("portChecking", (bool) $name);
|
$this->interface->sendOption("portChecking", (bool) $name);
|
||||||
|
@ -102,6 +102,12 @@ class AdventureSettingsPacket extends DataPacket{
|
|||||||
return ($this->flags & $flag) !== 0;
|
return ($this->flags & $flag) !== 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $flag
|
||||||
|
* @param bool $value
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function setFlag(int $flag, bool $value){
|
public function setFlag(int $flag, bool $value){
|
||||||
if($flag & self::BITFLAG_SECOND_SET){
|
if($flag & self::BITFLAG_SECOND_SET){
|
||||||
$flagSet =& $this->flags2;
|
$flagSet =& $this->flags2;
|
||||||
|
@ -77,6 +77,8 @@ class BatchPacket extends DataPacket{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param DataPacket $packet
|
* @param DataPacket $packet
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function addPacket(DataPacket $packet){
|
public function addPacket(DataPacket $packet){
|
||||||
if(!$packet->canBeBatched()){
|
if(!$packet->canBeBatched()){
|
||||||
@ -107,6 +109,11 @@ class BatchPacket extends DataPacket{
|
|||||||
return $this->compressionLevel;
|
return $this->compressionLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $level
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function setCompressionLevel(int $level){
|
public function setCompressionLevel(int $level){
|
||||||
$this->compressionLevel = $level;
|
$this->compressionLevel = $level;
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,11 @@ class CommandOutputPacket extends DataPacket{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param CommandOutputMessage $message
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
protected function putCommandMessage(CommandOutputMessage $message){
|
protected function putCommandMessage(CommandOutputMessage $message){
|
||||||
$this->putBool($message->isInternal);
|
$this->putBool($message->isInternal);
|
||||||
$this->putString($message->messageId);
|
$this->putString($message->messageId);
|
||||||
|
@ -238,14 +238,29 @@ class CraftingDataPacket extends DataPacket{
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ShapelessRecipe $recipe
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function addShapelessRecipe(ShapelessRecipe $recipe){
|
public function addShapelessRecipe(ShapelessRecipe $recipe){
|
||||||
$this->entries[] = $recipe;
|
$this->entries[] = $recipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ShapedRecipe $recipe
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function addShapedRecipe(ShapedRecipe $recipe){
|
public function addShapedRecipe(ShapedRecipe $recipe){
|
||||||
$this->entries[] = $recipe;
|
$this->entries[] = $recipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param FurnaceRecipe $recipe
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function addFurnaceRecipe(FurnaceRecipe $recipe){
|
public function addFurnaceRecipe(FurnaceRecipe $recipe){
|
||||||
$this->entries[] = $recipe;
|
$this->entries[] = $recipe;
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,9 @@ class PacketPool{
|
|||||||
/** @var \SplFixedArray<DataPacket> */
|
/** @var \SplFixedArray<DataPacket> */
|
||||||
protected static $pool = null;
|
protected static $pool = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public static function init(){
|
public static function init(){
|
||||||
static::$pool = new \SplFixedArray(256);
|
static::$pool = new \SplFixedArray(256);
|
||||||
|
|
||||||
@ -179,6 +182,8 @@ class PacketPool{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param DataPacket $packet
|
* @param DataPacket $packet
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function registerPacket(DataPacket $packet){
|
public static function registerPacket(DataPacket $packet){
|
||||||
static::$pool[$packet->pid()] = clone $packet;
|
static::$pool[$packet->pid()] = clone $packet;
|
||||||
|
@ -115,6 +115,7 @@ class NetworkInventoryAction{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param InventoryTransactionPacket $packet
|
* @param InventoryTransactionPacket $packet
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function write(InventoryTransactionPacket $packet){
|
public function write(InventoryTransactionPacket $packet){
|
||||||
$packet->putUnsignedVarInt($this->sourceType);
|
$packet->putUnsignedVarInt($this->sourceType);
|
||||||
|
@ -76,11 +76,16 @@ class QueryHandler{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function regenerateInfo(){
|
public function regenerateInfo(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function regenerateToken(){
|
public function regenerateToken(){
|
||||||
$this->lastToken = $this->token;
|
$this->lastToken = $this->token;
|
||||||
$this->token = random_bytes(16);
|
$this->token = random_bytes(16);
|
||||||
@ -90,6 +95,14 @@ class QueryHandler{
|
|||||||
return Binary::readInt(substr(hash("sha512", $salt . ":" . $token, true), 7, 4));
|
return Binary::readInt(substr(hash("sha512", $salt . ":" . $token, true), 7, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AdvancedSourceInterface $interface
|
||||||
|
* @param string $address
|
||||||
|
* @param int $port
|
||||||
|
* @param string $packet
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function handle(AdvancedSourceInterface $interface, string $address, int $port, string $packet){
|
public function handle(AdvancedSourceInterface $interface, string $address, int $port, string $packet){
|
||||||
$offset = 2;
|
$offset = 2;
|
||||||
$packetType = ord($packet[$offset++]);
|
$packetType = ord($packet[$offset++]);
|
||||||
|
@ -100,6 +100,9 @@ class RCON{
|
|||||||
$this->server->getLogger()->info("RCON running on $addr:$port");
|
$this->server->getLogger()->info("RCON running on $addr:$port");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function stop(){
|
public function stop(){
|
||||||
$this->instance->close();
|
$this->instance->close();
|
||||||
socket_write($this->ipcMainSocket, "\x00"); //make select() return
|
socket_write($this->ipcMainSocket, "\x00"); //make select() return
|
||||||
@ -110,6 +113,9 @@ class RCON{
|
|||||||
@socket_close($this->ipcThreadSocket);
|
@socket_close($this->ipcThreadSocket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function check(){
|
public function check(){
|
||||||
$response = new RemoteConsoleCommandSender();
|
$response = new RemoteConsoleCommandSender();
|
||||||
$command = $this->instance->cmd;
|
$command = $this->instance->cmd;
|
||||||
|
@ -159,10 +159,16 @@ class RCONInstance extends Thread{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function close(){
|
public function close(){
|
||||||
$this->stop = true;
|
$this->stop = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function run(){
|
public function run(){
|
||||||
$this->registerClassLoader();
|
$this->registerClassLoader();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user