-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReflectionUtils.java
39 lines (33 loc) · 1.04 KB
/
ReflectionUtils.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
package net.taunahi_v3.ezskyblock.util;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
public class ReflectionUtils {
public static boolean invoke(Object object, String methodName) {
try {
final Method method = object.getClass().getDeclaredMethod(methodName);
method.setAccessible(true);
method.invoke(object);
return true;
} catch (Exception ignored) {
}
return false;
}
public static Object field(Object object, String name) {
try {
Field field = object.getClass().getDeclaredField(name);
field.setAccessible(true);
return field.get(object);
} catch (Exception ignored) {
}
return null;
}
public static boolean hasPackageInstalled(String name) {
Package[] packages = Package.getPackages();
for (Package pack : packages) {
if (pack.getName().contains(name)) {
return true;
}
}
return false;
}
}