Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CooldownManager {
- public Map<UUID, Long> cooldowns;
- public CooldownManager() {
- this.cooldowns = new HashMap<UUID, Long>();
- }
- public void addCooldown(final Player player) {
- final long time = System.currentTimeMillis();
- this.cooldowns.put(player.getUniqueId(), time);
- }
- public void removeCooldown(final Player player) {
- this.cooldowns.remove(player.getUniqueId());
- }
- public boolean hasCooldown(final Player player, final int timer) {
- if (!this.cooldowns.containsKey(player.getUniqueId())) {
- return false;
- }
- final long now = System.currentTimeMillis();
- final long time = this.cooldowns.get(player.getUniqueId());
- if (now - time >= timer) {
- this.cooldowns.remove(player.getUniqueId());
- return false;
- }
- return true;
- }
- }
- public CooldownManager getCooldownManager() {
- return this.cooldownManager;
- }
- public void onLoad() {
- this.cooldownManager = new CooldownManager();
- }
- public CooldownManager cooldownManager;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement