Fixed fuse on detonator
This commit is contained in:
parent
b9762bddc4
commit
e638674444
@ -12,6 +12,7 @@ import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.games.lobbers.BombLobbers;
|
||||
import nautilus.game.arcade.game.games.lobbers.events.TNTPreExplodeEvent;
|
||||
import nautilus.game.arcade.game.games.lobbers.events.TNTThrowEvent;
|
||||
import nautilus.game.arcade.game.games.lobbers.kits.perks.PerkCraftman;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
@ -30,7 +31,7 @@ import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
public class KitDetonator extends Kit
|
||||
{
|
||||
private NautHashMap<TNTPrimed, Integer> _fuseTimes = new NautHashMap<TNTPrimed, Integer>();
|
||||
private NautHashMap<TNTPrimed, Long> _respawnTimes = new NautHashMap<TNTPrimed, Long>();
|
||||
|
||||
public KitDetonator(ArcadeManager manager)
|
||||
{
|
||||
@ -77,7 +78,11 @@ public class KitDetonator extends Kit
|
||||
}
|
||||
|
||||
event.getTNT().setFuseTicks(lever.getAmount() * 20);
|
||||
_fuseTimes.put(event.getTNT(), lever.getAmount() * 20);
|
||||
|
||||
if (lever.getAmount() > 3)
|
||||
{
|
||||
_respawnTimes.put(event.getTNT(), System.currentTimeMillis() + 3000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,39 +135,41 @@ public class KitDetonator extends Kit
|
||||
if (!Manager.GetGame().IsLive())
|
||||
return;
|
||||
|
||||
for (Entry<TNTPrimed, Integer> entry : _fuseTimes.entrySet())
|
||||
for (Entry<TNTPrimed, Long> entry : _respawnTimes.entrySet())
|
||||
{
|
||||
if (entry.getKey() == null || !entry.getKey().isValid())
|
||||
return;
|
||||
|
||||
//If it will need respawning
|
||||
if (entry.getValue() > 60)
|
||||
if (System.currentTimeMillis() >= entry.getValue())
|
||||
{
|
||||
//If it's near 60 ticks
|
||||
//2 tick leeway
|
||||
if (entry.getKey().getFuseTicks() >= 60 && entry.getKey().getFuseTicks() <= 62)
|
||||
{
|
||||
Player player = l.getThrower(entry.getKey());
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
TNTPrimed newTNT = entry.getKey().getWorld().spawn(entry.getKey().getLocation(), TNTPrimed.class);
|
||||
newTNT.setMetadata("owner", new FixedMetadataValue(Manager.getPlugin(), player.getUniqueId()));
|
||||
newTNT.setVelocity(entry.getKey().getVelocity());
|
||||
newTNT.setFuseTicks(59);
|
||||
Player player = l.getThrower(entry.getKey());
|
||||
|
||||
Manager.GetProjectile().AddThrow(newTNT, player, l, -1L, true, false, true, .2F);
|
||||
|
||||
entry.getKey().remove();
|
||||
l.removeThrower(entry.getKey());
|
||||
_fuseTimes.remove(entry.getKey());
|
||||
if (player == null)
|
||||
continue;
|
||||
|
||||
l.addThrower(player, newTNT);
|
||||
}
|
||||
TNTPrimed newTNT = entry.getKey().getWorld().spawn(entry.getKey().getLocation(), TNTPrimed.class);
|
||||
newTNT.setMetadata("owner", new FixedMetadataValue(Manager.getPlugin(), player.getUniqueId()));
|
||||
newTNT.setVelocity(entry.getKey().getVelocity());
|
||||
newTNT.setFuseTicks(60);
|
||||
|
||||
Manager.GetProjectile().AddThrow(newTNT, player, l, -1L, true, false, true, .2F);
|
||||
|
||||
entry.getKey().remove();
|
||||
l.removeThrower(entry.getKey());
|
||||
_respawnTimes.remove(entry.getKey());
|
||||
|
||||
l.addThrower(player, newTNT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onExplode(TNTPreExplodeEvent event)
|
||||
{
|
||||
if (_respawnTimes.containsKey(event.getTNT()))
|
||||
{
|
||||
_respawnTimes.remove(event.getTNT());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user