Fix crash when there's no sectors on planet (#5202)

`sectors.size - 1` is `-1` when there's no sectors on planet.
relevant crash log:
```
[E] java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 16
	at arc.struct.Seq.get(Seq.java:451)
	at mindustry.type.Planet.getLastSector(Planet.java:114)
	at mindustry.ui.dialogs.PlanetDialog.show(PlanetDialog.java:185)
        ...
        at mindustry.desktop.DesktopLauncher.main(DesktopLauncher.java:36)
```
This commit is contained in:
Antsiferov Andrew 2021-05-05 21:51:35 +03:00 committed by GitHub
parent 622f735953
commit c53e14dd31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,6 +111,9 @@ public class Planet extends UnlockableContent{
}
public @Nullable Sector getLastSector(){
if(sectors.isEmpty()){
return null;
}
return sectors.get(Math.min(Core.settings.getInt(name + "-last-sector", startSector), sectors.size - 1));
}