package com.lifeknight.relaymchub.cosmetics; import com.lifeknight.relaymchub.player.HubPlayer; import com.lifeknight.relayutils.player.cosmetics.Cosmetic; import org.bukkit.ChatColor; import java.util.List; public abstract class CooldownCosmetic extends DefinedLobbyCosmetic { protected double cooldown = 0; public CooldownCosmetic(Cosmetic original) { super(original); } public void use(HubPlayer hubPlayer, boolean rightClick) { if (this.hasCooldown()) { if (hubPlayer.enoughSecondsHaveElapsed(this.getCodeName(), this.cooldown)) { if (this.onUse(hubPlayer, rightClick)) { hubPlayer.updateCooldown(this.getCodeName()); } } else { hubPlayer.showCooldownWarning(this.getCodeName(), this.cooldown); } } else { this.onUse(hubPlayer, rightClick); } } public abstract boolean onUse(HubPlayer hubPlayer, boolean rightClick); public boolean hasCooldown() { return this.cooldown > 0; } public CooldownCosmetic setCooldown(double seconds) { this.cooldown = seconds; return this; } @Override public List<String> getDescription(boolean withExtraLine) { if (!this.hasCooldown()) { return super.getDescription(withExtraLine); } List<String> description = super.getDescription(withExtraLine); description.add(ChatColor.YELLOW + "Cooldown: " + this.cooldown + "s"); return description; } }