mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Removed @deprecated classes, methods and properties, added some type hints
This commit is contained in:
@ -29,14 +29,12 @@ class CompressBatchedTask extends AsyncTask{
|
||||
public $level = 7;
|
||||
public $data;
|
||||
public $final;
|
||||
public $channel = 0;
|
||||
public $targets = [];
|
||||
|
||||
public function __construct($data, array $targets, $level = 7, $channel = 0){
|
||||
public function __construct($data, array $targets, $level = 7){
|
||||
$this->data = $data;
|
||||
$this->targets = $targets;
|
||||
$this->level = $level;
|
||||
$this->channel = $channel;
|
||||
}
|
||||
|
||||
public function onRun(){
|
||||
|
@ -84,25 +84,6 @@ class Network{
|
||||
|
||||
public static $BATCH_THRESHOLD = 512;
|
||||
|
||||
/** @deprecated */
|
||||
const CHANNEL_NONE = 0;
|
||||
/** @deprecated */
|
||||
const CHANNEL_PRIORITY = 1; //Priority channel, only to be used when it matters
|
||||
/** @deprecated */
|
||||
const CHANNEL_WORLD_CHUNKS = 2; //Chunk sending
|
||||
/** @deprecated */
|
||||
const CHANNEL_MOVEMENT = 3; //Movement sending
|
||||
/** @deprecated */
|
||||
const CHANNEL_BLOCKS = 4; //Block updates or explosions
|
||||
/** @deprecated */
|
||||
const CHANNEL_WORLD_EVENTS = 5; //Entity, level or tile entity events
|
||||
/** @deprecated */
|
||||
const CHANNEL_ENTITY_SPAWNING = 6; //Entity spawn/despawn channel
|
||||
/** @deprecated */
|
||||
const CHANNEL_TEXT = 7; //Chat and other text stuff
|
||||
/** @deprecated */
|
||||
const CHANNEL_END = 31;
|
||||
|
||||
/** @var \SplFixedArray */
|
||||
private $packetPool;
|
||||
|
||||
|
@ -64,10 +64,6 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
||||
|
||||
$this->rakLib = new RakLibServer($this->server->getLogger(), $this->server->getLoader(), $this->server->getPort(), $this->server->getIp() === "" ? "0.0.0.0" : $this->server->getIp());
|
||||
$this->interface = new ServerHandler($this->rakLib, $this);
|
||||
|
||||
for($i = 0; $i < 256; ++$i){
|
||||
$this->channelCounts[$i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function setNetwork(Network $network){
|
||||
@ -83,9 +79,9 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
||||
}
|
||||
|
||||
if($this->rakLib->isTerminated()){
|
||||
$info = $this->rakLib->getTerminationInfo();
|
||||
$this->network->unregisterInterface($this);
|
||||
\ExceptionHandler::handler(E_ERROR, "RakLib Thread crashed [".$info["scope"]."]: " . (isset($info["message"]) ? $info["message"] : ""), $info["file"], $info["line"]);
|
||||
|
||||
throw new \Exception("RakLib Thread crashed");
|
||||
}
|
||||
|
||||
return $work;
|
||||
@ -206,13 +202,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
||||
$packet->__encapsulatedPacket = new CachedEncapsulatedPacket;
|
||||
$packet->__encapsulatedPacket->identifierACK = null;
|
||||
$packet->__encapsulatedPacket->buffer = $packet->buffer;
|
||||
if($packet->getChannel() !== 0){
|
||||
$packet->__encapsulatedPacket->reliability = 3;
|
||||
$packet->__encapsulatedPacket->orderChannel = $packet->getChannel();
|
||||
$packet->__encapsulatedPacket->orderIndex = 0;
|
||||
}else{
|
||||
$packet->__encapsulatedPacket->reliability = 2;
|
||||
}
|
||||
$packet->__encapsulatedPacket->reliability = 2;
|
||||
}
|
||||
$pk = $packet->__encapsulatedPacket;
|
||||
}
|
||||
@ -220,20 +210,14 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
||||
if(!$immediate and !$needACK and $packet::NETWORK_ID !== ProtocolInfo::BATCH_PACKET
|
||||
and Network::$BATCH_THRESHOLD >= 0
|
||||
and strlen($packet->buffer) >= Network::$BATCH_THRESHOLD){
|
||||
$this->server->batchPackets([$player], [$packet], true, $packet->getChannel());
|
||||
$this->server->batchPackets([$player], [$packet], true);
|
||||
return null;
|
||||
}
|
||||
|
||||
if($pk === null){
|
||||
$pk = new EncapsulatedPacket();
|
||||
$pk->buffer = $packet->buffer;
|
||||
if($packet->getChannel() !== 0){
|
||||
$packet->reliability = 3;
|
||||
$packet->orderChannel = $packet->getChannel();
|
||||
$packet->orderIndex = 0;
|
||||
}else{
|
||||
$packet->reliability = 2;
|
||||
}
|
||||
$packet->reliability = 2;
|
||||
|
||||
if($needACK === true){
|
||||
$pk->identifierACK = $this->identifiersACK[$identifier]++;
|
||||
|
@ -37,7 +37,6 @@ abstract class DataPacket extends BinaryStream{
|
||||
const NETWORK_ID = 0;
|
||||
|
||||
public $isEncoded = false;
|
||||
private $channel = 0;
|
||||
|
||||
public function pid(){
|
||||
return $this::NETWORK_ID;
|
||||
@ -52,18 +51,6 @@ abstract class DataPacket extends BinaryStream{
|
||||
$this->offset = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This adds extra overhead on the network, so its usage is now discouraged. It was a test for the viability of this.
|
||||
*/
|
||||
public function setChannel($channel){
|
||||
$this->channel = (int) $channel;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChannel(){
|
||||
return $this->channel;
|
||||
}
|
||||
|
||||
public function clean(){
|
||||
$this->buffer = null;
|
||||
$this->isEncoded = false;
|
||||
|
@ -31,6 +31,11 @@ class RCONInstance extends Thread{
|
||||
private $socket;
|
||||
private $password;
|
||||
private $maxClients;
|
||||
private $waiting;
|
||||
|
||||
public function isWaiting(){
|
||||
return $this->waiting === true;
|
||||
}
|
||||
|
||||
|
||||
public function __construct($socket, $password, $maxClients = 50){
|
||||
@ -137,8 +142,10 @@ class RCONInstance extends Thread{
|
||||
socket_getpeername($client, $addr, $port);
|
||||
$this->response = "[INFO] Successful Rcon connection from: /$addr:$port";
|
||||
$this->synchronized(function (){
|
||||
$this->waiting = true;
|
||||
$this->wait();
|
||||
});
|
||||
$this->waiting = false;
|
||||
$this->response = "";
|
||||
$this->writePacket($client, $requestID, 2, "");
|
||||
$this->{"status" . $n} = 1;
|
||||
@ -156,8 +163,10 @@ class RCONInstance extends Thread{
|
||||
if(strlen($payload) > 0){
|
||||
$this->cmd = ltrim($payload);
|
||||
$this->synchronized(function (){
|
||||
$this->waiting = true;
|
||||
$this->wait();
|
||||
});
|
||||
$this->waiting = false;
|
||||
$this->writePacket($client, $requestID, 0, str_replace("\n", "\r\n", trim($this->response)));
|
||||
$this->response = "";
|
||||
$this->cmd = "";
|
||||
|
Reference in New Issue
Block a user