-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
LibsDisguise.java
156 lines (127 loc) · 3.94 KB
/
LibsDisguise.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
package com.denizenscript.depenizen.bukkit.objects.libsdisguises;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import net.aufdemrand.denizen.objects.dEntity;
import net.aufdemrand.denizencore.objects.Element;
import net.aufdemrand.denizencore.objects.Fetchable;
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.tags.Attribute;
import net.aufdemrand.denizencore.tags.TagContext;
import net.aufdemrand.denizencore.utilities.CoreUtilities;
import java.util.List;
public class LibsDisguise implements dObject {
/////////////////////
// OBJECT FETCHER
/////////////////
public static LibsDisguise valueOf(String string) {
return valueOf(string, null);
}
@Fetchable("libsdisguise")
public static LibsDisguise valueOf(String string, TagContext context) {
if (string == null) {
return null;
}
////////
// Match disguise name
string = string.replace("libsdisguise@", "");
try {
List<String> split = CoreUtilities.split(string, ',');
return new LibsDisguise(DisguiseAPI.getCustomDisguise(split.get(0)));
}
catch (Throwable e) {
}
return null;
}
public static boolean matches(String arg) {
return arg.startsWith("disguise@");
}
/////////////////////
// STATIC CONSTRUCTORS
/////////////////
Disguise disguise = null;
public LibsDisguise(Disguise pl) {
disguise = pl;
}
/////////////////////
// dObject Methods
/////////////////
private String prefix = "LibsDisguise";
@Override
public String getPrefix() {
return prefix;
}
@Override
public LibsDisguise setPrefix(String prefix) {
this.prefix = prefix;
return this;
}
@Override
public int hashCode() {
return disguise.hashCode();
}
@Override
public boolean equals(Object a) {
if (a instanceof LibsDisguise) {
return ((LibsDisguise) a).disguise.equals(disguise);
}
return false;
}
@Override
public String debug() {
return (prefix + "='<A>" + identify() + "<G>' ");
}
@Override
public boolean isUnique() {
return true;
}
@Override
public String getObjectType() {
return "LibsDisguise";
}
@Override
public String identify() {
return "libsdisguise@" + disguise.toString();
}
@Override
public String identifySimple() {
return identify();
}
@Override
public String toString() {
return identify();
}
@Override
public String getAttribute(Attribute attribute) {
// <--[tag]
// @attribute <libsdisguise@libsdisguise.type>
// @returns Element
// @description
// Returns the type of the disguise.
// @Plugin Depenizen, LibsDisguises
// -->
if (attribute.startsWith("type")) {
return new Element(disguise.getType().toString()).getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <libsdisguise@libsdisguise.type>
// @returns dEntity
// @description
// Returns the entity of the disguise.
// @Plugin Depenizen, LibsDisguises
// -->
if (attribute.startsWith("entity")) {
return new dEntity(disguise.getEntity()).getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <libsdisguise@libsdisguise.display_name>
// @returns Element
// @description
// Returns the display name of the disguise.
// @Plugin Depenizen, LibsDisguises
// -->
if (attribute.startsWith("display_name")) {
return new Element(disguise.getWatcher().getCustomName()).getAttribute(attribute.fulfill(1));
}
return new Element(identify()).getAttribute(attribute);
}
}