Casting cleanup and removed some 32-bit string-int leftovers

This commit is contained in:
Dylan K. Taylor 2017-08-17 11:24:49 +01:00
parent 77376d3e33
commit 5b4035253b
6 changed files with 25 additions and 24 deletions

View File

@ -440,7 +440,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
* @param bool $remove * @param bool $remove
*/ */
public function setRemoveFormat(bool $remove = true){ public function setRemoveFormat(bool $remove = true){
$this->removeFormat = (bool) $remove; $this->removeFormat = $remove;
} }
public function getScreenLineHeight() : int{ public function getScreenLineHeight() : int{
@ -3435,7 +3435,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
if($this->connected and !$this->closed){ if($this->connected and !$this->closed){
try{ try{
if($notify and strlen((string) $reason) > 0){ if($notify and strlen($reason) > 0){
$pk = new DisconnectPacket(); $pk = new DisconnectPacket();
$pk->message = $reason; $pk->message = $reason;
$this->directDataPacket($pk); $this->directDataPacket($pk);

View File

@ -428,7 +428,7 @@ class Server{
* @return string * @return string
*/ */
public static function getGamemodeString(int $mode) : string{ public static function getGamemodeString(int $mode) : string{
switch((int) $mode){ switch($mode){
case Player::SURVIVAL: case Player::SURVIVAL:
return "%gameMode.survival"; return "%gameMode.survival";
case Player::CREATIVE: case Player::CREATIVE:
@ -1209,7 +1209,7 @@ class Server{
return (int) $v[$variable]; return (int) $v[$variable];
} }
return $this->properties->exists($variable) ? (int) $this->properties->get($variable) : (int) $defaultValue; return $this->properties->exists($variable) ? (int) $this->properties->get($variable) : $defaultValue;
} }
/** /**
@ -1217,7 +1217,7 @@ class Server{
* @param int $value * @param int $value
*/ */
public function setConfigInt(string $variable, int $value){ public function setConfigInt(string $variable, int $value){
$this->properties->set($variable, (int) $value); $this->properties->set($variable, $value);
} }
/** /**

View File

@ -180,6 +180,7 @@ class Level implements ChunkManager, Metadatable{
/** @var float[] */ /** @var float[] */
private $unloadQueue = []; private $unloadQueue = [];
/** @var int */
private $time; private $time;
public $stopTime; public $stopTime;
@ -334,7 +335,7 @@ class Level implements ChunkManager, Metadatable{
$this->neighbourBlockUpdateQueue = new \SplQueue(); $this->neighbourBlockUpdateQueue = new \SplQueue();
$this->time = (int) $this->provider->getTime(); $this->time = $this->provider->getTime();
$this->chunkTickRadius = min($this->server->getViewDistance(), max(1, (int) $this->server->getProperty("chunk-ticking.tick-radius", 4))); $this->chunkTickRadius = min($this->server->getViewDistance(), max(1, (int) $this->server->getProperty("chunk-ticking.tick-radius", 4)));
$this->chunksPerTick = (int) $this->server->getProperty("chunk-ticking.per-tick", 40); $this->chunksPerTick = (int) $this->server->getProperty("chunk-ticking.per-tick", 40);
@ -668,7 +669,7 @@ class Level implements ChunkManager, Metadatable{
*/ */
public function sendTime(Player ...$targets){ public function sendTime(Player ...$targets){
$pk = new SetTimePacket(); $pk = new SetTimePacket();
$pk->time = (int) $this->time; $pk->time = $this->time;
$this->server->broadcastPacket(count($targets) > 0 ? $targets : $this->players, $pk); $this->server->broadcastPacket(count($targets) > 0 ? $targets : $this->players, $pk);
} }
@ -1010,7 +1011,7 @@ class Level implements ChunkManager, Metadatable{
$this->server->getPluginManager()->callEvent(new LevelSaveEvent($this)); $this->server->getPluginManager()->callEvent(new LevelSaveEvent($this));
$this->provider->setTime((int) $this->time); $this->provider->setTime($this->time);
$this->saveChunks(); $this->saveChunks();
if($this->provider instanceof BaseLevelProvider){ if($this->provider instanceof BaseLevelProvider){
$this->provider->saveLevelData(); $this->provider->saveLevelData();
@ -1090,7 +1091,7 @@ class Level implements ChunkManager, Metadatable{
return; return;
} }
$this->scheduledBlockUpdateQueueIndex[$index] = $delay; $this->scheduledBlockUpdateQueueIndex[$index] = $delay;
$this->scheduledBlockUpdateQueue->insert(new Vector3((int) $pos->x, (int) $pos->y, (int) $pos->z), (int) $delay + $this->server->getTick()); $this->scheduledBlockUpdateQueue->insert(new Vector3((int) $pos->x, (int) $pos->y, (int) $pos->z), $delay + $this->server->getTick());
} }
/** /**
@ -2729,7 +2730,7 @@ class Level implements ChunkManager, Metadatable{
* @return int * @return int
*/ */
public function getTime() : int{ public function getTime() : int{
return (int) $this->time; return $this->time;
} }
/** /**

View File

@ -84,19 +84,19 @@ abstract class BaseLevelProvider implements LevelProvider{
return (string) $this->levelData["LevelName"]; return (string) $this->levelData["LevelName"];
} }
public function getTime(){ public function getTime() : int{
return $this->levelData["Time"]; return $this->levelData["Time"];
} }
public function setTime($value){ public function setTime(int $value){
$this->levelData->Time = new LongTag("Time", $value); $this->levelData->Time = new LongTag("Time", $value);
} }
public function getSeed(){ public function getSeed() : int{
return $this->levelData["RandomSeed"]; return $this->levelData["RandomSeed"];
} }
public function setSeed($value){ public function setSeed(int $value){
$this->levelData->RandomSeed = new LongTag("RandomSeed", $value); $this->levelData->RandomSeed = new LongTag("RandomSeed", $value);
} }

View File

@ -177,24 +177,24 @@ interface LevelProvider{
public function getName() : string; public function getName() : string;
/** /**
* @return int|string int, or the string numeric representation of a long in 32-bit systems * @return int
*/ */
public function getTime(); public function getTime() : int;
/** /**
* @param int|string $value int, or the string numeric representation of a long in 32-bit systems * @param int
*/ */
public function setTime($value); public function setTime(int $value);
/** /**
* @return int|string int, or the string numeric representation of a long in 32-bit systems * @return int
*/ */
public function getSeed(); public function getSeed() : int;
/** /**
* @param int|string $value int, or the string numeric representation of a long in 32-bit systems * @param int
*/ */
public function setSeed($value); public function setSeed(int $value);
/** /**
* @return Vector3 * @return Vector3

View File

@ -260,8 +260,8 @@ class PluginManager{
$plugins[$name] = $file; $plugins[$name] = $file;
$softDependencies[$name] = (array) $description->getSoftDepend(); $softDependencies[$name] = $description->getSoftDepend();
$dependencies[$name] = (array) $description->getDepend(); $dependencies[$name] = $description->getDepend();
foreach($description->getLoadBefore() as $before){ foreach($description->getLoadBefore() as $before){
if(isset($softDependencies[$before])){ if(isset($softDependencies[$before])){