fix(plugins) basic private server variable

This commit is contained in:
gh0sTedBuddy
2024-04-07 13:44:22 +01:00
parent ebda263852
commit a3c5a832b7
2 changed files with 6 additions and 2 deletions

View File

@@ -3,6 +3,10 @@ export default class BasePlugin {
constructor() { constructor() {
} }
_getServer() {
return this.#wetsock;
}
initialize(wetsock) { initialize(wetsock) {
this.#wetsock = wetsock; this.#wetsock = wetsock;
} }

View File

@@ -48,7 +48,7 @@ class EntityPlugin extends BasePlugin {
broadcast(clientId, message) { broadcast(clientId, message) {
// Broadcast the message to all connected clients // 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) { if (id !== clientId) {
client.send(JSON.stringify(message)); client.send(JSON.stringify(message));
} }
@@ -57,7 +57,7 @@ class EntityPlugin extends BasePlugin {
send(clientId, message) { send(clientId, message) {
// Send the message to a specific client // Send the message to a specific client
const client = this.#wetsock.clients.get(clientId); const client = this._getServer().clients.get(clientId);
if (client) { if (client) {
client.send(JSON.stringify(message)); client.send(JSON.stringify(message));
} }