Fixed a couple more achievement bugs

Track damage mods in combat log
This commit is contained in:
CoderTim 2014-10-27 19:00:34 -04:00
parent f0ba562265
commit cd5e4234b7
5 changed files with 49 additions and 9 deletions

View File

@ -2,10 +2,12 @@ package mineplex.minecraft.game.core.combat;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.minecraft.game.core.damage.DamageChange;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -32,12 +34,12 @@ public class CombatComponent
}
}
public void AddDamage(String source, double dmg)
public void AddDamage(String source, double dmg, List<DamageChange> mod)
{
if (source == null)
source = "-";
GetDamage().addFirst(new CombatDamage(source, dmg));
GetDamage().addFirst(new CombatDamage(source, dmg, mod));
LastDamage = System.currentTimeMillis();
}

View File

@ -1,16 +1,23 @@
package mineplex.minecraft.game.core.combat;
import java.util.ArrayList;
import java.util.List;
import mineplex.minecraft.game.core.damage.DamageChange;
public class CombatDamage
{
private String _name;
private double _dmg;
private long _time;
private List<DamageChange> _mod = new ArrayList<>();
public CombatDamage(String name, double dmg)
public CombatDamage(String name, double dmg, List<DamageChange> mod)
{
_name = name;
_dmg = dmg;
_time = System.currentTimeMillis();
_mod = mod;
}
public String GetName()
@ -27,4 +34,9 @@ public class CombatDamage
{
return _time;
}
public List<DamageChange> getDamageMod()
{
return _mod;
}
}

View File

@ -3,9 +3,11 @@ package mineplex.minecraft.game.core.combat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilTime;
import mineplex.minecraft.game.core.damage.DamageChange;
import org.bukkit.ChatColor;
import org.bukkit.entity.LivingEntity;
@ -45,12 +47,12 @@ public class CombatLog
}
public void Attacked(String damagerName, double damage,
LivingEntity damagerEnt, String attackName)
LivingEntity damagerEnt, String attackName, List<DamageChange> mod)
{
// Add Attacked
CombatComponent comp = GetEnemy(damagerName, damagerEnt);
comp.AddDamage(attackName, damage);
comp.AddDamage(attackName, damage, mod);
// Set Last
LastDamager = comp;

View File

@ -84,7 +84,7 @@ public class CombatManager extends MiniPlugin
Get(damagee).Attacked(
UtilEnt.getName(damagerEnt),
event.getDamage(), damagerEnt,
event.getCause() + "");
event.getCause() + "", null);
}
// Damager is WORLD
else
@ -181,7 +181,7 @@ public class CombatManager extends MiniPlugin
}
Get(damagee).Attacked(source,
event.getDamage(), null, reason);
event.getDamage(), null, reason, null);
}
}
@ -231,7 +231,7 @@ public class CombatManager extends MiniPlugin
Get(event.GetDamageePlayer()).Attacked(
UtilEnt.getName(event.GetDamagerEntity(true)),
(int) event.GetDamage(), event.GetDamagerEntity(true),
reason);
reason, event.GetDamageMod());
}
// Damager is WORLD
else
@ -331,7 +331,7 @@ public class CombatManager extends MiniPlugin
reason = event.GetReason();
Get(event.GetDamageePlayer()).Attacked(source,
(int) event.GetDamage(), null, reason);
(int) event.GetDamage(), null, reason, event.GetDamageMod());
}
}

View File

@ -5,7 +5,10 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import mineplex.core.common.util.UtilPlayer;
import mineplex.minecraft.game.core.combat.CombatComponent;
import mineplex.minecraft.game.core.combat.CombatDamage;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.damage.DamageChange;
import nautilus.game.arcade.game.Game;
public class KillReasonStatTracker extends StatTracker<Game>
@ -49,6 +52,27 @@ public class KillReasonStatTracker extends StatTracker<Game>
if (event.GetLog().GetLastDamager() != null && event.GetLog().GetLastDamager().GetReason() != null && event.GetLog().GetLastDamager().GetReason().contains(getReason()))
addStat(killer, getStatName(), 1, false, false);
else
{
for (CombatComponent component : event.GetLog().GetAttackers())
{
for (CombatDamage damage : component.GetDamage())
{
if (damage.getDamageMod() != null)
{
for (DamageChange mod : damage.getDamageMod())
{
if (mod.GetReason() != null && mod.GetReason().contains(getReason()))
{
addStat(killer, getStatName(), 1, false, false);
return;
}
}
}
}
}
}
}
public String getStatName()