Book titles can be null, fixes #2108

This commit is contained in:
PikaMug 2023-05-20 21:55:20 -04:00
parent 5b63533e7b
commit 8d4b39c9d7

View File

@ -34,6 +34,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
@SuppressWarnings("deprecation")
public class ItemUtil {
@ -132,10 +133,13 @@ public class ItemUtil {
if (one.getType().equals(Material.WRITTEN_BOOK)) {
final BookMeta bMeta1 = (BookMeta) one.getItemMeta();
final BookMeta bMeta2 = (BookMeta) two.getItemMeta();
if (!bMeta1.getTitle().equals(bMeta2.getTitle())) {
if (!bMeta1.getAuthor().equals(bMeta2.getAuthor())) {
if (!bMeta1.getPages().equals(bMeta2.getPages())) {
return -8;
if (bMeta1 != null && bMeta2 != null) {
// Title and author can be null
if (Objects.equals(bMeta1.getTitle(), bMeta2.getTitle())) {
if (Objects.equals(bMeta1.getAuthor(), bMeta2.getAuthor())) {
if (!bMeta1.getPages().equals(bMeta2.getPages())) {
return -8;
}
}
}
}