-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
ASkyBlockBridge.java
84 lines (76 loc) · 3.82 KB
/
ASkyBlockBridge.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package com.denizenscript.depenizen.bukkit.bridges;
import com.denizenscript.depenizen.bukkit.events.askyblock.PlayerExitsSkyBlockScriptEvent;
import com.denizenscript.depenizen.bukkit.events.askyblock.PlayerCompletesSkyBlockChallengeScriptEvent;
import com.denizenscript.depenizen.bukkit.events.askyblock.PlayerEntersSkyBlockScriptEvent;
import com.denizenscript.depenizen.bukkit.events.askyblock.SkyBlockCreatedScriptEvent;
import com.denizenscript.depenizen.bukkit.events.askyblock.SkyBlockResetScriptEvent;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
import com.denizenscript.denizen.objects.dLocation;
import com.denizenscript.denizen.objects.dPlayer;
import com.denizenscript.denizen.objects.dWorld;
import com.denizenscript.denizencore.events.ScriptEvent;
import com.denizenscript.denizencore.objects.TagRunnable;
import com.denizenscript.denizencore.objects.properties.PropertyParser;
import com.denizenscript.denizencore.tags.ReplaceableTagEvent;
import com.denizenscript.denizencore.objects.Element;
import com.denizenscript.denizencore.tags.Attribute;
import com.denizenscript.depenizen.bukkit.properties.askyblock.ASkyBlockLocationProperties;
import com.denizenscript.depenizen.bukkit.properties.askyblock.ASkyBlockPlayerProperties;
import com.denizenscript.depenizen.bukkit.properties.askyblock.ASkyBlockWorldProperties;
import com.denizenscript.depenizen.bukkit.Bridge;
import com.denizenscript.denizencore.tags.TagManager;
public class ASkyBlockBridge extends Bridge {
@Override
public void init() {
api = ASkyBlockAPI.getInstance();
PropertyParser.registerProperty(ASkyBlockPlayerProperties.class, dPlayer.class);
PropertyParser.registerProperty(ASkyBlockLocationProperties.class, dLocation.class);
PropertyParser.registerProperty(ASkyBlockWorldProperties.class, dWorld.class);
ScriptEvent.registerScriptEvent(new SkyBlockCreatedScriptEvent());
ScriptEvent.registerScriptEvent(new SkyBlockResetScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerEntersSkyBlockScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerExitsSkyBlockScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerCompletesSkyBlockChallengeScriptEvent());
TagManager.registerTagHandler(new TagRunnable.RootForm() {
@Override
public void run(ReplaceableTagEvent event) {
tagEvent(event);
}
}, "skyblock");
// TODO: Skyblock Command
}
public ASkyBlockAPI api;
public void tagEvent(ReplaceableTagEvent event) {
Attribute attribute = event.getAttributes().fulfill(1);
// <--[tag]
// @attribute <skyblock.island_world>
// @returns dWorld
// @description
// Returns the world that A Skyblock uses for islands.
// @Plugin Depenizen, A SkyBlock
// -->
if (attribute.startsWith("island_world")) {
event.setReplacedObject(new dWorld(api.getIslandWorld()).getObjectAttribute(attribute.fulfill(1)));
}
// <--[tag]
// @attribute <skyblock.nether_world>
// @returns dWorld
// @description
// Returns the world that A Skyblock uses for the nether.
// @Plugin Depenizen, A SkyBlock
// -->
else if (attribute.startsWith("nether_world")) {
event.setReplacedObject(new dWorld(api.getNetherWorld()).getObjectAttribute(attribute.fulfill(1)));
}
// <--[tag]
// @attribute <skyblock.island_count>
// @returns Element(Number)
// @description
// Returns the number of Skyblock Islands that exist.
// @Plugin Depenizen, A SkyBlock
// -->
else if (attribute.startsWith("island_count")) {
event.setReplacedObject(new Element(api.getIslandCount()).getObjectAttribute(attribute.fulfill(1)));
}
}
}