From 2ac2fd4b1cf427160c617d95941575b320ad5f2a Mon Sep 17 00:00:00 2001 From: Skillet Date: Fri, 14 Apr 2023 17:33:08 -0400 Subject: [PATCH] Update mapvote.js --- mapvote.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mapvote.js b/mapvote.js index 6f011c1..fbaf90a 100644 --- a/mapvote.js +++ b/mapvote.js @@ -352,10 +352,13 @@ export default class MapVote extends DiscordBasePlugin { if (this.server.players.length >= 1 && this.server.players.length < maxSeedingModePlayerCount) { if (+(new Date()) - +this.server.layerHistory[ 0 ].time > 30 * 1000) { const seedingMaps = Layers.layers.filter((l) => l.layerid && l.gamemode.toLowerCase() == this.options.seedingGameMode && !this.options.layerLevelBlacklist.find((fl) => l.layerid.toLowerCase().startsWith(fl.toLowerCase()))) - + this.verbose(1, seedingMaps); + const rndMap = randomElement(seedingMaps); if (this.server.currentLayer) { + this.verbose(1, "checking current layer gamemode"); if (this.server.currentLayer.gamemode.toLowerCase() != this.options.seedingGameMode) { + this.verbose(1, "checking player count"); if (this.server.players.length <= this.options.instantSeedingModePlayerCount) { const newCurrentMap = rndMap.layerid; this.verbose(1, 'Going into seeding mode.'); @@ -366,12 +369,11 @@ export default class MapVote extends DiscordBasePlugin { if (this.server.nextLayer) { const nextMaps = seedingMaps.filter((l) => (!this.server.currentLayer || l.layerid != this.server.currentLayer.layerid)) - let rndMap2; - do rndMap2 = randomElement(nextMaps); - while (rndMap2.layerid == rndMap.layerid) + const rndMap2 = randomElement(nextMaps); - if (this.server.players.length < this.options.nextLayerSeedingModePlayerCount && this.server.nextLayer.gamemode.toLowerCase() != "seed") { + if (this.server.players.length < this.options.nextLayerSeedingModePlayerCount && this.server.nextLayer.gamemode.toLowerCase() != this.options.seedingGameMode) { const newNextMap = rndMap2.layerid; + this.verbose(1, "setting next layer to seed mode"); this.server.rcon.execute(`AdminSetNextLayer ${newNextMap} `); } } else this.verbose(1, "Bad data (nextLayer). Seeding mode for next layer skipped to prevent errors.");