Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent quests from being entered when hidden and in view mode #69

Open
wants to merge 1 commit into
base: 1.12
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -75,7 +77,7 @@ public PanelButtonQuest(GuiRectangle rect, int id, String txt, DBEntry<IQuest> 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
Expand All @@ -100,7 +102,11 @@ private List<String> getQuestTooltip(IQuest quest, EntityPlayer player, int qID)
private List<String> getStandardTooltip(IQuest quest, EntityPlayer player, int qID) {
List<String> 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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,19 @@ public void setQuestLine(IQuestLine line) {

HashMap<Integer, PanelButtonQuest> questBtns = new HashMap<>();

for (DBEntry<IQuestLineEntry> qle : line.getEntries()) {
IQuest quest = QuestingAPI.getAPI(ApiReference.QUEST_DB).getValue(qle.getID());
for (DBEntry<IQuestLineEntry> 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<Integer, PanelButtonQuest> entry : questBtns.entrySet()) {
Expand Down