Make Milk Spiral only hit twice

This commit is contained in:
Sam 2018-02-28 20:55:44 +00:00 committed by Alexander Meech
parent 03ac44fb85
commit 53fc397536
2 changed files with 12 additions and 1 deletions

View File

@ -1,5 +1,8 @@
package nautilus.game.arcade.game.games.smash.perks.cow; package nautilus.game.arcade.game.games.smash.perks.cow;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -28,6 +31,8 @@ public class DataCowMilkSpiral
public Location SpiralA = null; public Location SpiralA = null;
public Location SpiralB = null; public Location SpiralB = null;
public final Map<Player, Integer> HitPlayers;
public DataCowMilkSpiral(Player player, boolean superActive) public DataCowMilkSpiral(Player player, boolean superActive)
{ {
Time = System.currentTimeMillis(); Time = System.currentTimeMillis();
@ -39,6 +44,8 @@ public class DataCowMilkSpiral
Direction = player.getLocation().getDirection(); Direction = player.getLocation().getDirection();
Spiral = player.getLocation().add(new Vector(0,1,0)).add(player.getLocation().getDirection().multiply(2)); Spiral = player.getLocation().add(new Vector(0,1,0)).add(player.getLocation().getDirection().multiply(2));
HitPlayers = new HashMap<>();
} }
public boolean update() public boolean update()

View File

@ -110,6 +110,7 @@ public class PerkCowMilkSpiral extends SmashPerk
if (data.update()) if (data.update())
{ {
data.HitPlayers.clear();
activeIter.remove(); activeIter.remove();
} }
@ -120,8 +121,11 @@ public class PerkCowMilkSpiral extends SmashPerk
continue; continue;
} }
if (UtilMath.offset(player.getLocation().add(0, 1.5, 0), data.Spiral) < _hitBoxRadius) int timesHit = data.HitPlayers.getOrDefault(player, 0);
if (UtilMath.offset(player.getLocation().add(0, 1.5, 0), data.Spiral) < _hitBoxRadius && timesHit < 2)
{ {
data.HitPlayers.put(player, ++timesHit);
Manager.GetDamage().NewDamageEvent(player, data.Player, null, DamageCause.CUSTOM, _damage, true, true, false, player.getName(), GetName()); Manager.GetDamage().NewDamageEvent(player, data.Player, null, DamageCause.CUSTOM, _damage, true, true, false, player.getName(), GetName());
UtilParticle.PlayParticleToAll(isSuperActive(player) ? ParticleType.RED_DUST : ParticleType.FIREWORKS_SPARK, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0.3f, 30, ViewDist.LONG); UtilParticle.PlayParticleToAll(isSuperActive(player) ? ParticleType.RED_DUST : ParticleType.FIREWORKS_SPARK, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0.3f, 30, ViewDist.LONG);