Skip to content

Commit

Permalink
Only have Gunther make announcements when there are online players
Browse files Browse the repository at this point in the history
  • Loading branch information
RussellLVP committed May 29, 2020
1 parent 2cec83c commit f4c9515
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,20 @@ export default class CommunicationCommands extends Feature {
await wait(this.settings_().getValue('playground/gunther_help_interval_sec') * 1000);
if (this.disposed_)
return;


let hasOnlinePlayers = 0;
for (const player of server.playerManager) {
if (player.isNonPlayerCharacter())
continue;

hasOnlinePlayers = true;
break;
}

const message = kGuntherMessages[Math.floor(Math.random() * kGuntherMessages.length)];
const gunther = server.playerManager.getByName('Gunther', false);

if (gunther)
if (gunther && hasOnlinePlayers)
this.onShowCommand(gunther, message, null);

} while (true);
Expand Down

0 comments on commit f4c9515

Please sign in to comment.