mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
Human: remove getRawUniqueId() premature optimization
this is never used in a hot path and presents a potential for inconsistency.
This commit is contained in:
parent
2e01bd1029
commit
45b0cbc796
@ -165,6 +165,8 @@ This version features substantial changes to the network system, improving coher
|
||||
- `Living->hasEffect()` -> `EffectManager->has()`
|
||||
- `Living->hasEffects()` -> `EffectManager->hasEffects()`
|
||||
- `Living->getEffects()` -> `EffectManager->all()`
|
||||
- The following API methods have been removed:
|
||||
- `Human->getRawUniqueId()`: use `Human->getUniqueId()->toBinary()` instead
|
||||
- The following classes have been removed:
|
||||
- `Creature`
|
||||
- `Damageable`
|
||||
|
@ -1781,16 +1781,17 @@ class Server{
|
||||
foreach($this->playerList as $p){
|
||||
$p->getNetworkSession()->onPlayerAdded($player);
|
||||
}
|
||||
$this->playerList[$player->getRawUniqueId()] = $player;
|
||||
$rawUUID = $player->getUniqueId()->toBinary();
|
||||
$this->playerList[$rawUUID] = $player;
|
||||
|
||||
if($this->sendUsageTicker > 0){
|
||||
$this->uniquePlayers[$player->getRawUniqueId()] = $player->getRawUniqueId();
|
||||
$this->uniquePlayers[$rawUUID] = $rawUUID;
|
||||
}
|
||||
}
|
||||
|
||||
public function removeOnlinePlayer(Player $player) : void{
|
||||
if(isset($this->playerList[$player->getRawUniqueId()])){
|
||||
unset($this->playerList[$player->getRawUniqueId()]);
|
||||
if(isset($this->playerList[$rawUUID = $player->getUniqueId()->toBinary()])){
|
||||
unset($this->playerList[$rawUUID]);
|
||||
foreach($this->playerList as $p){
|
||||
$p->getNetworkSession()->onPlayerRemoved($player);
|
||||
}
|
||||
|
@ -82,7 +82,6 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
|
||||
|
||||
/** @var UUID */
|
||||
protected $uuid;
|
||||
protected $rawUUID;
|
||||
|
||||
public $width = 0.6;
|
||||
public $height = 1.8;
|
||||
@ -137,13 +136,6 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
|
||||
return $this->uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRawUniqueId() : string{
|
||||
return $this->rawUUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Skin object containing information about this human's skin.
|
||||
* @return Skin
|
||||
|
@ -282,7 +282,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
||||
$this->randomClientId = $this->playerInfo->getClientId();
|
||||
|
||||
$this->uuid = $this->playerInfo->getUuid();
|
||||
$this->rawUUID = $this->uuid->toBinary();
|
||||
$this->xuid = $this->playerInfo->getXuid();
|
||||
|
||||
$this->perm = new PermissibleBase($this);
|
||||
@ -575,7 +574,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
||||
* @return bool
|
||||
*/
|
||||
public function canSee(Player $player) : bool{
|
||||
return !isset($this->hiddenPlayers[$player->getRawUniqueId()]);
|
||||
return !isset($this->hiddenPlayers[$player->getUniqueId()->toBinary()]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -585,7 +584,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
||||
if($player === $this){
|
||||
return;
|
||||
}
|
||||
$this->hiddenPlayers[$player->getRawUniqueId()] = true;
|
||||
$this->hiddenPlayers[$player->getUniqueId()->toBinary()] = true;
|
||||
$player->despawnFrom($this);
|
||||
}
|
||||
|
||||
@ -596,7 +595,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
||||
if($player === $this){
|
||||
return;
|
||||
}
|
||||
unset($this->hiddenPlayers[$player->getRawUniqueId()]);
|
||||
unset($this->hiddenPlayers[$player->getUniqueId()->toBinary()]);
|
||||
if($player->isOnline()){
|
||||
$player->spawnTo($this);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user