-
-
Notifications
You must be signed in to change notification settings - Fork 87
/
SentinelSimplePets.java
41 lines (35 loc) · 1.28 KB
/
SentinelSimplePets.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
package org.mcmonkey.sentinel.integration;
import org.bukkit.entity.LivingEntity;
import org.mcmonkey.sentinel.SentinelIntegration;
import org.mcmonkey.sentinel.SentinelUtilities;
import simplepets.brainsynder.api.entity.IEntityPet;
import simplepets.brainsynder.api.plugin.SimplePets;
import java.util.Optional;
public class SentinelSimplePets extends SentinelIntegration {
@Override
public String getTargetHelp() {
return "simplepet:PET_NAME_REGEX";
}
@Override
public String[] getTargetPrefixes() {
return new String[] { "simplepet" };
}
@Override
public boolean isTarget(LivingEntity ent, String prefix, String value) {
try {
if (!prefix.equals("simplepet")) {
return false;
}
Optional<Object> optional = SimplePets.getSpawnUtil().getHandle(ent);
if (optional.isPresent() && optional.get() instanceof IEntityPet) {
String name = ((IEntityPet) optional.get()).getPetType().getName();
return SentinelUtilities.regexFor(value).matcher(name).matches();
}
return false;
}
catch (Exception ex) {
ex.printStackTrace();
}
return false;
}
}