84 lines
2.4 KiB
Java
84 lines
2.4 KiB
Java
package mineplex.game.clans.items.legendaries;
|
|
|
|
import org.bukkit.Material;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.potion.PotionEffect;
|
|
import org.bukkit.potion.PotionEffectType;
|
|
|
|
import mineplex.core.common.util.C;
|
|
import mineplex.core.recharge.Recharge;
|
|
import mineplex.game.clans.items.generation.ValueDistribution;
|
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
|
|
|
public class HyperAxe extends LegendaryItem
|
|
{
|
|
public static final long ATTACK_RATE_DURATION = 200;
|
|
private static ValueDistribution amountGen = generateDistribution(0, 3); // [1, 4] speed amount
|
|
private static ValueDistribution durationGen = generateDistribution(80, 320); // [4, 16] seconds speed duration
|
|
|
|
private int _speedAmount;
|
|
private int _speedDuration;
|
|
|
|
private long _lastAttack;
|
|
public long timeSinceLastAttack() { return System.currentTimeMillis() - _lastAttack; }
|
|
|
|
public HyperAxe()
|
|
{
|
|
super("Hyper Axe", new String[]{
|
|
C.cWhite + "Of all the weapons known to man,",
|
|
C.cWhite + "none is more prevalent than the",
|
|
C.cWhite + "Hyper Axe. Infused with rabbit's",
|
|
C.cWhite + "speed and pigman's ferocity, this",
|
|
C.cWhite + "blade can rip through any opponent.",
|
|
C.cWhite + " ",
|
|
C.cWhite + "Hit delay is reduced by " + C.cYellow + "50%",
|
|
C.cWhite + "Deals " + C.cYellow + "10 Damage" + C.cWhite + " with attack",
|
|
C.cYellow + "Right-Click" + C.cWhite + " to use " + C.cGreen + "Dash",
|
|
}, Material.RECORD_3);
|
|
_speedAmount = amountGen.generateIntValue();
|
|
_speedDuration = durationGen.generateIntValue();
|
|
_lastAttack = 0;
|
|
}
|
|
|
|
@Override
|
|
public void update(Player wielder)
|
|
{
|
|
if (isHoldingRightClick() && canBuff())
|
|
{
|
|
buffPlayer(wielder);
|
|
_lastAttack = System.currentTimeMillis();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onAttack(CustomDamageEvent event, Player wielder)
|
|
{
|
|
if (timeSinceLastAttack() >= ATTACK_RATE_DURATION)
|
|
{
|
|
event.SetIgnoreRate(true);
|
|
// log("Ignoring rate!");
|
|
|
|
event.AddMod("Hyper Axe", 1);
|
|
}
|
|
else
|
|
{
|
|
event.SetCancelled("Hyper Axe Cooldown");
|
|
}
|
|
}
|
|
|
|
private void buffPlayer(Player wielder)
|
|
{
|
|
if (!Recharge.Instance.use(wielder, "Hyper Rush", 16000, true, true))
|
|
return;
|
|
|
|
// Give player speed buff
|
|
wielder.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, _speedDuration, _speedAmount));
|
|
log("Buffing");
|
|
}
|
|
|
|
private boolean canBuff()
|
|
{
|
|
return true; // TODO: Implement cooldown? (None specified in docs, sounds OP)
|
|
}
|
|
}
|