Make sure post offices are saved and loaded properly.

Fixes #141
This commit is contained in:
James Mitchell committed 2014-09-02 19:15:33 -07:00
1 parent a1dad33c00
commit d05dbd7f94
2 files changed
+6 -9

No files matched your search

+4 -9
View File
@@ -47,6 +47,10 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
super(s);
}
public void setWorld(World world) {
refreshActiveTradeStations(world);
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
for (int i = 0; i < collectedPostage.length; i++) {
@@ -67,9 +71,6 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
@Override
public LinkedHashMap<MailAddress, ITradeStation> getActiveTradeStations(World world) {
if (activeTradeStations == null)
refreshActiveTradeStations(world);
return this.activeTradeStations;
}
@@ -101,18 +102,12 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
@Override
public void registerTradeStation(ITradeStation trade) {
if (activeTradeStations == null)
return;
if (!activeTradeStations.containsKey(trade.getAddress()))
activeTradeStations.put(trade.getAddress(), trade);
}
@Override
public void deregisterTradeStation(ITradeStation trade) {
if (activeTradeStations == null)
return;
activeTradeStations.remove(trade.getAddress());
}
@@ -151,6 +151,8 @@ public class PostRegistry implements IPostRegistry {
world.setItemData(PostOffice.SAVE_NAME, office);
}
office.setWorld(world);
cachedPostOffice = office;
return office;
}