Prevent probable general contract violation.

This commit is contained in:
MobiusDev
2018-07-29 11:32:38 +00:00
parent 466510e098
commit b6843b2ec3
7 changed files with 147 additions and 21 deletions

View File

@ -20,7 +20,6 @@ import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@ -836,12 +835,31 @@ public class L2Attackable extends L2Npc
*/
public L2Character getMostHated()
{
if (getAggroList().isEmpty() || isAlikeDead())
if (_aggroList.isEmpty() || isAlikeDead())
{
return null;
}
return getAggroList().values().stream().filter(Objects::nonNull).sorted(Comparator.comparingInt(AggroInfo::getHate).reversed()).map(AggroInfo::getAttacker).findFirst().orElse(null);
L2Character mostHated = null;
int maxHate = 0;
// While Interacting over This Map Removing Object is Not Allowed
// Go through the aggroList of the L2Attackable
for (AggroInfo ai : _aggroList.values())
{
if (ai == null)
{
continue;
}
if (ai.checkHate(this) > maxHate)
{
mostHated = ai.getAttacker();
maxHate = ai.getHate();
}
}
return mostHated;
}
/**