2015-11-26 03:49:01 +01:00
|
|
|
package mineplex.game.clans.items.legendaries;
|
2015-05-16 18:58:58 +02:00
|
|
|
|
2015-06-01 18:25:20 +02:00
|
|
|
import org.bukkit.Material;
|
2015-05-16 18:58:58 +02:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.potion.PotionEffect;
|
|
|
|
import org.bukkit.potion.PotionEffectType;
|
|
|
|
|
2015-11-27 04:28:19 +01:00
|
|
|
import mineplex.core.common.util.C;
|
|
|
|
import mineplex.core.recharge.Recharge;
|
2015-10-26 13:21:33 +01:00
|
|
|
import mineplex.game.clans.items.generation.ValueDistribution;
|
|
|
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
|
|
|
|
2015-11-25 02:32:05 +01:00
|
|
|
public class HyperAxe extends LegendaryItem
|
2015-05-16 18:58:58 +02:00
|
|
|
{
|
2015-11-26 03:49:01 +01:00
|
|
|
public static final long ATTACK_RATE_DURATION = 200;
|
2015-05-16 18:58:58 +02:00
|
|
|
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;
|
|
|
|
|
2015-06-01 18:25:20 +02:00
|
|
|
private long _lastAttack;
|
|
|
|
public long timeSinceLastAttack() { return System.currentTimeMillis() - _lastAttack; }
|
|
|
|
|
2015-11-25 02:32:05 +01:00
|
|
|
public HyperAxe()
|
2015-05-16 18:58:58 +02:00
|
|
|
{
|
2015-11-27 04:28:19 +01:00
|
|
|
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);
|
2015-05-16 18:58:58 +02:00
|
|
|
_speedAmount = amountGen.generateIntValue();
|
|
|
|
_speedDuration = durationGen.generateIntValue();
|
2015-06-01 18:25:20 +02:00
|
|
|
_lastAttack = 0;
|
2015-05-16 18:58:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void update(Player wielder)
|
|
|
|
{
|
|
|
|
if (isHoldingRightClick() && canBuff())
|
|
|
|
{
|
|
|
|
buffPlayer(wielder);
|
2015-11-26 03:49:01 +01:00
|
|
|
_lastAttack = System.currentTimeMillis();
|
2015-05-16 18:58:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-06-01 18:25:20 +02:00
|
|
|
public void onAttack(CustomDamageEvent event, Player wielder)
|
2015-05-16 18:58:58 +02:00
|
|
|
{
|
2015-06-01 18:25:20 +02:00
|
|
|
if (timeSinceLastAttack() >= ATTACK_RATE_DURATION)
|
|
|
|
{
|
|
|
|
event.SetIgnoreRate(true);
|
2015-11-26 03:49:01 +01:00
|
|
|
// log("Ignoring rate!");
|
|
|
|
|
2015-11-26 05:21:30 +01:00
|
|
|
event.AddMod("Hyper Axe", 1);
|
2015-11-26 03:49:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
event.SetCancelled("Hyper Axe Cooldown");
|
2015-06-01 18:25:20 +02:00
|
|
|
}
|
2015-05-16 18:58:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void buffPlayer(Player wielder)
|
|
|
|
{
|
2015-11-27 04:28:19 +01:00
|
|
|
if (!Recharge.Instance.use(wielder, "Hyper Rush", 16000, true, true))
|
|
|
|
return;
|
|
|
|
|
2015-05-16 18:58:58 +02:00
|
|
|
// Give player speed buff
|
2015-06-01 18:25:20 +02:00
|
|
|
wielder.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, _speedDuration, _speedAmount));
|
|
|
|
log("Buffing");
|
2015-05-16 18:58:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private boolean canBuff()
|
|
|
|
{
|
|
|
|
return true; // TODO: Implement cooldown? (None specified in docs, sounds OP)
|
|
|
|
}
|
|
|
|
}
|