Merge pull request #143 in MIN/mineplex from bugfix/achievements-misc to develop

* commit '7d33e76055eb160e58d63443a72117e654df9468':
  Fixed ForTheKing achievement.
  Made sure Sniper achievement in Bridges is always fulfilled.
  Fixed + Tidied Gladiators Precision achievement.
This commit is contained in:
Shaun Bennett 2016-01-29 02:32:50 -06:00
commit a0e9a82327
3 changed files with 62 additions and 34 deletions

View File

@ -212,7 +212,6 @@ public class CastleSiege extends TeamGame
}
registerStatTrackers(
new WinAsTeamStatTracker(this, notRedTeam, "ForTheKing"),
new KingSlayerStatTracker(this),
new BloodThirstyStatTracker(this),
new KingDamageStatTracker(this),
@ -273,6 +272,30 @@ public class CastleSiege extends TeamGame
}
}
@EventHandler(priority = EventPriority.HIGH)
public void registerTeamTracker(GameStateChangeEvent event)
{
if (event.GetState() == GameState.Recruit)
{
GameTeam notRed = null;
for (GameTeam team : GetTeamList())
{
if (team.GetColor() == ChatColor.RED)
continue;
notRed = team;
break;
}
if (notRed != null)
{
registerStatTrackers(new WinAsTeamStatTracker(this, notRed, "ForTheKing"));
System.out.println("Successfully registered For the King StatTrak");
}
}
}
@EventHandler
public void MoveKits(GameStateChangeEvent event)
{

View File

@ -1,16 +1,18 @@
package nautilus.game.arcade.game.games.gladiators.trackers;
import java.util.HashMap;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import java.util.List;
import java.util.UUID;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.gladiators.Gladiators;
import nautilus.game.arcade.stats.StatTracker;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
/**
* Created by William (WilliamTiger).
@ -18,15 +20,13 @@ import nautilus.game.arcade.stats.StatTracker;
*/
public class PrecisionTracker extends StatTracker<Gladiators>
{
private HashMap<String, Integer> _shot;
private HashMap<String, Integer> _hit;
private NautHashMap<Projectile, UUID> _current = new NautHashMap<Projectile, UUID>();
private NautHashMap<UUID, Integer> _shot = new NautHashMap<UUID, Integer>();
private NautHashMap<UUID, Integer> _hit = new NautHashMap<UUID, Integer>();
public PrecisionTracker(Gladiators game)
{
super(game);
_shot = new HashMap<>();
_hit = new HashMap<>();
}
@EventHandler
@ -35,15 +35,15 @@ public class PrecisionTracker extends StatTracker<Gladiators>
if (e.GetState() != Game.GameState.End)
return;
for (Player p : getGame().getWinners())
List<Player> winners = getGame().getWinners();
if (winners == null)
return;
for (Player p : winners)
{
if (_shot.containsKey(p.getName()) && _hit.containsKey(p.getName()))
if (getShot(p) == getHit(p) && getShot(p) >= 3)
{
if (_shot.get(p.getName()) == _hit.get(p.getName()))
{
if (_shot.get(p.getName()) >= 3)
addStat(p, "Precision", 1, true, false);
}
addStat(p, "Precision", 1, true, false);
}
}
}
@ -56,24 +56,30 @@ public class PrecisionTracker extends StatTracker<Gladiators>
Player p = (Player) e.getEntity();
if (_shot.containsKey(p.getName()))
_shot.put(p.getName(), _shot.get(p.getName()) + 1);
else
_shot.put(p.getName(), 1);
_shot.put(p.getUniqueId(), getShot(p) + 1);
_current.put((Projectile) e.getProjectile(), p.getUniqueId());
}
@EventHandler
public void hit(ProjectileHitEvent e)
{
if (e.getEntity().getShooter() instanceof Player)
{
Player p = (Player) e.getEntity().getShooter();
if (!_current.containsKey(e.getEntity()))
return;
if (_hit.containsKey(p.getName()))
_hit.put(p.getName(), _hit.get(p.getName()) + 1);
else
_hit.put(p.getName(), 1);
}
Player player = UtilPlayer.searchExact(_current.remove(e.getEntity()));
if (player == null)
return;
_hit.put(player.getUniqueId(), getHit(player) + 1);
}
private int getShot(Player player)
{
return _shot.containsKey(player.getUniqueId()) ? _shot.get(player.getUniqueId()) : 0;
}
private int getHit(Player player)
{
return _hit.containsKey(player.getUniqueId()) ? _hit.get(player.getUniqueId()) : 0;
}
}

View File

@ -3,7 +3,6 @@ package nautilus.game.arcade.stats;
import mineplex.core.common.util.UtilPlayer;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.game.games.bridge.Bridge;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -49,7 +48,7 @@ public class BridgesSniperStatTracker extends StatTracker<Bridge>
if (player == killer)
return;
if (event.GetLog().GetLastDamager().GetLastDamageSource().contains("Archery"))
if (event.GetLog().GetKiller().GetBestWeapon().contains("Archery"))
{
addStat(killer, "Sniper", 1, true, false);
}