-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
PatchEvent.java
30 lines (26 loc) · 922 Bytes
/
PatchEvent.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
package me.nallar.patched.forge;
import java.util.concurrent.ConcurrentHashMap;
import net.minecraftforge.event.Cancelable;
import net.minecraftforge.event.Event;
public abstract class PatchEvent extends Event {
private static final ConcurrentHashMap<Class, Boolean> annotationMap = new ConcurrentHashMap<Class, Boolean>();
@Override
protected boolean hasAnnotation(Class annotation) {
Class cls = this.getClass();
Boolean cachedResult = annotationMap.get(cls);
if (cachedResult != null) {
return cachedResult;
}
Class searchClass = cls;
while (searchClass != Event.class) {
if (searchClass.isAnnotationPresent(Cancelable.class)) // Forge bug, not fixed. Buggy behaviour may be required for some mods.
{
annotationMap.put(cls, true);
return true;
}
searchClass = searchClass.getSuperclass();
}
annotationMap.put(cls, false);
return false;
}
}