aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/xmrvizzy/skyblocker/skyblock/cooldown/ItemCooldownEntry.java
blob: 0b21c75fdd27b0c6797a852de54b6dc59db05f03 (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
package me.xmrvizzy.skyblocker.skyblock.cooldown;

public class ItemCooldownEntry {
    private final int cooldown;
    private final long startTime;

    public ItemCooldownEntry(int cooldown) {
        this.cooldown = cooldown;
        this.startTime = System.currentTimeMillis();
    }

    public boolean isOnCooldown() {
        return (this.startTime + this.cooldown) > System.currentTimeMillis();
    }

    public long getRemainingCooldown() {
        long time = (this.startTime + this.cooldown) - System.currentTimeMillis();
        return time <= 0 ? 0 : time;
    }

    public float getRemainingCooldownPercent() {
        return this.isOnCooldown() ? ((float) this.getRemainingCooldown()) / ((float) cooldown) : 0.0f;
    }
}