Sync with L2jServer HighFive Mar 25th 2015.
This commit is contained in:
@@ -23,9 +23,11 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
@@ -65,16 +67,13 @@ public class AutoSpawnHandler
|
||||
private static final int DEFAULT_RESPAWN = 3600000; // 1 hour in millisecs
|
||||
private static final int DEFAULT_DESPAWN = 3600000; // 1 hour in millisecs
|
||||
|
||||
protected Map<Integer, AutoSpawnInstance> _registeredSpawns;
|
||||
protected Map<Integer, ScheduledFuture<?>> _runningSpawns;
|
||||
protected Map<Integer, AutoSpawnInstance> _registeredSpawns = new ConcurrentHashMap<>();
|
||||
protected Map<Integer, ScheduledFuture<?>> _runningSpawns = new ConcurrentHashMap<>();
|
||||
|
||||
protected boolean _activeState = true;
|
||||
|
||||
protected AutoSpawnHandler()
|
||||
{
|
||||
_registeredSpawns = new HashMap<>();
|
||||
_runningSpawns = new HashMap<>();
|
||||
|
||||
restoreSpawnData();
|
||||
}
|
||||
|
||||
@@ -108,8 +107,8 @@ public class AutoSpawnHandler
|
||||
}
|
||||
|
||||
// create clean list
|
||||
_registeredSpawns = new HashMap<>();
|
||||
_runningSpawns = new HashMap<>();
|
||||
_registeredSpawns.clear();
|
||||
_runningSpawns.clear();
|
||||
|
||||
// load
|
||||
restoreSpawnData();
|
||||
@@ -367,19 +366,17 @@ public class AutoSpawnHandler
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map<Integer, AutoSpawnInstance> getAutoSpawnInstances(int npcId)
|
||||
public List<AutoSpawnInstance> getAutoSpawnInstances(int npcId)
|
||||
{
|
||||
Map<Integer, AutoSpawnInstance> spawnInstList = new HashMap<>();
|
||||
|
||||
final List<AutoSpawnInstance> result = new LinkedList<>();
|
||||
for (AutoSpawnInstance spawnInst : _registeredSpawns.values())
|
||||
{
|
||||
if (spawnInst.getId() == npcId)
|
||||
{
|
||||
spawnInstList.put(spawnInst.getObjectId(), spawnInst);
|
||||
result.add(spawnInst);
|
||||
}
|
||||
}
|
||||
|
||||
return spawnInstList;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -595,9 +592,9 @@ public class AutoSpawnHandler
|
||||
|
||||
protected int _lastLocIndex = -1;
|
||||
|
||||
private final List<L2Npc> _npcList = new ArrayList<>();
|
||||
private final List<L2Npc> _npcList = new CopyOnWriteArrayList<>();
|
||||
|
||||
private final List<Location> _locList = new ArrayList<>();
|
||||
private final List<Location> _locList = new CopyOnWriteArrayList<>();
|
||||
|
||||
private boolean _spawnActive;
|
||||
|
||||
@@ -680,16 +677,14 @@ public class AutoSpawnHandler
|
||||
return ret;
|
||||
}
|
||||
|
||||
public L2Spawn[] getSpawns()
|
||||
public List<L2Spawn> getSpawns()
|
||||
{
|
||||
List<L2Spawn> npcSpawns = new ArrayList<>();
|
||||
|
||||
final List<L2Spawn> npcSpawns = new ArrayList<>();
|
||||
for (L2Npc npcInst : _npcList)
|
||||
{
|
||||
npcSpawns.add(npcInst.getSpawn());
|
||||
}
|
||||
|
||||
return npcSpawns.toArray(new L2Spawn[npcSpawns.size()]);
|
||||
return npcSpawns;
|
||||
}
|
||||
|
||||
public void setSpawnCount(int spawnCount)
|
||||
|
||||
Reference in New Issue
Block a user