From a3c5a832b70181b78d6a0476704247a353c06723 Mon Sep 17 00:00:00 2001 From: gh0sTedBuddy Date: Sun, 7 Apr 2024 13:44:22 +0100 Subject: [PATCH] fix(plugins) basic private server variable --- lib/WetSock/Plugins/BasePlugin.js | 4 ++++ lib/WetSock/Plugins/EntityPlugin.js | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/WetSock/Plugins/BasePlugin.js b/lib/WetSock/Plugins/BasePlugin.js index b76de63..cc590c4 100644 --- a/lib/WetSock/Plugins/BasePlugin.js +++ b/lib/WetSock/Plugins/BasePlugin.js @@ -3,6 +3,10 @@ export default class BasePlugin { constructor() { } + _getServer() { + return this.#wetsock; + } + initialize(wetsock) { this.#wetsock = wetsock; } diff --git a/lib/WetSock/Plugins/EntityPlugin.js b/lib/WetSock/Plugins/EntityPlugin.js index 0490e4d..9b0f096 100644 --- a/lib/WetSock/Plugins/EntityPlugin.js +++ b/lib/WetSock/Plugins/EntityPlugin.js @@ -48,7 +48,7 @@ class EntityPlugin extends BasePlugin { broadcast(clientId, message) { // Broadcast the message to all connected clients - for (const [id, client] of this.#wetsock.clients) { + for (const [id, client] of this._getServer().clients) { if (id !== clientId) { client.send(JSON.stringify(message)); } @@ -57,7 +57,7 @@ class EntityPlugin extends BasePlugin { send(clientId, message) { // Send the message to a specific client - const client = this.#wetsock.clients.get(clientId); + const client = this._getServer().clients.get(clientId); if (client) { client.send(JSON.stringify(message)); }