diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverPayload.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverPayload.java index efff82b84..e642cb1d3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverPayload.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverPayload.java @@ -5,6 +5,7 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Minecart; @@ -19,6 +20,7 @@ import org.bukkit.material.MaterialData; import org.bukkit.util.Vector; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTextBottom; import mineplex.core.hologram.Hologram; @@ -50,6 +52,8 @@ public class QuiverPayload extends TeamGame private Hologram _hologram; private GameTeam _teamDirection; private Vector _lastDirection; + private boolean _postiveVector; + private boolean _oldVector; private Map _ultimatePercentage = new HashMap(); @@ -104,11 +108,12 @@ public class QuiverPayload extends TeamGame { Location location = WorldData.GetDataLocs("BLACK").get(0); _minecart = location.getWorld().spawn(location, Minecart.class); - _hologram = new Hologram(Manager.getHologramManager(), location, "None"); + _hologram = new Hologram(Manager.getHologramManager(), location.add(0, 1, 0), "None"); _minecart.setDisplayBlock(new MaterialData(Material.TNT)); _hologram.setFollowEntity(_minecart); - + _hologram.start(); + for (Player player : GetPlayers(true)) { player.getInventory().addItem(Quiver.SUPER_ARROW); @@ -172,7 +177,7 @@ public class QuiverPayload extends TeamGame } } - if (event.getType() == UpdateType.FAST || _minecart != null) + if (event.getType() == UpdateType.FAST && _minecart != null) { Map mostPlayers = new HashMap<>(); @@ -186,6 +191,8 @@ public class QuiverPayload extends TeamGame { GameTeam gameTeam = GetTeam(player); + Bukkit.broadcastMessage(gameTeam.GetFormattedName() + " " + player.getName()); + mostPlayers.put(gameTeam, mostPlayers.get(gameTeam) + 1); } @@ -197,6 +204,26 @@ public class QuiverPayload extends TeamGame if (playerCount > mostPlayersCount) { + if (_teamDirection == null) + { + if (GetTeamList().get(0).equals(gameTeam)) + { + _postiveVector = true; + } + else + { + _postiveVector = false; + } + } + else if (_teamDirection.equals(gameTeam)) + { + _postiveVector = true; + } + else + { + _postiveVector = false; + } + _teamDirection = gameTeam; } else if (playerCount == mostPlayersCount) @@ -209,33 +236,55 @@ public class QuiverPayload extends TeamGame if (_teamDirection == null) { - return; - } - - if (_teamDirection.equals(GetTeamList().get(0))) - { - if (_lastDirection == null) + if (mostPlayersCount == 0) { - _minecart.setVelocity(new Vector(-0.1, 0, 0)); + _hologram.setText("None"); } else { - _minecart.setVelocity(_minecart.getVelocity().normalize().multiply(0.1)); + _hologram.setText("Contested"); } - _lastDirection = _minecart.getVelocity(); + + _minecart.setVelocity(new Vector(0, 0, 0)); + return; } - else + + if (_lastDirection == null) { - if (_lastDirection == null) + if (_postiveVector) { _minecart.setVelocity(new Vector(0.1, 0, 0)); } else { - _minecart.setVelocity(_minecart.getVelocity().normalize().multiply(0.1)); + _minecart.setVelocity(new Vector(-0.1, 0, 0)); } - _lastDirection = _minecart.getVelocity(); } + else + { + if (_oldVector == _postiveVector) + { + _minecart.setVelocity(_lastDirection); + } + else + { + _minecart.setVelocity(_lastDirection.multiply(-1)); + } + + _oldVector = _postiveVector; + } + + if (UtilBlock.solid(_minecart.getVelocity().add(_minecart.getVelocity().normalize()).toLocation(_minecart.getWorld()).getBlock())) + { + _minecart.setVelocity(_minecart.getVelocity().normalize().multiply(5)); + } + else + { + _minecart.setVelocity(_minecart.getVelocity().normalize().multiply(0.1)); + } + + _lastDirection = _minecart.getVelocity(); + _hologram.setText(_teamDirection.GetFormattedName()); } } @@ -271,7 +320,7 @@ public class QuiverPayload extends TeamGame public void onCombatDeath(CombatDeathEvent event) { Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); - + if (player == null) { return;