-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/main/java/com/github/manolo8/darkbot/config/actions/conditions/HasQuestCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.github.manolo8.darkbot.config.actions.conditions; | ||
|
||
import com.github.manolo8.darkbot.Main; | ||
import com.github.manolo8.darkbot.config.actions.Condition; | ||
import com.github.manolo8.darkbot.config.actions.Parser; | ||
import com.github.manolo8.darkbot.config.actions.SyntaxException; | ||
import com.github.manolo8.darkbot.config.actions.ValueData; | ||
import com.github.manolo8.darkbot.config.actions.parser.ParseUtil; | ||
|
||
import eu.darkbot.api.managers.QuestAPI; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
@ValueData(name = "has-quest", description = "True if it has quests", example = "hasQuest()") | ||
public class HasQuestCondition implements Condition, Parser { | ||
private QuestAPI questApi; | ||
|
||
@Override | ||
public @NotNull Result get(Main main) { | ||
if (questApi == null) { | ||
this.questApi = main.pluginAPI.getAPI(QuestAPI.class); | ||
} | ||
|
||
return Result.fromBoolean(this.questApi.getDisplayedQuest() != null); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "hasQuest()"; | ||
} | ||
|
||
@Override | ||
public String parse(String str) throws SyntaxException { | ||
String[] params = str.split("\\)", 2); | ||
return ParseUtil.separate(params, getClass(), ")"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters