From 11c78bf4553ad012708cb62db8c0a8a1d501b562 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 23 Dec 2015 00:38:39 +0100 Subject: [PATCH] Fixed a stupid NP that crashed the BTM server. *Hangs himself in shame now* --- .../actuallyadditions/booklet/EntrySet.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/EntrySet.java b/src/main/java/ellpeck/actuallyadditions/booklet/EntrySet.java index 508245c7d..ec6e91a9c 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/EntrySet.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/EntrySet.java @@ -38,17 +38,19 @@ public class EntrySet{ } public static EntrySet readFromNBT(NBTTagCompound compound){ - if(compound.hasKey("Entry")){ - int entry = compound.getInteger("Entry"); - int chapter = compound.getInteger("Chapter"); - int page = compound.getInteger("Page"); + if(compound != null){ + if(compound.hasKey("Entry")){ + int entry = compound.getInteger("Entry"); + int chapter = compound.getInteger("Chapter"); + int page = compound.getInteger("Page"); - BookletEntry currentEntry = entry == -1 ? null : InitBooklet.entries.get(entry); - BookletChapter currentChapter = chapter == -1 || entry == -1 || currentEntry.chapters.size() <= chapter ? null : currentEntry.chapters.get(chapter); - BookletPage currentPage = chapter == -1 || currentChapter == null || currentChapter.pages.length <= page-1 ? null : currentChapter.pages[page-1]; - int pageInIndex = compound.getInteger("PageInIndex"); + BookletEntry currentEntry = entry == -1 ? null : InitBooklet.entries.get(entry); + BookletChapter currentChapter = chapter == -1 || entry == -1 || currentEntry.chapters.size() <= chapter ? null : currentEntry.chapters.get(chapter); + BookletPage currentPage = chapter == -1 || currentChapter == null || currentChapter.pages.length <= page-1 ? null : currentChapter.pages[page-1]; + int pageInIndex = compound.getInteger("PageInIndex"); - return new EntrySet(currentPage, currentChapter, currentEntry, pageInIndex); + return new EntrySet(currentPage, currentChapter, currentEntry, pageInIndex); + } } return new EntrySet(null); }