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