PC-203
Fixes the issue of "auto-bowing" in OITQ
This commit is contained in:
parent
55317730fa
commit
6db4c3acc7
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -30,6 +31,7 @@ import nautilus.game.arcade.stats.SharpShooterStatTracker;
|
||||
import nautilus.game.arcade.stats.WinWithoutBowStatTracker;
|
||||
import nautilus.game.arcade.stats.WinWithoutDyingStatTracker;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -48,6 +50,7 @@ public class Quiver extends SoloGame
|
||||
private HashMap<Player, Integer> _combo = new HashMap<Player, Integer>();
|
||||
private HashMap<Player, Integer> _bestCombo = new HashMap<Player, Integer>();
|
||||
private HashMap<Player, Long> _deathTime = new HashMap<Player, Long>();
|
||||
private HashMap<UUID, Integer> _bowTime = new HashMap<>();
|
||||
|
||||
private Objective _scoreObj;
|
||||
|
||||
@ -114,12 +117,33 @@ public class Quiver extends SoloGame
|
||||
{
|
||||
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item("Super Arrow")));
|
||||
player.playSound(player.getLocation(), Sound.PISTON_EXTEND, 3f, 2f);
|
||||
_bowTime.put(player.getUniqueId(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if(event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
for(Player player : GetPlayers(true))
|
||||
{
|
||||
if(UtilPlayer.isChargingBow(player))
|
||||
{
|
||||
_bowTime.put(player.getUniqueId(), _bowTime.get(player.getUniqueId()) + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_bowTime.put(player.getUniqueId(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void BowShoot(EntityShootBowEvent event)
|
||||
{
|
||||
Bukkit.broadcastMessage(event.getEventName());
|
||||
if (!(event.getProjectile() instanceof Arrow))
|
||||
return;
|
||||
|
||||
@ -131,6 +155,14 @@ public class Quiver extends SoloGame
|
||||
if (!(arrow.getShooter() instanceof Player))
|
||||
return;
|
||||
|
||||
Player shooter = (Player) arrow.getShooter();
|
||||
//If the player has a full charge but they haven't been holding the bow for more than 20 ticks
|
||||
if(_bowTime.get(shooter.getUniqueId()) < 20 && event.getForce() == 1)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_deathTime.containsKey(arrow.getShooter()))
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user