-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
McMMOBridge.java
57 lines (52 loc) · 2.89 KB
/
McMMOBridge.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
package com.denizenscript.depenizen.bukkit.bridges;
import com.denizenscript.depenizen.bukkit.commands.mcmmo.McMMOCommand;
import com.denizenscript.depenizen.bukkit.events.mcmmo.*;
import com.denizenscript.depenizen.bukkit.properties.mcmmo.McMMOEntityProperties;
import com.denizenscript.depenizen.bukkit.properties.mcmmo.McMMOPlayerProperties;
import com.denizenscript.depenizen.bukkit.objects.mcmmo.dParty;
import com.denizenscript.depenizen.bukkit.Bridge;
import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizen.objects.PlayerTag;
import com.denizenscript.denizen.utilities.DenizenAPI;
import com.denizenscript.denizen.utilities.debugging.Debug;
import com.denizenscript.denizencore.events.ScriptEvent;
import com.denizenscript.denizencore.objects.ObjectFetcher;
import com.denizenscript.denizencore.objects.TagRunnable;
import com.denizenscript.denizencore.objects.properties.PropertyParser;
import com.denizenscript.denizencore.tags.Attribute;
import com.denizenscript.denizencore.tags.ReplaceableTagEvent;
import com.denizenscript.denizencore.tags.TagManager;
public class McMMOBridge extends Bridge {
@Override
public void init() {
ObjectFetcher.registerWithObjectFetcher(dParty.class);
TagManager.registerTagHandler(new TagRunnable.RootForm() {
@Override
public void run(ReplaceableTagEvent event) {
tagEvent(event);
}
}, "party");
PropertyParser.registerProperty(McMMOPlayerProperties.class, PlayerTag.class);
PropertyParser.registerProperty(McMMOEntityProperties.class, EntityTag.class);
DenizenAPI.getCurrentInstance().getCommandRegistry().registerCoreMember(McMMOCommand.class,
"MCMMO", "mcmmo [add/remove/set] [levels/xp/xprate/vampirism/hardcore/leader] (skill:<skill>) (state:{toggle}/true/false) (qty:<#>) (party:<party>)", 1);
ScriptEvent.registerScriptEvent(new mcMMOPlayerLevelChangeScriptEvent());
ScriptEvent.registerScriptEvent(new mcMMOPlayerLevelUpScriptEvent());
ScriptEvent.registerScriptEvent(new mcMMOPlayerLevelDownScriptEvent());
ScriptEvent.registerScriptEvent(new mcMMOPlayerGainsXPScriptEvent());
ScriptEvent.registerScriptEvent(new mcMMOPlayerAbilityActivateScriptEvent());
ScriptEvent.registerScriptEvent(new mcMMOPlayerAbilityDeactivateScriptEvent());
}
public void tagEvent(ReplaceableTagEvent event) {
Attribute attribute = event.getAttributes();
if (attribute.startsWith("party") && attribute.hasContext(1)) {
dParty party = dParty.valueOf(attribute.getContext(1));
if (party != null) {
event.setReplacedObject(party.getObjectAttribute(attribute.fulfill(1)));
}
else if (!event.hasAlternative()) {
Debug.echoError("Unknown party '" + attribute.getContext(1) + "' for party[] tag.");
}
}
}
}