Fix NPE in sorting grid
This commit is contained in:
@@ -220,11 +220,13 @@ public class GuiGrid extends GuiBase {
|
|||||||
items.sort(new Comparator<StorageItem>() {
|
items.sort(new Comparator<StorageItem>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(StorageItem o1, StorageItem o2) {
|
public int compare(StorageItem o1, StorageItem o2) {
|
||||||
|
if (o1 != null && o2 != null) {
|
||||||
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
|
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
|
||||||
return o2.toItemStack().getDisplayName().compareTo(o1.toItemStack().getDisplayName());
|
return o2.toItemStack().getDisplayName().compareTo(o1.toItemStack().getDisplayName());
|
||||||
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
||||||
return o1.toItemStack().getDisplayName().compareTo(o2.toItemStack().getDisplayName());
|
return o1.toItemStack().getDisplayName().compareTo(o2.toItemStack().getDisplayName());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -234,11 +236,13 @@ public class GuiGrid extends GuiBase {
|
|||||||
items.sort(new Comparator<StorageItem>() {
|
items.sort(new Comparator<StorageItem>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(StorageItem o1, StorageItem o2) {
|
public int compare(StorageItem o1, StorageItem o2) {
|
||||||
|
if (o1 != null && o2 != null) {
|
||||||
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
|
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
|
||||||
return Integer.valueOf(o2.getQuantity()).compareTo(o1.getQuantity());
|
return Integer.valueOf(o2.getQuantity()).compareTo(o1.getQuantity());
|
||||||
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
||||||
return Integer.valueOf(o1.getQuantity()).compareTo(o2.getQuantity());
|
return Integer.valueOf(o1.getQuantity()).compareTo(o2.getQuantity());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user