aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authorVixid <52578495+VixidDev@users.noreply.github.com>2023-01-31 08:26:45 +0000
committerGitHub <noreply@github.com>2023-01-31 19:26:45 +1100
commit81ab56786aeb360e23f2f864c64101cc026c8277 (patch)
tree416b0af2add4af85883dab1435de16dc3d03cdde /src/main/java/io
parent3a24bfb4e8b3026b8f59a4465faadde8f800f075 (diff)
downloadNotEnoughUpdates-81ab56786aeb360e23f2f864c64101cc026c8277.tar.gz
NotEnoughUpdates-81ab56786aeb360e23f2f864c64101cc026c8277.tar.bz2
NotEnoughUpdates-81ab56786aeb360e23f2f864c64101cc026c8277.zip
Equipment overlay pet item crash fix (#572)
Co-authored-by: Vixid <52578495+vixid1@users.noreply.github.com> Fixes https://github.com/NotEnoughUpdates/NotEnoughUpdates/issues/471
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java
index bc44f656..f8f42b80 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java
@@ -287,16 +287,20 @@ public class ItemUtils {
if (secondLastBlankLine != -1) {
List<String> petItemLore = new ArrayList<>();
if (heldItem != null) {
- petItemLore.add(EnumChatFormatting.GOLD + "Held Item: " + heldItemJson.get("displayname").getAsString());
- List<String> heldItemLore = JsonUtils.getJsonArrayOrEmpty(heldItemJson, "lore", JsonElement::getAsString);
- int blanks = 0;
- for (String heldItemLoreLine : heldItemLore) {
- if (heldItemLoreLine.trim().isEmpty()) {
- blanks++;
- } else if (blanks == 2) {
- petItemLore.add(heldItemLoreLine);
- } else if (blanks > 2) {
- break;
+ if (heldItemJson == null) {
+ petItemLore.add(EnumChatFormatting.RED + "Could not find held item in repo!");
+ } else {
+ petItemLore.add(EnumChatFormatting.GOLD + "Held Item: " + heldItemJson.get("displayname").getAsString());
+ List<String> heldItemLore = JsonUtils.getJsonArrayOrEmpty(heldItemJson, "lore", JsonElement::getAsString);
+ int blanks = 0;
+ for (String heldItemLoreLine : heldItemLore) {
+ if (heldItemLoreLine.trim().isEmpty()) {
+ blanks++;
+ } else if (blanks == 2) {
+ petItemLore.add(heldItemLoreLine);
+ } else if (blanks > 2) {
+ break;
+ }
}
}
}