Avoid a crash when reading malformed .mt files
color component values greater than 255 would cause the app to crashmaster
parent
e7c328b0ae
commit
44ea73d3e7
|
@ -1,6 +1,7 @@
|
|||
package amidst.gameengineabstraction.world.biome;
|
||||
|
||||
import amidst.documentation.GsonConstructor;
|
||||
import amidst.logging.AmidstLogger;
|
||||
import amidst.mojangapi.world.biome.BiomeColor;
|
||||
import amidst.settings.biomeprofile.BiomeColorJson;
|
||||
|
||||
|
@ -50,8 +51,14 @@ public abstract class BiomeBase implements IBiome {
|
|||
|
||||
public BiomeColor getDefaultColor() {
|
||||
if (defaultColor == null) {
|
||||
// Must have been deserialized rather than constructed
|
||||
defaultColor = BiomeColor.fromBiomeColorJson(color);
|
||||
try {
|
||||
// Must have been deserialized rather than constructed
|
||||
defaultColor = BiomeColor.fromBiomeColorJson(color);
|
||||
} catch(IllegalArgumentException ex) {
|
||||
// badly formatted data file
|
||||
AmidstLogger.error("Biome \"" + name + "\" has invalid colour");
|
||||
defaultColor = BiomeColor.error();
|
||||
}
|
||||
}
|
||||
return defaultColor;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,12 @@ public class BiomeColor {
|
|||
return UNKNOWN_BIOME_COLOR;
|
||||
}
|
||||
|
||||
public static BiomeColor error() {
|
||||
return ERROR_BIOME_COLOR;
|
||||
}
|
||||
|
||||
private static final BiomeColor UNKNOWN_BIOME_COLOR = new BiomeColor(0, 0, 0);
|
||||
private static final BiomeColor ERROR_BIOME_COLOR = new BiomeColor(255, 0, 255);
|
||||
|
||||
private static final int DESELECT_NUMBER = 30;
|
||||
private static final int LIGHTEN_BRIGHTNESS = 40;
|
||||
|
|
Loading…
Reference in New Issue