Introduced cooldown time perks
This commit is contained in:
@@ -74,7 +74,7 @@ public abstract class Spell extends EcoEnchant {
|
||||
if (this.getDisabledWorlds().contains(player.getWorld())) return;
|
||||
|
||||
if (!cooldownTracker.containsKey(player.getUniqueId()))
|
||||
cooldownTracker.put(player.getUniqueId(), new SpellRunnable(this));
|
||||
cooldownTracker.put(player.getUniqueId(), new SpellRunnable(this, player));
|
||||
|
||||
SpellRunnable runnable = cooldownTracker.get(player.getUniqueId());
|
||||
runnable.setTask(() -> {
|
||||
@@ -100,7 +100,7 @@ public abstract class Spell extends EcoEnchant {
|
||||
|
||||
public static int getCooldown(Spell spell, Player player) {
|
||||
if (!spell.cooldownTracker.containsKey(player.getUniqueId()))
|
||||
spell.cooldownTracker.put(player.getUniqueId(), new SpellRunnable(spell));
|
||||
spell.cooldownTracker.put(player.getUniqueId(), new SpellRunnable(spell, player));
|
||||
|
||||
SpellRunnable runnable = spell.cooldownTracker.get(player.getUniqueId());
|
||||
|
||||
@@ -110,4 +110,12 @@ public abstract class Spell extends EcoEnchant {
|
||||
|
||||
return new Long(secondsLeft).intValue();
|
||||
}
|
||||
|
||||
public static double getCooldownMultiplier(Player player) {
|
||||
if(player.hasPermission("ecoenchants.cooldowntime.quarter")) return 0.25;
|
||||
if(player.hasPermission("ecoenchants.cooldowntime.third")) return 0.33;
|
||||
if(player.hasPermission("ecoenchants.cooldowntime.half")) return 0.5;
|
||||
if(player.hasPermission("ecoenchants.cooldowntime.75")) return 0.75;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,18 @@ package com.willfp.ecoenchants.enchantments.util;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.itemtypes.Spell;
|
||||
import com.willfp.ecoenchants.util.interfaces.Callable;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SpellRunnable {
|
||||
private final Spell spell;
|
||||
private final Player player;
|
||||
private long endTime = 0;
|
||||
private Callable callable = () -> {
|
||||
};
|
||||
|
||||
public SpellRunnable(Spell spell) {
|
||||
public SpellRunnable(Spell spell, Player player) {
|
||||
this.spell = spell;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public Spell getSpell() {
|
||||
@@ -27,7 +30,7 @@ public class SpellRunnable {
|
||||
}
|
||||
|
||||
public void updateEndTime() {
|
||||
endTime = System.currentTimeMillis() + (spell.getCooldownTime() * 1000L);
|
||||
endTime = System.currentTimeMillis() + (long) ((spell.getCooldownTime() * 1000L) * Spell.getCooldownMultiplier(player));
|
||||
}
|
||||
|
||||
public void setTask(Callable callable) {
|
||||
|
||||
@@ -68,3 +68,17 @@ permissions:
|
||||
ecoenchants.anvil.bypasshardcap:
|
||||
description: Allows bypassing the anvil hard cap
|
||||
default: op
|
||||
|
||||
# Perks
|
||||
ecoenchants.cooldowntime.half:
|
||||
description: Halves the cooldown time on spells
|
||||
default: op
|
||||
ecoenchants.cooldowntime.third:
|
||||
description: Thirds the cooldown time on spells
|
||||
default: op
|
||||
ecoenchants.cooldowntime.quarter:
|
||||
description: Quarters the cooldown time on spells
|
||||
default: op
|
||||
ecoenchants.cooldowntime.75:
|
||||
description: Reduces the cooldown time on spells by 25%
|
||||
default: op
|
||||
Reference in New Issue
Block a user