Merge pull request #51 from Sunch233/master

Improve code quality
This commit is contained in:
enirboreHemaG 2025-01-11 18:59:26 +03:00 • committed by GitHub
commit 1d2efd7e78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 9 additions and 12 deletions

View file

@ -161,7 +161,7 @@ class BanAPI{
$player = $this->server->api->player->get($user); $player = $this->server->api->player->get($user);
if(!($player instanceof Player)){ if(!($player instanceof Player)){
$this->ops->set($user); $this->ops->set($user);
$this->ops->save($user); $this->ops->save();
$output .= $user . " is now op\n"; $output .= $user . " is now op\n";
break; break;
} }

View file

@ -150,7 +150,7 @@ class EntityAPI{
"y" => $pos->y, "y" => $pos->y,
"z" => $pos->z "z" => $pos->z
] + $data); ] + $data);
$this->spawnToAll($entity, $pos->level); $this->spawnToAll($entity);
} }
public function getNextEID(){ public function getNextEID(){

View file

@ -12,7 +12,7 @@ class PlayerAPI{
$this->server->addHandler("player.death", [$this, "handle"], 1); $this->server->addHandler("player.death", [$this, "handle"], 1);
$this->registerCmd("list"); $this->registerCmd("list");
$this->registerCmd("kill", "<player>"); $this->registerCmd("kill", "<player>");
$this->registerCmd("gamemode", "<mode> [player]", [$this, "commandHandler"]); $this->registerCmd("gamemode", "<mode> [player]");
$this->registerCmd("tp", "[target player] <destination player|w:world> OR /tp [target player] <x> <y> <z>"); $this->registerCmd("tp", "[target player] <destination player|w:world> OR /tp [target player] <x> <y> <z>");
$this->registerCmd("spawnpoint", "[player] [x] [y] [z]"); $this->registerCmd("spawnpoint", "[player] [x] [y] [z]");
$this->registerCmd("spawn"); $this->registerCmd("spawn");

View file

@ -591,7 +591,6 @@ class PocketMinecraftServer{
$this->clients[$CID] = new Player($packet->clientID, $packet->ip, $packet->port, $packet->mtuSize); //New Session! $this->clients[$CID] = new Player($packet->clientID, $packet->ip, $packet->port, $packet->mtuSize); //New Session!
$pk = new RakNetPacket(RakNetInfo::OPEN_CONNECTION_REPLY_2); $pk = new RakNetPacket(RakNetInfo::OPEN_CONNECTION_REPLY_2);
$pk->serverID = $this->serverID; $pk->serverID = $this->serverID;
$pk->port = $this->port;
$pk->mtuSize = $packet->mtuSize; $pk->mtuSize = $packet->mtuSize;
$pk->ip = $packet->ip; $pk->ip = $packet->ip;
$pk->port = $packet->port; $pk->port = $packet->port;

View file

@ -99,7 +99,7 @@ abstract class Living extends Entity implements Pathfindable{
foreach($this->level->entityListPositioned[$ind] ?? [] as $entid){ foreach($this->level->entityListPositioned[$ind] ?? [] as $entid){
if(($this->level->entityList[$entid] ?? null) instanceof Entity){ if(($this->level->entityList[$entid] ?? null) instanceof Entity){
if($this->level->entityList[$entid]->isPushable() && $bb->intersectsWith($this->level->entityList[$entid]->boundingBox)){ if($this->level->entityList[$entid]->isPushable() && $bb->intersectsWith($this->level->entityList[$entid]->boundingBox)){
$this->level->entityList[$entid]->applyCollision($this, true); $this->level->entityList[$entid]->applyCollision($this);
} }
} }
} }

View file

@ -397,7 +397,7 @@ class Minecart extends Vehicle{
if($e instanceof Entity && $e->eid != $this->eid && $e->eid != $this->linkedEntity){ if($e instanceof Entity && $e->eid != $this->eid && $e->eid != $this->linkedEntity){
if($e->isPushable() && $e->boundingBox->intersectsWith($bb)){ if($e->isPushable() && $e->boundingBox->intersectsWith($bb)){
if($e->isPlayer()){ if($e->isPlayer()){
$this->applyCollision($e, true); $this->applyCollision($e);
}else{ }else{
$e->applyCollision($this); $e->applyCollision($this);
} }

View file

@ -295,7 +295,7 @@ class CraftingRecipes{
break; break;
} }
} }
if($continue === false or $craftItem[0] !== $recipe[1][0] or $recipe[1][1] !== $recipe[1][1] or $recipe[1][2] !== $recipe[1][2]){ if($continue === false or $craftItem[0] !== $recipe[1][0]){
$continue = false; $continue = false;
continue; continue;
} }

View file

@ -15,7 +15,6 @@ class SmeltingData{
RED_MUSHROOM => [DYE, 1], RED_MUSHROOM => [DYE, 1],
RAW_BEEF => [STEAK, 0], RAW_BEEF => [STEAK, 0],
RAW_CHICKEN => [COOKED_CHICKEN, 0], RAW_CHICKEN => [COOKED_CHICKEN, 0],
RED_MUSHROOM => [DYE, 1],
POTATO => [BAKED_POTATO, 0], POTATO => [BAKED_POTATO, 0],
]; ];
} }

View file

@ -63,7 +63,7 @@ class RailLogic
} }
public function canConnectTo(RailLogic $rail){ public function canConnectTo(RailLogic $rail){
return $this->connectsTo($rail) || ((count($this->railPositions) == 2 ? false : (empty($this->railPositions) ? true : true))); return $this->connectsTo($rail) || !(count($this->railPositions) == 2);
} }
public function hasNeighborRail($x, $y, $z){ public function hasNeighborRail($x, $y, $z){

View file

@ -395,7 +395,6 @@ class Level{
if(count($this->changedCount) > 0){ if(count($this->changedCount) > 0){
arsort($this->changedCount); arsort($this->changedCount);
$resendChunks = [];
$reorder = false; $reorder = false;
foreach($this->changedCount as $index => $count){ foreach($this->changedCount as $index => $count){
if($count < 582){//Optimal value, calculated using the relation between minichunks and single packets if($count < 582){//Optimal value, calculated using the relation between minichunks and single packets

View file

@ -41,8 +41,8 @@ class SuperflatGenerator implements LevelGenerator{
$preset = explode(";", $preset); $preset = explode(";", $preset);
$version = (int) $preset[0]; $version = (int) $preset[0];
$blocks = @$preset[1]; $blocks = @$preset[1];
$biome = isset($preset[2]) ? $preset[2] : 1; $biome = $preset[2] ?? 1;
$options = isset($preset[3]) ? $preset[3] : ""; $options = $preset[3] ?? "";
preg_match_all('#(([0-9]{0,})x?([0-9]{1,3}:?[0-9]{0,2})),?#', $blocks, $matches); preg_match_all('#(([0-9]{0,})x?([0-9]{1,3}:?[0-9]{0,2})),?#', $blocks, $matches);
$y = 0; $y = 0;
$this->structure = []; $this->structure = [];