Skip to content

Commit

Permalink
fix: check for undefined players in playerList
Browse files Browse the repository at this point in the history
  • Loading branch information
Jameskmonger committed Jul 9, 2023
1 parent f163a8e commit 06d7d3e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/engine/world/world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ export class World {
public playerOnline(player: Player | string): boolean {
if(typeof player === 'string') {
player = player.toLowerCase();
return this.playerList.findIndex(p => p !== null && p.username.toLowerCase() === player) !== -1;
return this.playerList.findIndex(p => Boolean(p) && p.username.toLowerCase() === player) !== -1;
} else {
const foundPlayer = this.playerList[player.worldIndex];
if(!foundPlayer) {
Expand Down

0 comments on commit 06d7d3e

Please sign in to comment.