From 8491b4e299df849b158508ec18e7be229dfe298a Mon Sep 17 00:00:00 2001 From: alongstringofnumbers Date: Sat, 17 Sep 2022 22:44:19 -0700 Subject: [PATCH] Prevent quests from being entered when hidden and in view mode --- .../api2/client/gui/controls/PanelButtonQuest.java | 10 ++++++++-- .../client/gui/panels/lists/CanvasQuestLine.java | 14 ++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/betterquesting/api2/client/gui/controls/PanelButtonQuest.java b/src/main/java/betterquesting/api2/client/gui/controls/PanelButtonQuest.java index 2ab6f5ec1..c88a3ab8c 100644 --- a/src/main/java/betterquesting/api2/client/gui/controls/PanelButtonQuest.java +++ b/src/main/java/betterquesting/api2/client/gui/controls/PanelButtonQuest.java @@ -3,6 +3,7 @@ import betterquesting.api.api.ApiReference; import betterquesting.api.api.QuestingAPI; import betterquesting.api.enums.EnumQuestState; +import betterquesting.api.enums.EnumQuestVisibility; import betterquesting.api.properties.NativeProps; import betterquesting.api.questing.IQuest; import betterquesting.api.questing.tasks.ITask; @@ -25,6 +26,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.text.TextFormatting; +import java.beans.Visibility; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Collections; @@ -75,7 +77,7 @@ public PanelButtonQuest(GuiRectangle rect, int id, String txt, DBEntry v 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); - setActive(QuestingAPI.getAPI(ApiReference.SETTINGS).canUserEdit(player) || !lock || BQ_Settings.viewMode); + setActive(QuestingAPI.getAPI(ApiReference.SETTINGS).canUserEdit(player) || !lock || (BQ_Settings.viewMode && !(value.getValue().getProperty(NativeProps.VISIBILITY) == EnumQuestVisibility.HIDDEN))); } @Override @@ -100,7 +102,11 @@ private List getQuestTooltip(IQuest quest, EntityPlayer player, int qID) private List getStandardTooltip(IQuest quest, EntityPlayer player, int qID) { List list = new ArrayList<>(); - list.add(QuestTranslation.translate(quest.getProperty(NativeProps.NAME)) + (!Minecraft.getMinecraft().gameSettings.advancedItemTooltips ? "" : (" #" + qID))); + String questName = QuestTranslation.translate(quest.getProperty(NativeProps.NAME)); + if(quest.getProperty(NativeProps.VISIBILITY) == EnumQuestVisibility.HIDDEN && !quest.isUnlocked(QuestingAPI.getQuestingUUID(player))) { + questName = TextFormatting.OBFUSCATED + questName; + } + list.add(questName + (Minecraft.getMinecraft().gameSettings.advancedItemTooltips ? (" #" + qID) : "")); UUID playerID = QuestingAPI.getQuestingUUID(player); diff --git a/src/main/java/betterquesting/api2/client/gui/panels/lists/CanvasQuestLine.java b/src/main/java/betterquesting/api2/client/gui/panels/lists/CanvasQuestLine.java index 410d23a24..e86f1f8e9 100644 --- a/src/main/java/betterquesting/api2/client/gui/panels/lists/CanvasQuestLine.java +++ b/src/main/java/betterquesting/api2/client/gui/panels/lists/CanvasQuestLine.java @@ -96,17 +96,19 @@ public void setQuestLine(IQuestLine line) { HashMap questBtns = new HashMap<>(); - for (DBEntry qle : line.getEntries()) { - IQuest quest = QuestingAPI.getAPI(ApiReference.QUEST_DB).getValue(qle.getID()); + for (DBEntry questLineEntry : line.getEntries()) { + IQuest quest = QuestingAPI.getAPI(ApiReference.QUEST_DB).getValue(questLineEntry.getID()); - if (!QuestCache.isQuestShown(quest, pid, player)) continue; + if (!QuestCache.isQuestShown(quest, pid, player)) { + continue; + } - GuiRectangle rect = new GuiRectangle(qle.getValue().getPosX(), qle.getValue().getPosY(), qle.getValue().getSizeX(), qle.getValue().getSizeY()); - PanelButtonQuest paBtn = new PanelButtonQuest(rect, buttonId, "", new DBEntry<>(qle.getID(), quest)); + GuiRectangle questRect = new GuiRectangle(questLineEntry.getValue().getPosX(), questLineEntry.getValue().getPosY(), questLineEntry.getValue().getSizeX(), questLineEntry.getValue().getSizeY()); + PanelButtonQuest paBtn = new PanelButtonQuest(questRect, buttonId, "", new DBEntry<>(questLineEntry.getID(), quest)); this.addPanel(paBtn); this.btnList.add(paBtn); - questBtns.put(qle.getID(), paBtn); + questBtns.put(questLineEntry.getID(), paBtn); } for (Entry entry : questBtns.entrySet()) {