mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 04:17:07 +00:00
remove usages of deprecated {} string access, closes #3035
This commit is contained in:
parent
b788982d60
commit
622f93df45
@ -74,14 +74,14 @@ class FormattedCommandAlias extends Command{
|
|||||||
$index = strpos($formatString, '$');
|
$index = strpos($formatString, '$');
|
||||||
while($index !== false){
|
while($index !== false){
|
||||||
$start = $index;
|
$start = $index;
|
||||||
if($index > 0 and $formatString{$start - 1} === "\\"){
|
if($index > 0 and $formatString[$start - 1] === "\\"){
|
||||||
$formatString = substr($formatString, 0, $start - 1) . substr($formatString, $start);
|
$formatString = substr($formatString, 0, $start - 1) . substr($formatString, $start);
|
||||||
$index = strpos($formatString, '$', $index);
|
$index = strpos($formatString, '$', $index);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$required = false;
|
$required = false;
|
||||||
if($formatString{$index + 1} == '$'){
|
if($formatString[$index + 1] == '$'){
|
||||||
$required = true;
|
$required = true;
|
||||||
|
|
||||||
++$index;
|
++$index;
|
||||||
@ -91,7 +91,7 @@ class FormattedCommandAlias extends Command{
|
|||||||
|
|
||||||
$argStart = $index;
|
$argStart = $index;
|
||||||
|
|
||||||
while($index < strlen($formatString) and self::inRange(ord($formatString{$index}) - 48, 0, 9)){
|
while($index < strlen($formatString) and self::inRange(ord($formatString[$index]) - 48, 0, 9)){
|
||||||
++$index;
|
++$index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ class FormattedCommandAlias extends Command{
|
|||||||
|
|
||||||
$rest = false;
|
$rest = false;
|
||||||
|
|
||||||
if($index < strlen($formatString) and $formatString{$index} === "-"){
|
if($index < strlen($formatString) and $formatString[$index] === "-"){
|
||||||
$rest = true;
|
$rest = true;
|
||||||
++$index;
|
++$index;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ abstract class VanillaCommand extends Command{
|
|||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
protected function getRelativeDouble(float $original, CommandSender $sender, string $input, float $min = self::MIN_COORD, float $max = self::MAX_COORD) : float{
|
protected function getRelativeDouble(float $original, CommandSender $sender, string $input, float $min = self::MIN_COORD, float $max = self::MAX_COORD) : float{
|
||||||
if($input{0} === "~"){
|
if($input[0] === "~"){
|
||||||
$value = $this->getDouble($sender, substr($input, 1));
|
$value = $this->getDouble($sender, substr($input, 1));
|
||||||
|
|
||||||
return $original + $value;
|
return $original + $value;
|
||||||
|
@ -79,8 +79,8 @@ class ShapedRecipe implements CraftingRecipe{
|
|||||||
}
|
}
|
||||||
|
|
||||||
for($x = 0; $x < $this->width; ++$x){
|
for($x = 0; $x < $this->width; ++$x){
|
||||||
if($row{$x} !== ' ' and !isset($ingredients[$row{$x}])){
|
if($row[$x] !== ' ' and !isset($ingredients[$row[$x]])){
|
||||||
throw new \InvalidArgumentException("No item specified for symbol '" . $row{$x} . "'");
|
throw new \InvalidArgumentException("No item specified for symbol '" . $row[$x] . "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ class BaseLang{
|
|||||||
|
|
||||||
$len = strlen($text);
|
$len = strlen($text);
|
||||||
for($i = 0; $i < $len; ++$i){
|
for($i = 0; $i < $len; ++$i){
|
||||||
$c = $text{$i};
|
$c = $text[$i];
|
||||||
if($replaceString !== null){
|
if($replaceString !== null){
|
||||||
$ord = ord($c);
|
$ord = ord($c);
|
||||||
if(
|
if(
|
||||||
|
@ -460,7 +460,7 @@ class Chunk{
|
|||||||
* @return int 0-255
|
* @return int 0-255
|
||||||
*/
|
*/
|
||||||
public function getBiomeId(int $x, int $z) : int{
|
public function getBiomeId(int $x, int $z) : int{
|
||||||
return ord($this->biomeIds{($z << 4) | $x});
|
return ord($this->biomeIds[($z << 4) | $x]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -472,7 +472,7 @@ class Chunk{
|
|||||||
*/
|
*/
|
||||||
public function setBiomeId(int $x, int $z, int $biomeId){
|
public function setBiomeId(int $x, int $z, int $biomeId){
|
||||||
$this->hasChanged = true;
|
$this->hasChanged = true;
|
||||||
$this->biomeIds{($z << 4) | $x} = chr($biomeId & 0xff);
|
$this->biomeIds[($z << 4) | $x] = chr($biomeId & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,31 +71,31 @@ class SubChunk implements SubChunkInterface{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getBlockId(int $x, int $y, int $z) : int{
|
public function getBlockId(int $x, int $y, int $z) : int{
|
||||||
return ord($this->ids{($x << 8) | ($z << 4) | $y});
|
return ord($this->ids[($x << 8) | ($z << 4) | $y]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setBlockId(int $x, int $y, int $z, int $id) : bool{
|
public function setBlockId(int $x, int $y, int $z, int $id) : bool{
|
||||||
$this->ids{($x << 8) | ($z << 4) | $y} = chr($id);
|
$this->ids[($x << 8) | ($z << 4) | $y] = chr($id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBlockData(int $x, int $y, int $z) : int{
|
public function getBlockData(int $x, int $y, int $z) : int{
|
||||||
return (ord($this->data{($x << 7) | ($z << 3) | ($y >> 1)}) >> (($y & 1) << 2)) & 0xf;
|
return (ord($this->data[($x << 7) | ($z << 3) | ($y >> 1)]) >> (($y & 1) << 2)) & 0xf;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setBlockData(int $x, int $y, int $z, int $data) : bool{
|
public function setBlockData(int $x, int $y, int $z, int $data) : bool{
|
||||||
$i = ($x << 7) | ($z << 3) | ($y >> 1);
|
$i = ($x << 7) | ($z << 3) | ($y >> 1);
|
||||||
|
|
||||||
$shift = ($y & 1) << 2;
|
$shift = ($y & 1) << 2;
|
||||||
$byte = ord($this->data{$i});
|
$byte = ord($this->data[$i]);
|
||||||
$this->data{$i} = chr(($byte & ~(0xf << $shift)) | (($data & 0xf) << $shift));
|
$this->data[$i] = chr(($byte & ~(0xf << $shift)) | (($data & 0xf) << $shift));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFullBlock(int $x, int $y, int $z) : int{
|
public function getFullBlock(int $x, int $y, int $z) : int{
|
||||||
$i = ($x << 8) | ($z << 4) | $y;
|
$i = ($x << 8) | ($z << 4) | $y;
|
||||||
return (ord($this->ids{$i}) << 4) | ((ord($this->data{$i >> 1}) >> (($y & 1) << 2)) & 0xf);
|
return (ord($this->ids[$i]) << 4) | ((ord($this->data[$i >> 1]) >> (($y & 1) << 2)) & 0xf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setBlock(int $x, int $y, int $z, ?int $id = null, ?int $data = null) : bool{
|
public function setBlock(int $x, int $y, int $z, ?int $id = null, ?int $data = null) : bool{
|
||||||
@ -103,8 +103,8 @@ class SubChunk implements SubChunkInterface{
|
|||||||
$changed = false;
|
$changed = false;
|
||||||
if($id !== null){
|
if($id !== null){
|
||||||
$block = chr($id);
|
$block = chr($id);
|
||||||
if($this->ids{$i} !== $block){
|
if($this->ids[$i] !== $block){
|
||||||
$this->ids{$i} = $block;
|
$this->ids[$i] = $block;
|
||||||
$changed = true;
|
$changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,10 +113,10 @@ class SubChunk implements SubChunkInterface{
|
|||||||
$i >>= 1;
|
$i >>= 1;
|
||||||
|
|
||||||
$shift = ($y & 1) << 2;
|
$shift = ($y & 1) << 2;
|
||||||
$oldPair = ord($this->data{$i});
|
$oldPair = ord($this->data[$i]);
|
||||||
$newPair = ($oldPair & ~(0xf << $shift)) | (($data & 0xf) << $shift);
|
$newPair = ($oldPair & ~(0xf << $shift)) | (($data & 0xf) << $shift);
|
||||||
if($newPair !== $oldPair){
|
if($newPair !== $oldPair){
|
||||||
$this->data{$i} = chr($newPair);
|
$this->data[$i] = chr($newPair);
|
||||||
$changed = true;
|
$changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,29 +125,29 @@ class SubChunk implements SubChunkInterface{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getBlockLight(int $x, int $y, int $z) : int{
|
public function getBlockLight(int $x, int $y, int $z) : int{
|
||||||
return (ord($this->blockLight{($x << 7) | ($z << 3) | ($y >> 1)}) >> (($y & 1) << 2)) & 0xf;
|
return (ord($this->blockLight[($x << 7) | ($z << 3) | ($y >> 1)]) >> (($y & 1) << 2)) & 0xf;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setBlockLight(int $x, int $y, int $z, int $level) : bool{
|
public function setBlockLight(int $x, int $y, int $z, int $level) : bool{
|
||||||
$i = ($x << 7) | ($z << 3) | ($y >> 1);
|
$i = ($x << 7) | ($z << 3) | ($y >> 1);
|
||||||
|
|
||||||
$shift = ($y & 1) << 2;
|
$shift = ($y & 1) << 2;
|
||||||
$byte = ord($this->blockLight{$i});
|
$byte = ord($this->blockLight[$i]);
|
||||||
$this->blockLight{$i} = chr(($byte & ~(0xf << $shift)) | (($level & 0xf) << $shift));
|
$this->blockLight[$i] = chr(($byte & ~(0xf << $shift)) | (($level & 0xf) << $shift));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBlockSkyLight(int $x, int $y, int $z) : int{
|
public function getBlockSkyLight(int $x, int $y, int $z) : int{
|
||||||
return (ord($this->skyLight{($x << 7) | ($z << 3) | ($y >> 1)}) >> (($y & 1) << 2)) & 0xf;
|
return (ord($this->skyLight[($x << 7) | ($z << 3) | ($y >> 1)]) >> (($y & 1) << 2)) & 0xf;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setBlockSkyLight(int $x, int $y, int $z, int $level) : bool{
|
public function setBlockSkyLight(int $x, int $y, int $z, int $level) : bool{
|
||||||
$i = ($x << 7) | ($z << 3) | ($y >> 1);
|
$i = ($x << 7) | ($z << 3) | ($y >> 1);
|
||||||
|
|
||||||
$shift = ($y & 1) << 2;
|
$shift = ($y & 1) << 2;
|
||||||
$byte = ord($this->skyLight{$i});
|
$byte = ord($this->skyLight[$i]);
|
||||||
$this->skyLight{$i} = chr(($byte & ~(0xf << $shift)) | (($level & 0xf) << $shift));
|
$this->skyLight[$i] = chr(($byte & ~(0xf << $shift)) | (($level & 0xf) << $shift));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ class SubChunk implements SubChunkInterface{
|
|||||||
$low = ($x << 8) | ($z << 4);
|
$low = ($x << 8) | ($z << 4);
|
||||||
$i = $low | 0x0f;
|
$i = $low | 0x0f;
|
||||||
for(; $i >= $low; --$i){
|
for(; $i >= $low; --$i){
|
||||||
if($this->ids{$i} !== "\x00"){
|
if($this->ids[$i] !== "\x00"){
|
||||||
return $i & 0x0f;
|
return $i & 0x0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ if(!extension_loaded('pocketmine_chunkutils')){
|
|||||||
for($z = $x; $z < $zM; $z += 16){
|
for($z = $x; $z < $zM; $z += 16){
|
||||||
$yM = $z + 4096;
|
$yM = $z + 4096;
|
||||||
for($y = $z; $y < $yM; $y += 256){
|
for($y = $z; $y < $yM; $y += 256){
|
||||||
$result{$i} = $array{$y};
|
$result[$i] = $array[$y];
|
||||||
++$i;
|
++$i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,13 +76,13 @@ if(!extension_loaded('pocketmine_chunkutils')){
|
|||||||
for($y = 0; $y < 8; ++$y){
|
for($y = 0; $y < 8; ++$y){
|
||||||
$j = (($y << 8) | $zx);
|
$j = (($y << 8) | $zx);
|
||||||
$j80 = ($j | 0x80);
|
$j80 = ($j | 0x80);
|
||||||
if($array{$j} === $commonValue and $array{$j80} === $commonValue){
|
if($array[$j] === $commonValue and $array[$j80] === $commonValue){
|
||||||
//values are already filled
|
//values are already filled
|
||||||
}else{
|
}else{
|
||||||
$i1 = ord($array{$j});
|
$i1 = ord($array[$j]);
|
||||||
$i2 = ord($array{$j80});
|
$i2 = ord($array[$j80]);
|
||||||
$result{$i} = chr(($i2 << 4) | ($i1 & 0x0f));
|
$result[$i] = chr(($i2 << 4) | ($i1 & 0x0f));
|
||||||
$result{$i | 0x80} = chr(($i1 >> 4) | ($i2 & 0xf0));
|
$result[$i | 0x80] = chr(($i1 >> 4) | ($i2 & 0xf0));
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ if(!extension_loaded('pocketmine_chunkutils')){
|
|||||||
public static function convertBiomeColors(array $array) : string{
|
public static function convertBiomeColors(array $array) : string{
|
||||||
$result = str_repeat("\x00", 256);
|
$result = str_repeat("\x00", 256);
|
||||||
foreach($array as $i => $color){
|
foreach($array as $i => $color){
|
||||||
$result{$i} = chr(($color >> 24) & 0xff);
|
$result[$i] = chr(($color >> 24) & 0xff);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ class GroundCover extends Populator{
|
|||||||
|
|
||||||
$column = $chunk->getBlockIdColumn($x, $z);
|
$column = $chunk->getBlockIdColumn($x, $z);
|
||||||
for($y = 127; $y > 0; --$y){
|
for($y = 127; $y > 0; --$y){
|
||||||
if($column{$y} !== "\x00" and !BlockFactory::get(ord($column{$y}))->isTransparent()){
|
if($column[$y] !== "\x00" and !BlockFactory::get(ord($column[$y]))->isTransparent()){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,10 +56,10 @@ class GroundCover extends Populator{
|
|||||||
$endY = $startY - count($cover);
|
$endY = $startY - count($cover);
|
||||||
for($y = $startY; $y > $endY and $y >= 0; --$y){
|
for($y = $startY; $y > $endY and $y >= 0; --$y){
|
||||||
$b = $cover[$startY - $y];
|
$b = $cover[$startY - $y];
|
||||||
if($column{$y} === "\x00" and $b->isSolid()){
|
if($column[$y] === "\x00" and $b->isSolid()){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if($b->canBeFlowedInto() and BlockFactory::get(ord($column{$y})) instanceof Liquid){
|
if($b->canBeFlowedInto() and BlockFactory::get(ord($column[$y])) instanceof Liquid){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if($b->getDamage() === 0){
|
if($b->getDamage() === 0){
|
||||||
|
@ -120,12 +120,12 @@ class VerifyLoginTask extends AsyncTask{
|
|||||||
[$rString, $sString] = str_split($plainSignature, 48);
|
[$rString, $sString] = str_split($plainSignature, 48);
|
||||||
|
|
||||||
$rString = ltrim($rString, "\x00");
|
$rString = ltrim($rString, "\x00");
|
||||||
if(ord($rString{0}) >= 128){ //Would be considered signed, pad it with an extra zero
|
if(ord($rString[0]) >= 128){ //Would be considered signed, pad it with an extra zero
|
||||||
$rString = "\x00" . $rString;
|
$rString = "\x00" . $rString;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sString = ltrim($sString, "\x00");
|
$sString = ltrim($sString, "\x00");
|
||||||
if(ord($sString{0}) >= 128){ //Would be considered signed, pad it with an extra zero
|
if(ord($sString[0]) >= 128){ //Would be considered signed, pad it with an extra zero
|
||||||
$sString = "\x00" . $sString;
|
$sString = "\x00" . $sString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class UnknownPacket extends DataPacket{
|
|||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
if(strlen($this->payload ?? "") > 0){
|
if(strlen($this->payload ?? "") > 0){
|
||||||
return ord($this->payload{0});
|
return ord($this->payload[0]);
|
||||||
}
|
}
|
||||||
return self::NETWORK_ID;
|
return self::NETWORK_ID;
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ class QueryHandler{
|
|||||||
|
|
||||||
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++]);
|
||||||
$sessionID = Binary::readInt(substr($packet, $offset, 4));
|
$sessionID = Binary::readInt(substr($packet, $offset, 4));
|
||||||
$offset += 4;
|
$offset += 4;
|
||||||
$payload = substr($packet, $offset);
|
$payload = substr($packet, $offset);
|
||||||
|
@ -154,7 +154,7 @@ class BanList{
|
|||||||
$fp = @fopen($this->file, "r");
|
$fp = @fopen($this->file, "r");
|
||||||
if(is_resource($fp)){
|
if(is_resource($fp)){
|
||||||
while(($line = fgets($fp)) !== false){
|
while(($line = fgets($fp)) !== false){
|
||||||
if($line{0} !== "#"){
|
if($line[0] !== "#"){
|
||||||
try{
|
try{
|
||||||
$entry = BanEntry::fromString($line);
|
$entry = BanEntry::fromString($line);
|
||||||
if($entry instanceof BanEntry){
|
if($entry instanceof BanEntry){
|
||||||
|
@ -496,7 +496,7 @@ class Utils{
|
|||||||
public static function javaStringHash(string $string) : int{
|
public static function javaStringHash(string $string) : int{
|
||||||
$hash = 0;
|
$hash = 0;
|
||||||
for($i = 0, $len = strlen($string); $i < $len; $i++){
|
for($i = 0, $len = strlen($string); $i < $len; $i++){
|
||||||
$ord = ord($string{$i});
|
$ord = ord($string[$i]);
|
||||||
if($ord & 0x80){
|
if($ord & 0x80){
|
||||||
$ord -= 0x100;
|
$ord -= 0x100;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user