SpawnTable update to Java 8
Source L2J HighFive branch:5cbbd96a0d
1da891ae95
This commit is contained in:
@@ -86,9 +86,9 @@ public class Lindvior extends AbstractNpcAI
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "start":
|
case "start":
|
||||||
_lindviorCamera = SpawnTable.getInstance().getFirstSpawn(LINDVIOR_CAMERA).getLastSpawn();
|
_lindviorCamera = SpawnTable.getInstance().getAnySpawn(LINDVIOR_CAMERA).getLastSpawn();
|
||||||
_tomaris = SpawnTable.getInstance().getFirstSpawn(TOMARIS).getLastSpawn();
|
_tomaris = SpawnTable.getInstance().getAnySpawn(TOMARIS).getLastSpawn();
|
||||||
_artius = SpawnTable.getInstance().getFirstSpawn(ARTIUS).getLastSpawn();
|
_artius = SpawnTable.getInstance().getAnySpawn(ARTIUS).getLastSpawn();
|
||||||
|
|
||||||
startQuestTimer("tomaris_shout1", 1000, _tomaris, null);
|
startQuestTimer("tomaris_shout1", 1000, _tomaris, null);
|
||||||
startQuestTimer("artius_shout", 60000, _artius, null);
|
startQuestTimer("artius_shout", 60000, _artius, null);
|
||||||
|
@@ -282,6 +282,6 @@ public final class Q00625_TheFinestIngredientsPart2 extends Quest
|
|||||||
|
|
||||||
private static boolean isBumbalumpSpawned()
|
private static boolean isBumbalumpSpawned()
|
||||||
{
|
{
|
||||||
return SpawnTable.getInstance().getFirstSpawn(ICICLE_EMPEROR_BUMBALUMP) != null;
|
return SpawnTable.getInstance().getAnySpawn(ICICLE_EMPEROR_BUMBALUMP) != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,7 +27,6 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.CopyOnWriteArraySet;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@@ -355,39 +354,43 @@ public final class SpawnTable implements IXmlReader
|
|||||||
return addSpawn(spawnInfo, null);
|
return addSpawn(spawnInfo, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the spawn data.
|
||||||
|
* @return the spawn data
|
||||||
|
*/
|
||||||
public Map<Integer, Set<L2Spawn>> getSpawnTable()
|
public Map<Integer, Set<L2Spawn>> getSpawnTable()
|
||||||
{
|
{
|
||||||
return _spawnTable;
|
return _spawnTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the spawns for the NPC Id.
|
* Gets the spawns for the NPC Id.
|
||||||
* @param npcId the NPC Id
|
* @param npcId the NPC Id
|
||||||
* @return the spawn set for the given npcId
|
* @return the spawn set for the given npcId
|
||||||
*/
|
*/
|
||||||
public Set<L2Spawn> getSpawns(int npcId)
|
public Set<L2Spawn> getSpawns(int npcId)
|
||||||
{
|
{
|
||||||
return _spawnTable.containsKey(npcId) ? _spawnTable.get(npcId) : Collections.<L2Spawn> emptySet();
|
return _spawnTable.getOrDefault(npcId, Collections.emptySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the first NPC spawn.
|
* Gets the spawn count for the given NPC ID.
|
||||||
* @param npcId the NPC Id to search
|
* @param npcId the NPC Id
|
||||||
* @return the first not null spawn, if any
|
* @return the spawn count
|
||||||
*/
|
*/
|
||||||
public L2Spawn getFirstSpawn(int npcId)
|
public int getSpawnCount(int npcId)
|
||||||
{
|
{
|
||||||
if (_spawnTable.containsKey(npcId))
|
return getSpawns(npcId).size();
|
||||||
{
|
}
|
||||||
for (L2Spawn spawn : _spawnTable.get(npcId))
|
|
||||||
{
|
/**
|
||||||
if (spawn != null)
|
* Gets a spawn for the given NPC ID.
|
||||||
{
|
* @param npcId the NPC Id
|
||||||
return spawn;
|
* @return a spawn for the given NPC ID or {@code null}
|
||||||
}
|
*/
|
||||||
}
|
public L2Spawn getAnySpawn(int npcId)
|
||||||
}
|
{
|
||||||
return null;
|
return getSpawns(npcId).stream().findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -460,11 +463,7 @@ public final class SpawnTable implements IXmlReader
|
|||||||
*/
|
*/
|
||||||
private void addSpawn(L2Spawn spawn)
|
private void addSpawn(L2Spawn spawn)
|
||||||
{
|
{
|
||||||
if (!_spawnTable.containsKey(spawn.getId()))
|
_spawnTable.computeIfAbsent(spawn.getId(), k -> ConcurrentHashMap.newKeySet(1)).add(spawn);
|
||||||
{
|
|
||||||
_spawnTable.put(spawn.getId(), new CopyOnWriteArraySet<L2Spawn>());
|
|
||||||
}
|
|
||||||
_spawnTable.get(spawn.getId()).add(spawn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -474,9 +473,9 @@ public final class SpawnTable implements IXmlReader
|
|||||||
*/
|
*/
|
||||||
private boolean removeSpawn(L2Spawn spawn)
|
private boolean removeSpawn(L2Spawn spawn)
|
||||||
{
|
{
|
||||||
if (_spawnTable.containsKey(spawn.getId()))
|
final Set<L2Spawn> set = _spawnTable.get(spawn.getId());
|
||||||
|
if (set != null)
|
||||||
{
|
{
|
||||||
final Set<L2Spawn> set = _spawnTable.get(spawn.getId());
|
|
||||||
boolean removed = set.remove(spawn);
|
boolean removed = set.remove(spawn);
|
||||||
if (set.isEmpty())
|
if (set.isEmpty())
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user