Search in sources :

Example 1 with EnumQuestVisibility

use of betterquesting.api.enums.EnumQuestVisibility in project BetterQuesting by Funwayguy.

the class CanvasQuestLine method isQuestShown.

public static boolean isQuestShown(IQuest quest, UUID uuid) {
    if (quest == null || uuid == null) {
        return false;
    }
    Minecraft mc = Minecraft.getMinecraft();
    EnumQuestVisibility vis = quest.getProperties().getProperty(NativeProps.VISIBILITY);
    if (QuestingAPI.getAPI(ApiReference.SETTINGS).canUserEdit(mc.player) || vis == EnumQuestVisibility.ALWAYS) {
        return true;
    } else if (vis == EnumQuestVisibility.HIDDEN) {
        return false;
    } else if (vis == EnumQuestVisibility.UNLOCKED) {
        return quest.isComplete(uuid) || quest.isUnlocked(uuid);
    } else if (vis == EnumQuestVisibility.NORMAL) {
        if (quest.isComplete(uuid) || quest.isUnlocked(uuid)) {
            return true;
        }
        for (IQuest q : quest.getPrerequisites()) {
            if (!q.isUnlocked(uuid)) {
                return false;
            }
        }
        return true;
    } else if (vis == EnumQuestVisibility.COMPLETED) {
        return quest.isComplete(uuid);
    } else if (vis == EnumQuestVisibility.CHAIN) {
        if (quest.getPrerequisites().size() <= 0) {
            return true;
        }
        for (IQuest q : quest.getPrerequisites()) {
            if (isQuestShown(q, uuid)) {
                return true;
            }
        }
        return false;
    }
    return true;
}
Also used : IQuest(betterquesting.api.questing.IQuest) EnumQuestVisibility(betterquesting.api.enums.EnumQuestVisibility) Minecraft(net.minecraft.client.Minecraft)

Example 2 with EnumQuestVisibility

use of betterquesting.api.enums.EnumQuestVisibility in project BetterQuesting by Funwayguy.

the class GuiQuestEditor method actionPerformed.

@Override
public void actionPerformed(GuiButton button) {
    super.actionPerformed(button);
    if (// Rewards
    button.id == 1) {
        mc.displayGuiScreen(new GuiRewardEditor(this, quest));
    } else if (// Tasks
    button.id == 2) {
        mc.displayGuiScreen(new GuiTaskEditor(this, quest));
    } else if (// Prerequisites
    button.id == 3) {
        mc.displayGuiScreen(new GuiPrerequisiteEditor(this, quest));
    } else if (// Raw JSON
    button.id == 4) {
        this.lastEdit = new NBTTagCompound();
        quest.writeToNBT(lastEdit, EnumSaveType.CONFIG);
        JsonDocEvent event = new JsonDocEvent(new JsonDocBasic(null, "jdoc.betterquesting.quest"));
        MinecraftForge.EVENT_BUS.post(event);
        mc.displayGuiScreen(new GuiJsonEditor(this, lastEdit, event.getJdocResult()));
    } else if (button.id == 5) {
        boolean main = !quest.getProperties().getProperty(NativeProps.MAIN);
        quest.getProperties().setProperty(NativeProps.MAIN, main);
        button.displayString = I18n.format("betterquesting.btn.is_main") + ": " + main;
        SendChanges();
    } else if (button.id == 6) {
        EnumLogic[] logicList = EnumLogic.values();
        EnumLogic logic = quest.getProperties().getProperty(NativeProps.LOGIC_QUEST);
        logic = logicList[(logic.ordinal() + 1) % logicList.length];
        quest.getProperties().setProperty(NativeProps.LOGIC_QUEST, logic);
        button.displayString = I18n.format("betterquesting.btn.logic") + ": " + logic;
        SendChanges();
    } else if (button.id == 7) {
        EnumQuestVisibility[] visList = EnumQuestVisibility.values();
        EnumQuestVisibility vis = quest.getProperties().getProperty(NativeProps.VISIBILITY);
        vis = visList[(vis.ordinal() + 1) % visList.length];
        quest.getProperties().setProperty(NativeProps.VISIBILITY, vis);
        button.displayString = I18n.format("betterquesting.btn.show") + ": " + vis;
        SendChanges();
    }
}
Also used : EnumLogic(betterquesting.api.enums.EnumLogic) GuiTaskEditor(betterquesting.client.gui.editors.tasks.GuiTaskEditor) JsonDocEvent(betterquesting.api.events.JsonDocEvent) JsonDocBasic(betterquesting.api.jdoc.JsonDocBasic) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EnumQuestVisibility(betterquesting.api.enums.EnumQuestVisibility) GuiRewardEditor(betterquesting.client.gui.editors.rewards.GuiRewardEditor) GuiJsonEditor(betterquesting.client.gui.editors.json.scrolling.GuiJsonEditor)

Aggregations

EnumQuestVisibility (betterquesting.api.enums.EnumQuestVisibility)2 EnumLogic (betterquesting.api.enums.EnumLogic)1 JsonDocEvent (betterquesting.api.events.JsonDocEvent)1 JsonDocBasic (betterquesting.api.jdoc.JsonDocBasic)1 IQuest (betterquesting.api.questing.IQuest)1 GuiJsonEditor (betterquesting.client.gui.editors.json.scrolling.GuiJsonEditor)1 GuiRewardEditor (betterquesting.client.gui.editors.rewards.GuiRewardEditor)1 GuiTaskEditor (betterquesting.client.gui.editors.tasks.GuiTaskEditor)1 Minecraft (net.minecraft.client.Minecraft)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1