aboutsummaryrefslogtreecommitdiff
path: root/render/dwarvenNotifier.js
blob: 33739b0c94bb1929250cb758fe475e617d151c0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import settings from "../settings"
import { checkInDwarven, drawTitle } from "../util/helperFunctions"
import constants from "../util/constants"
const PREFIX = constants.PREFIX

let drawTitleState = 0,
 drawTimestamp = undefined

register("step", () => {
    if(checkInDwarven() || !settings.dwarvenNotifier) return
    const scoreboard = Scoreboard.getLines()

    for(let lineIndex = 0; lineIndex < scoreboard.length; lineIndex++) 
    {
        let line = scoreboard[lineIndex].toString()
        if (line.includes("☽") || line.includes("☀"))
        {
            let matches = /§7(\d\d?:\d\d)(am|pm)/g.exec(line)
            if(matches == undefined) return ChatLib.chat("No matches.")
            if(matches[1] == "12:00" && matches[2] == "am")
            {
                ChatLib.chat(`${PREFIX}&aA day has passed and your Skymall perk has changed!`)
                drawTitleState = 1
            }
        }
    }
}).setDelay(10)

register("renderOverlay", () => {
    if(drawTitleState == 1)
    {
        titleResults = drawTitle(`&2A day has passed and your &bSkymall &2perk has changed!`, drawTimestamp, 3)
        drawTitleState = titleResults.drawTitle
        drawTimestamp = titleResults.drawTimestamp
    }
})