mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 00:29:54 +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->hasEffect()` -> `EffectManager->has()`
|
||||||
- `Living->hasEffects()` -> `EffectManager->hasEffects()`
|
- `Living->hasEffects()` -> `EffectManager->hasEffects()`
|
||||||
- `Living->getEffects()` -> `EffectManager->all()`
|
- `Living->getEffects()` -> `EffectManager->all()`
|
||||||
|
- The following API methods have been removed:
|
||||||
|
- `Human->getRawUniqueId()`: use `Human->getUniqueId()->toBinary()` instead
|
||||||
- The following classes have been removed:
|
- The following classes have been removed:
|
||||||
- `Creature`
|
- `Creature`
|
||||||
- `Damageable`
|
- `Damageable`
|
||||||
|
@ -1781,16 +1781,17 @@ class Server{
|
|||||||
foreach($this->playerList as $p){
|
foreach($this->playerList as $p){
|
||||||
$p->getNetworkSession()->onPlayerAdded($player);
|
$p->getNetworkSession()->onPlayerAdded($player);
|
||||||
}
|
}
|
||||||
$this->playerList[$player->getRawUniqueId()] = $player;
|
$rawUUID = $player->getUniqueId()->toBinary();
|
||||||
|
$this->playerList[$rawUUID] = $player;
|
||||||
|
|
||||||
if($this->sendUsageTicker > 0){
|
if($this->sendUsageTicker > 0){
|
||||||
$this->uniquePlayers[$player->getRawUniqueId()] = $player->getRawUniqueId();
|
$this->uniquePlayers[$rawUUID] = $rawUUID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeOnlinePlayer(Player $player) : void{
|
public function removeOnlinePlayer(Player $player) : void{
|
||||||
if(isset($this->playerList[$player->getRawUniqueId()])){
|
if(isset($this->playerList[$rawUUID = $player->getUniqueId()->toBinary()])){
|
||||||
unset($this->playerList[$player->getRawUniqueId()]);
|
unset($this->playerList[$rawUUID]);
|
||||||
foreach($this->playerList as $p){
|
foreach($this->playerList as $p){
|
||||||
$p->getNetworkSession()->onPlayerRemoved($player);
|
$p->getNetworkSession()->onPlayerRemoved($player);
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,6 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
|
|||||||
|
|
||||||
/** @var UUID */
|
/** @var UUID */
|
||||||
protected $uuid;
|
protected $uuid;
|
||||||
protected $rawUUID;
|
|
||||||
|
|
||||||
public $width = 0.6;
|
public $width = 0.6;
|
||||||
public $height = 1.8;
|
public $height = 1.8;
|
||||||
@ -137,13 +136,6 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
|
|||||||
return $this->uuid;
|
return $this->uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getRawUniqueId() : string{
|
|
||||||
return $this->rawUUID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a Skin object containing information about this human's skin.
|
* Returns a Skin object containing information about this human's skin.
|
||||||
* @return Skin
|
* @return Skin
|
||||||
|
@ -282,7 +282,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
|||||||
$this->randomClientId = $this->playerInfo->getClientId();
|
$this->randomClientId = $this->playerInfo->getClientId();
|
||||||
|
|
||||||
$this->uuid = $this->playerInfo->getUuid();
|
$this->uuid = $this->playerInfo->getUuid();
|
||||||
$this->rawUUID = $this->uuid->toBinary();
|
|
||||||
$this->xuid = $this->playerInfo->getXuid();
|
$this->xuid = $this->playerInfo->getXuid();
|
||||||
|
|
||||||
$this->perm = new PermissibleBase($this);
|
$this->perm = new PermissibleBase($this);
|
||||||
@ -575,7 +574,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function canSee(Player $player) : 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){
|
if($player === $this){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->hiddenPlayers[$player->getRawUniqueId()] = true;
|
$this->hiddenPlayers[$player->getUniqueId()->toBinary()] = true;
|
||||||
$player->despawnFrom($this);
|
$player->despawnFrom($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,7 +595,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
|||||||
if($player === $this){
|
if($player === $this){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
unset($this->hiddenPlayers[$player->getRawUniqueId()]);
|
unset($this->hiddenPlayers[$player->getUniqueId()->toBinary()]);
|
||||||
if($player->isOnline()){
|
if($player->isOnline()){
|
||||||
$player->spawnTo($this);
|
$player->spawnTo($this);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user