Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
Added check for existing sign in SignFactory createSign
Browse files Browse the repository at this point in the history
  • Loading branch information
bziemons committed Dec 23, 2013
1 parent abe5f25 commit 4ebdbb8
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@

public class SignFactory {
public static final SignFactory instance = new SignFactory();

private SignFactory() {
}

@Getter
private int signCount = 0;

Expand Down Expand Up @@ -108,6 +108,13 @@ public String toString() {
}

public Sign createSign(Region region, Location location, boolean isWallSign, BlockFace direction) {
// Check for sign on location
Sign oldSign = SimpleRegionMarket.getInstance().getLocationSignHelper().getSign(location);
if (oldSign != null) {
throw new IllegalArgumentException("Location already has a sign");
}

// Create new sign
Sign sign = new Sign(region, location, isWallSign, direction);

region.getSignList().add(sign);
Expand Down Expand Up @@ -144,7 +151,7 @@ public Sign loadFromConfiguration(Configuration config, Region region, String pa
boolean isWallSign = config.getBoolean(path + "is_wall_sign");
BlockFace direction = BlockFace.valueOf(config.getString(path + "direction"));

return new Sign(region, location, isWallSign, direction);
return createSign(region, location, isWallSign, direction);
} else {
throw new ContentLoadException("Region string in sign config did not match the outer region");
}
Expand Down

0 comments on commit 4ebdbb8

Please sign in to comment.