mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-22 05:02:11 +00:00
Add some try catch guards around sorting and filtering exceptions
This commit is contained in:
1 parent
983fafea7c
commit
edb6225c43
2 files changed
+16
-7
No files matched your search
@@ -71,16 +71,21 @@ public class ItemList
|
||||
public void itemsLoaded();
|
||||
}
|
||||
|
||||
public static boolean itemMatches(ItemStack item, List<ItemFilter> filters) {
|
||||
for(ItemFilter filter : filters)
|
||||
if(!filter.matches(item))
|
||||
return false;
|
||||
public static boolean itemMatchesAll(ItemStack item, List<ItemFilter> filters) {
|
||||
for(ItemFilter filter : filters) {
|
||||
try {
|
||||
if (!filter.matches(item))
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.error("Exception filtering "+item+" with "+filter, e);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean itemMatches(ItemStack item) {
|
||||
return itemMatches(item, getItemFilters());
|
||||
return itemMatchesAll(item, getItemFilters());
|
||||
}
|
||||
|
||||
public static List<ItemFilter> getItemFilters() {
|
||||
@@ -170,7 +175,7 @@ public class ItemList
|
||||
for(ItemStack item : items) {
|
||||
if (interrupted()) return;
|
||||
|
||||
if(itemMatches(item, filters))
|
||||
if(itemMatchesAll(item, filters))
|
||||
filtered.add(item);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,11 @@ public class ItemSorter implements Comparator<ItemStack>, ItemsLoadedCallback
|
||||
public HashMap<ItemStack, Integer> ordering = null;
|
||||
|
||||
public static void sort(ArrayList<ItemStack> items) {
|
||||
Collections.sort(items, instance);
|
||||
try {
|
||||
Collections.sort(items, instance);
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.error("Exception sorting item list", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user