mirror of
https://github.com/AsgardEternal/SquadJS.git
synced 2024-09-28 11:54:23 -05:00
fixing the PR
This commit is contained in:
parent
c5bd408b02
commit
2fd278e4cd
12
README.md
12
README.md
@ -773,7 +773,17 @@ Grafana (NOT YET WORKING WITH V2):
|
||||
<h6>Description</h6>
|
||||
<p>"Live" message to display.</p>
|
||||
<h6>Default</h6>
|
||||
<pre><code>Live!</code></pre></li></ul>
|
||||
<pre><code>Live!</code></pre></li>
|
||||
<li><h4>waitOnNewGames</h4>
|
||||
<h6>Description</h6>
|
||||
<p>Should the plugin wait to be executed on NEW_GAME event.</p>
|
||||
<h6>Default</h6>
|
||||
<pre><code>true</code></pre></li>
|
||||
<li><h4>waitTimeOnNewGame</h4>
|
||||
<h6>Description</h6>
|
||||
<p>The time to wait before check player counts in seconds.</p>
|
||||
<h6>Default</h6>
|
||||
<pre><code>30</code></pre></li></ul>
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
@ -176,7 +176,9 @@
|
||||
"seedingMessage": "Seeding Rules Active! Fight only over the middle flags! No FOB Hunting!",
|
||||
"liveEnabled": true,
|
||||
"liveThreshold": 52,
|
||||
"liveMessage": "Live!"
|
||||
"liveMessage": "Live!",
|
||||
"waitOnNewGames": true,
|
||||
"waitTimeOnNewGame": 30
|
||||
},
|
||||
{
|
||||
"plugin": "SocketIOAPI",
|
||||
|
@ -44,6 +44,16 @@ export default class SeedingMode extends BasePlugin {
|
||||
required: false,
|
||||
description: '"Live" message to display.',
|
||||
default: 'Live!'
|
||||
},
|
||||
waitOnNewGames: {
|
||||
required: false,
|
||||
description: 'Should the plugin wait to be executed on NEW_GAME event.',
|
||||
default: true
|
||||
},
|
||||
waitTimeOnNewGame: {
|
||||
required: false,
|
||||
description: 'The time to wait before check player counts in seconds.',
|
||||
default: 30
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -51,28 +61,57 @@ export default class SeedingMode extends BasePlugin {
|
||||
constructor(server, options, connectors) {
|
||||
super(server, options, connectors);
|
||||
|
||||
this.waitOnMapChange = false;
|
||||
this.broadcast = this.broadcast.bind(this);
|
||||
this.onNewGame = this.onNewGame.bind(this);
|
||||
}
|
||||
|
||||
async mount() {
|
||||
if (this.options.waitOnNewGames) {
|
||||
this.server.on('NEW_GAME', this.onNewGame);
|
||||
}
|
||||
|
||||
this.interval = setInterval(this.broadcast, this.options.interval);
|
||||
}
|
||||
|
||||
async unmount() {
|
||||
clearInterval(this.interval);
|
||||
this.server.removeEventListener('NEW_GAME', this.onNewGame);
|
||||
}
|
||||
|
||||
onNewGame(info) {
|
||||
this.waitOnMapChange = true;
|
||||
}
|
||||
|
||||
async broadcast() {
|
||||
if (
|
||||
this.server.a2sPlayerCount !== 0 &&
|
||||
this.server.a2sPlayerCount < this.options.seedingThreshold
|
||||
)
|
||||
await this.server.rcon.broadcast(this.options.seedingMessage);
|
||||
else if (
|
||||
this.server.a2sPlayerCount !== 0 &&
|
||||
this.options.liveEnabled &&
|
||||
this.server.a2sPlayerCount < this.options.liveThreshold
|
||||
)
|
||||
await this.server.rcon.broadcast(this.options.liveMessage);
|
||||
if (this.options.waitOnNewGames && this.waitOnMapChange) {
|
||||
setTimeout(async () => {
|
||||
if (
|
||||
this.server.a2sPlayerCount !== 0 &&
|
||||
this.server.a2sPlayerCount < this.options.seedingThreshold
|
||||
)
|
||||
await this.server.rcon.broadcast(this.options.seedingMessage);
|
||||
else if (
|
||||
this.server.a2sPlayerCount !== 0 &&
|
||||
this.options.liveEnabled &&
|
||||
this.server.a2sPlayerCount < this.options.liveThreshold
|
||||
)
|
||||
await this.server.rcon.broadcast(this.options.liveMessage);
|
||||
|
||||
this.waitOnMapChange = false;
|
||||
}, this.options.waitTimeOnNewGame * 1000);
|
||||
} else {
|
||||
if (
|
||||
this.server.a2sPlayerCount !== 0 &&
|
||||
this.server.a2sPlayerCount < this.options.seedingThreshold
|
||||
)
|
||||
await this.server.rcon.broadcast(this.options.seedingMessage);
|
||||
else if (
|
||||
this.server.a2sPlayerCount !== 0 &&
|
||||
this.options.liveEnabled &&
|
||||
this.server.a2sPlayerCount < this.options.liveThreshold
|
||||
)
|
||||
await this.server.rcon.broadcast(this.options.liveMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user