-
-
Notifications
You must be signed in to change notification settings - Fork 87
/
SentinelSquads.java
46 lines (39 loc) · 1.39 KB
/
SentinelSquads.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
package org.mcmonkey.sentinel.integration;
import net.citizensnpcs.api.CitizensAPI;
import org.bukkit.entity.LivingEntity;
import org.mcmonkey.sentinel.SentinelIntegration;
import org.mcmonkey.sentinel.SentinelTrait;
import java.util.Locale;
public class SentinelSquads extends SentinelIntegration {
@Override
public String getTargetHelp() {
return "squad:SENTINEL_SQUAD_NAME";
}
@Override
public String[] getTargetPrefixes() {
return new String[] { "squad" };
}
@Override
public boolean shouldLowerCaseValue() {
return true;
}
@Override
public boolean isTarget(LivingEntity ent, String prefix, String value) {
try {
if (prefix.equals("squad") && CitizensAPI.getNPCRegistry().isNPC(ent)
&& CitizensAPI.getNPCRegistry().getNPC(ent).hasTrait(SentinelTrait.class)) {
SentinelTrait sentinel = CitizensAPI.getNPCRegistry().getNPC(ent).getTrait(SentinelTrait.class);
if (sentinel.squad != null) {
String squadName = value.toLowerCase(Locale.ENGLISH);
if (squadName.equals(sentinel.squad)) {
return true;
}
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return false;
}
}