diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/achievementdiary/DiaryRequirementsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/achievementdiary/DiaryRequirementsPlugin.java index ff59ad8579..f36797ddc4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/achievementdiary/DiaryRequirementsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/achievementdiary/DiaryRequirementsPlugin.java @@ -33,7 +33,9 @@ import java.util.Map; import javax.inject.Inject; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; +import net.runelite.api.QuestState; import net.runelite.api.ScriptID; +import net.runelite.api.VarPlayer; import net.runelite.api.events.WidgetLoaded; import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.WidgetID; @@ -274,6 +276,20 @@ public class DiaryRequirementsPlugin extends Plugin { return client.getLocalPlayer().getCombatLevel() >= ((CombatLevelRequirement) r).getLevel(); } + if (r instanceof QuestRequirement) + { + QuestRequirement q = (QuestRequirement) r; + QuestState state = q.getQuest().getState(client); + if (q.isStarted()) + { + return state != QuestState.NOT_STARTED; + } + return state == QuestState.FINISHED; + } + if (r instanceof QuestPointRequirement) + { + return client.getVar(VarPlayer.QUEST_POINTS) >= ((QuestPointRequirement) r).getQp(); + } log.warn("Unknown requirement {}", r); return false; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/achievementdiary/QuestPointRequirement.java b/runelite-client/src/main/java/net/runelite/client/plugins/achievementdiary/QuestPointRequirement.java new file mode 100644 index 0000000000..c2b13e7c9b --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/achievementdiary/QuestPointRequirement.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2019 Abex + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.achievementdiary; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@Getter +public class QuestPointRequirement implements Requirement +{ + private final int qp; + + @Override + public String toString() + { + return qp + " " + "Quest points"; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/achievementdiary/QuestRequirement.java b/runelite-client/src/main/java/net/runelite/client/plugins/achievementdiary/QuestRequirement.java new file mode 100644 index 0000000000..cbc471651f --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/achievementdiary/QuestRequirement.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2019 Abex + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.achievementdiary; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import net.runelite.api.Quest; + +@Getter +@RequiredArgsConstructor +public class QuestRequirement implements Requirement +{ + private final Quest quest; + private final boolean started; + + public QuestRequirement(Quest quest) + { + this(quest, false); + } + + @Override + public String toString() + { + if (started) + { + return "Started " + quest.getName(); + } + + return quest.getName(); + } +}