fix cannon tnt exploding prematurely, added cooldown rather than using Recharge.
This commit is contained in:
parent
33845cbc72
commit
9b88683fdc
@ -44,8 +44,8 @@ import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClanTips.TipType;
|
||||
@ -55,7 +55,10 @@ public class Cannon implements Listener
|
||||
{
|
||||
public static final ItemStack CANNON_ITEM = new ItemBuilder(Material.IRON_BLOCK, 1).setRawTitle(C.cBlue + "Cannon").setLore(C.cWhite + "BOOM BABY!").build();
|
||||
|
||||
public static final int COOLDOWN = 20 * 1000 /* 20 seconds*/;
|
||||
|
||||
public static final int MAX_SULPHUR = 3;
|
||||
public static final int MAX_TNT = 1;
|
||||
|
||||
public static final int TNT_SLOT = 4;
|
||||
public static final List<Integer> SULPHUR_SLOTS = Arrays.asList(1, 3, 5, 7);
|
||||
@ -201,7 +204,7 @@ public class Cannon implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onTntExplode(EntityExplodeEvent event)
|
||||
{
|
||||
// stop the tnt from exploding naturally
|
||||
@ -238,14 +241,17 @@ public class Cannon implements Listener
|
||||
{
|
||||
if (canBeFired())
|
||||
{
|
||||
if (Recharge.Instance.use(_rider, "Fire Cannon", 10000 /* 10 seconds */, true, false))
|
||||
if (System.currentTimeMillis() - _lastFired < COOLDOWN)
|
||||
{
|
||||
fire();
|
||||
UtilPlayer.message(_rider, F.main("Clans", "Cannon is cooling down."));
|
||||
return;
|
||||
}
|
||||
|
||||
fire();
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(_rider, F.main("Clans", "Cannon is not correctly loaded."));
|
||||
UtilPlayer.message(_rider, F.main("Clans", "Cannon is not correctly loaded. (" + F.time(UtilTime.MakeStr(COOLDOWN - (System.currentTimeMillis() - _lastFired)) + ")")));
|
||||
_rider.playSound(_rider.getLocation(), Sound.CLICK, 1.f, 1.f);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user