Skip to content

Commit

Permalink
deal with null differently
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyfts committed May 30, 2024
1 parent 7a3e1a3 commit 22b140b
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import betterquesting.api.questing.IQuest;
import betterquesting.api.questing.tasks.ITask;
import betterquesting.api.storage.BQ_Settings;
import betterquesting.api.utils.BigItemStack;
import betterquesting.api2.client.gui.misc.GuiRectangle;
import betterquesting.api2.client.gui.misc.IGuiRect;
import betterquesting.api2.client.gui.resources.colors.IGuiColor;
Expand All @@ -21,11 +20,12 @@
import betterquesting.api2.utils.QuestTranslation;
import betterquesting.client.BookmarkHandler;
import betterquesting.questing.QuestDatabase;
import betterquesting.questing.QuestInstance;
import betterquesting.storage.QuestSettings;
import com.google.common.collect.Maps;
import com.mojang.realmsclient.gui.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.nbt.NBTTagCompound;

import javax.annotation.Nullable;
Expand All @@ -49,11 +49,16 @@ public PanelButtonQuest(GuiRectangle rect, int id, String txt, @Nullable Map.Ent
{
super(rect, id, txt, value);
this.rect = rect;

player = Minecraft.getMinecraft().thePlayer;
EnumQuestState qState = value == null ? EnumQuestState.LOCKED : value.getValue().getState(player);

if(value == null) {
IQuest dummyQuest = new QuestInstance();
value = Maps.immutableEntry(UUID.randomUUID(), dummyQuest);
}

EnumQuestState qState = value.getValue().getState(player);
IGuiColor txIconCol = null;
boolean main = value != null && value.getValue().getProperty(NativeProps.MAIN);
boolean main = value.getValue().getProperty(NativeProps.MAIN);
boolean lock = false;

switch(qState)
Expand Down Expand Up @@ -85,10 +90,9 @@ public PanelButtonQuest(GuiRectangle rect, int id, String txt, @Nullable Map.Ent

IGuiTexture btnTx = new GuiTextureColored(txFrame, txIconCol);
setTextures(btnTx, btnTx, btnTx);
setIcon(new OreDictTexture(1F, value == null ? new BigItemStack(Items.nether_star) : value.getValue().getProperty(NativeProps.ICON), false, true), 4);
setIcon(new OreDictTexture(1F, value.getValue().getProperty(NativeProps.ICON), false, true), 4);
setActive(QuestingAPI.getAPI(ApiReference.SETTINGS).canUserEdit(player) || !lock || BQ_Settings.viewMode);
boolean bookmarked = value != null && BookmarkHandler.isBookmarked(value.getKey());
setBookmarked(bookmarked);
setBookmarked(BookmarkHandler.isBookmarked(value.getKey()));
}

@Override
Expand Down

0 comments on commit 22b140b

Please sign in to comment.