Fix Deathbomber achievement tracker

This commit is contained in:
Sam 2017-06-30 00:27:12 +01:00
parent 5a7c7b8fa3
commit a8e1799617

View File

@ -1,12 +1,15 @@
package nautilus.game.arcade.stats;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.game.Game;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.Map;
@ -51,11 +54,6 @@ public class DeathBomberStatTracker extends StatTracker<Game>
if(killer.equals(killed))
return;
if (killer.getItemInHand().getType() != Material.TNT)
{
return;
}
if (event.GetLog().GetKiller() != null && event.GetLog().GetKiller().GetReason().contains("Throwing TNT"))
{
Integer count = _killCount.get(killer.getUniqueId());
@ -70,4 +68,32 @@ public class DeathBomberStatTracker extends StatTracker<Game>
addStat(killer, "DeathBomber", 1, true, false);
}
}
@EventHandler
public void removeFakeThrowingTNT(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
{
return;
}
for (Player player : getGame().GetPlayers(true))
{
ItemStack[] contents = player.getInventory().getContents();
int i = 0;
for (ItemStack itemStack : contents)
{
if (itemStack == null || itemStack.getItemMeta() == null || itemStack.getItemMeta().getDisplayName() == null)
{
continue;
}
if (itemStack.getItemMeta().getDisplayName().contains("Throwing TNT") && itemStack.getType() != Material.TNT)
{
player.getInventory().setItem(i, null);
}
}
}
}
}