Add a check to make sure that the player's socket also isn't undefined
This commit is contained in:
parent
f4396a1c42
commit
330125efbe
1 changed files with 1 additions and 1 deletions
|
|
@ -20,7 +20,7 @@ export class Player {
|
||||||
/** The socket that can be used to communicate directly with the player */
|
/** The socket that can be used to communicate directly with the player */
|
||||||
get socket() { return this._socket };
|
get socket() { return this._socket };
|
||||||
set socket(value: Socket) {
|
set socket(value: Socket) {
|
||||||
if (!this._socket.connected) {
|
if (!this._socket?.connected) {
|
||||||
this._socket = value;
|
this._socket = value;
|
||||||
} else {
|
} else {
|
||||||
throw Error("Cannot overwrite a player's socket that is connected.");
|
throw Error("Cannot overwrite a player's socket that is connected.");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue