2024-02-29 20:39:21 -05:00
|
|
|
function inject (bot) {
|
2024-05-26 19:38:43 -04:00
|
|
|
bot.on('player_data_loaded', (player, data) => {
|
|
|
|
data.data.seen ??= {}
|
|
|
|
const seenData = data.data.seen
|
2024-02-16 22:59:09 -05:00
|
|
|
|
2024-05-26 19:38:43 -04:00
|
|
|
if (seenData.first == null) {
|
2024-11-07 00:09:40 -05:00
|
|
|
seenData.first = createSeenValue()
|
2024-05-26 19:38:43 -04:00
|
|
|
bot.tellraw([
|
2024-04-02 17:53:10 -04:00
|
|
|
{ text: 'Welcome ', ...bot.styles.primary },
|
|
|
|
{ text: player.username, ...bot.styles.secondary },
|
2024-02-16 22:59:09 -05:00
|
|
|
' to the server!'
|
2024-05-26 19:38:43 -04:00
|
|
|
], '@a')
|
2024-02-16 22:59:09 -05:00
|
|
|
}
|
2024-11-07 00:09:40 -05:00
|
|
|
seenData.last = createSeenValue()
|
2024-02-16 22:59:09 -05:00
|
|
|
})
|
|
|
|
|
2024-05-26 19:38:43 -04:00
|
|
|
bot.on('player_data_unloading', (player, data) => {
|
|
|
|
const seenData = data.data.seen
|
2024-11-07 00:09:40 -05:00
|
|
|
if (seenData != null) seenData.last = createSeenValue()
|
2024-02-11 21:23:41 -05:00
|
|
|
})
|
2024-11-07 00:09:40 -05:00
|
|
|
|
|
|
|
function createSeenValue () {
|
|
|
|
return { date: new Date(), host: bot.host, port: bot.port ?? 25565 }
|
|
|
|
}
|
2024-02-11 21:23:41 -05:00
|
|
|
}
|
|
|
|
|
2024-02-29 20:39:21 -05:00
|
|
|
module.exports = inject
|