Minor DoorTable improvements.

This commit is contained in:
MobiusDevelopment 2019-08-23 21:13:20 +00:00
parent d885d11741
commit 27548ed230
2 changed files with 14 additions and 26 deletions

View File

@ -366,7 +366,7 @@ public class GameServer
BoatManager.getInstance(); BoatManager.getInstance();
Util.printSection("Doors"); Util.printSection("Doors");
DoorTable.getInstance().parseData(); DoorTable.getInstance().load();
FenceData.getInstance(); FenceData.getInstance();
Util.printSection("Four Sepulchers"); Util.printSection("Four Sepulchers");

View File

@ -22,6 +22,7 @@ import java.io.FileNotFoundException;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.io.LineNumberReader; import java.io.LineNumberReader;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.StringTokenizer; import java.util.StringTokenizer;
@ -40,7 +41,7 @@ public class DoorTable
{ {
private static Logger LOGGER = Logger.getLogger(DoorTable.class.getName()); private static Logger LOGGER = Logger.getLogger(DoorTable.class.getName());
private Map<Integer, DoorInstance> _staticItems; private final Map<Integer, DoorInstance> _doors = new HashMap<>();
private static DoorTable _instance; private static DoorTable _instance;
@ -56,23 +57,11 @@ public class DoorTable
public DoorTable() public DoorTable()
{ {
_staticItems = new HashMap<>(); _doors.clear();
// parseData(); // load();
} }
public void reloadAll() public void load()
{
respawn();
}
public void respawn()
{
// DoorInstance[] currentDoors = getDoors();
_staticItems = null;
_instance = new DoorTable();
}
public void parseData()
{ {
FileReader reader = null; FileReader reader = null;
BufferedReader buff = null; BufferedReader buff = null;
@ -97,7 +86,7 @@ public class DoorTable
} }
final DoorInstance door = parseList(line); final DoorInstance door = parseList(line);
_staticItems.put(door.getDoorId(), door); _doors.put(door.getDoorId(), door);
door.spawnMe(door.getX(), door.getY(), door.getZ()); door.spawnMe(door.getX(), door.getY(), door.getZ());
final ClanHall clanhall = ClanHallManager.getInstance().getNearbyClanHall(door.getX(), door.getY(), 500); final ClanHall clanhall = ClanHallManager.getInstance().getNearbyClanHall(door.getX(), door.getY(), 500);
if (clanhall != null) if (clanhall != null)
@ -107,7 +96,7 @@ public class DoorTable
} }
} }
LOGGER.info("DoorTable: Loaded " + _staticItems.size() + " Door Templates."); LOGGER.info("DoorTable: Loaded " + _doors.size() + " Door Templates.");
} }
catch (FileNotFoundException e) catch (FileNotFoundException e)
{ {
@ -289,18 +278,17 @@ public class DoorTable
public DoorInstance getDoor(Integer id) public DoorInstance getDoor(Integer id)
{ {
return _staticItems.get(id); return _doors.get(id);
} }
public void putDoor(DoorInstance door) public void putDoor(DoorInstance door)
{ {
_staticItems.put(door.getDoorId(), door); _doors.put(door.getDoorId(), door);
} }
public DoorInstance[] getDoors() public Collection<DoorInstance> getDoors()
{ {
final DoorInstance[] _allTemplates = _staticItems.values().toArray(new DoorInstance[_staticItems.size()]); return _doors.values();
return _allTemplates;
} }
/** /**
@ -308,7 +296,7 @@ public class DoorTable
*/ */
public void checkAutoOpen() public void checkAutoOpen()
{ {
for (DoorInstance doorInst : getDoors()) for (DoorInstance doorInst : _doors.values())
{ {
// Garden of Eva (every 7 minutes) // Garden of Eva (every 7 minutes)
if (doorInst.getDoorName().startsWith("goe")) if (doorInst.getDoorName().startsWith("goe"))
@ -345,7 +333,7 @@ public class DoorTable
return false; return false;
} }
for (DoorInstance doorInst : getDoors()) for (DoorInstance doorInst : _doors.values())
{ {
if (doorInst.getMapRegion() != region) if (doorInst.getMapRegion() != region)
{ {