-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
QuestsBridge.java
56 lines (50 loc) · 2.29 KB
/
QuestsBridge.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.denizenscript.depenizen.bukkit.bridges;
import com.denizenscript.denizencore.events.ScriptEvent;
import com.denizenscript.denizencore.objects.core.ListTag;
import com.denizenscript.denizencore.tags.Attribute;
import com.denizenscript.denizencore.tags.ReplaceableTagEvent;
import com.denizenscript.denizencore.tags.TagManager;
import com.denizenscript.denizencore.tags.TagRunnable;
import com.denizenscript.depenizen.bukkit.events.quests.PlayerCompletesQuestScriptEvent;
import com.denizenscript.depenizen.bukkit.events.quests.PlayerFailsQuestScriptEvent;
import com.denizenscript.depenizen.bukkit.events.quests.PlayerStartsQuestScriptEvent;
import com.denizenscript.depenizen.bukkit.properties.quests.QuestsPlayerProperties;
import com.denizenscript.depenizen.bukkit.Bridge;
import com.denizenscript.denizen.objects.PlayerTag;
import com.denizenscript.denizencore.objects.properties.PropertyParser;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quests;
public class QuestsBridge extends Bridge {
public static QuestsBridge instance;
@Override
public void init() {
instance = this;
PropertyParser.registerProperty(QuestsPlayerProperties.class, PlayerTag.class);
ScriptEvent.registerScriptEvent(new PlayerCompletesQuestScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerFailsQuestScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerStartsQuestScriptEvent());
TagManager.registerTagHandler(new TagRunnable.RootForm() {
@Override
public void run(ReplaceableTagEvent event) {
tagEvent(event);
}
}, "quests");
}
public void tagEvent(ReplaceableTagEvent event) {
Attribute attribute = event.getAttributes().fulfill(1);
// <--[tag]
// @attribute <quests.list_quests>
// @returns ListTag
// @plugin Depenizen, Quests
// @description
// Returns a list of all quest IDs from the Quests plugin.
// -->
if (attribute.startsWith("list_quests")) {
ListTag list = new ListTag();
for (Quest quest : ((Quests) plugin).getQuests()) {
list.add(quest.getId());
}
event.setReplacedObject(list.getObjectAttribute(attribute.fulfill(1)));
}
}
}