Fix #518 Trade station crashes when new station is named after a restart

This commit is contained in:
mezz committed 2015-02-21 00:02:31 -08:00
1 parent 9536bf1b78
commit b9b71cf015
2 files changed
+11 -5

No files matched your search

@@ -82,7 +82,7 @@ public class PostRegistry implements IPostRegistry {
*/
@Override
public boolean isValidTradeAddress(World world, IMailAddress address) {
return address.isTrader() && address.getName().matches("^[a-zA-Z0-9]+$");
return address != null && address.isTrader() && address.getName().matches("^[a-zA-Z0-9]+$");
}
/**
@@ -92,12 +92,12 @@ public class PostRegistry implements IPostRegistry {
*/
@Override
public boolean isAvailableTradeAddress(World world, IMailAddress address) {
return getTradeStation(world, address) == null;
return address != null && getTradeStation(world, address) == null;
}
@Override
public TradeStation getTradeStation(World world, IMailAddress address) {
if (address.getName() == null) {
if (address == null || address.getName() == null) {
return null;
}
@@ -25,6 +25,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional;
import forestry.api.core.ForestryAPI;
import forestry.api.core.IErrorState;
import forestry.api.mail.IMailAddress;
import forestry.api.mail.IStamps;
import forestry.api.mail.PostManager;
@@ -173,7 +174,12 @@ public class MachineTrader extends TileBase {
/* STATE INFORMATION */
public boolean isLinked() {
return address.isValid() && getErrorState() != EnumErrorCode.NOTALPHANUMERIC && getErrorState() != EnumErrorCode.NOTUNIQUE;
if (address == null || !address.isValid()) {
return false;
}
IErrorState errorState = getErrorState();
return errorState != EnumErrorCode.NOTALPHANUMERIC && errorState != EnumErrorCode.NOTUNIQUE;
}
/**
@@ -274,7 +280,7 @@ public class MachineTrader extends TileBase {
throw new NullPointerException("address must not be null");
}
if (this.address.isValid() && this.address.equals(address)) {
if (this.address != null && this.address.isValid() && this.address.equals(address)) {
return;
}