-Misc clean up/refactor.
-Removed unnecessary Map.containsKey calls
-Using java 8 methods where possible to avoid external checks.
Source L2J HighFive branch:
9d0fee8537
This commit is contained in:
@@ -154,15 +154,9 @@ public final class AntiFeedManager
|
||||
}
|
||||
|
||||
final Integer addrHash = Integer.valueOf(client.getConnectionAddress().hashCode());
|
||||
int limit = max;
|
||||
if (Config.L2JMOD_DUALBOX_CHECK_WHITELIST.containsKey(addrHash))
|
||||
{
|
||||
limit += Config.L2JMOD_DUALBOX_CHECK_WHITELIST.get(addrHash);
|
||||
}
|
||||
|
||||
final AtomicInteger connectionCount = event.computeIfAbsent(addrHash, k -> new AtomicInteger());
|
||||
|
||||
return connectionCount.getAndIncrement() < limit;
|
||||
return connectionCount.getAndIncrement() < (max + Config.L2JMOD_DUALBOX_CHECK_WHITELIST.getOrDefault(addrHash, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -95,22 +95,8 @@ public class RaidBossPointsManager
|
||||
|
||||
public final void addPoints(L2PcInstance player, int bossId, int points)
|
||||
{
|
||||
int ownerId = player.getObjectId();
|
||||
Map<Integer, Integer> tmpPoint = _list.get(ownerId);
|
||||
if (tmpPoint == null)
|
||||
{
|
||||
tmpPoint = new HashMap<>();
|
||||
tmpPoint.put(bossId, points);
|
||||
updatePointsInDB(player, bossId, points);
|
||||
}
|
||||
else
|
||||
{
|
||||
int currentPoins = tmpPoint.containsKey(bossId) ? tmpPoint.get(bossId) : 0;
|
||||
currentPoins += points;
|
||||
tmpPoint.put(bossId, currentPoins);
|
||||
updatePointsInDB(player, bossId, currentPoins);
|
||||
}
|
||||
_list.put(ownerId, tmpPoint);
|
||||
final Map<Integer, Integer> tmpPoint = _list.computeIfAbsent(player.getObjectId(), k -> new HashMap<>());
|
||||
updatePointsInDB(player, bossId, tmpPoint.merge(bossId, points, Integer::sum));
|
||||
}
|
||||
|
||||
public final int getPointsByOwnerId(int ownerId)
|
||||
|
||||
@@ -176,13 +176,12 @@ public class RaidBossSpawnManager
|
||||
*/
|
||||
public void updateStatus(L2RaidBossInstance boss, boolean isBossDead)
|
||||
{
|
||||
if (!_storedInfo.containsKey(boss.getId()))
|
||||
final StatsSet info = _storedInfo.get(boss.getId());
|
||||
if (info == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final StatsSet info = _storedInfo.get(boss.getId());
|
||||
|
||||
if (isBossDead)
|
||||
{
|
||||
boss.setRaidStatus(StatusEnum.DEAD);
|
||||
|
||||
@@ -334,9 +334,9 @@ public final class WalkingManager implements IXmlReader
|
||||
*/
|
||||
public synchronized void cancelMoving(L2Npc npc)
|
||||
{
|
||||
if (_activeRoutes.containsKey(npc.getObjectId()))
|
||||
final WalkInfo walk = _activeRoutes.remove(npc.getObjectId());
|
||||
if (walk != null)
|
||||
{
|
||||
final WalkInfo walk = _activeRoutes.remove(npc.getObjectId());
|
||||
walk.getWalkCheckTask().cancel(true);
|
||||
npc.getKnownList().stopTrackingTask();
|
||||
}
|
||||
@@ -348,15 +348,13 @@ public final class WalkingManager implements IXmlReader
|
||||
*/
|
||||
public void resumeMoving(final L2Npc npc)
|
||||
{
|
||||
if (!_activeRoutes.containsKey(npc.getObjectId()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final WalkInfo walk = _activeRoutes.get(npc.getObjectId());
|
||||
walk.setSuspended(false);
|
||||
walk.setStoppedByAttack(false);
|
||||
startMoving(npc, walk.getRoute().getName());
|
||||
if (walk != null)
|
||||
{
|
||||
walk.setSuspended(false);
|
||||
walk.setStoppedByAttack(false);
|
||||
startMoving(npc, walk.getRoute().getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user