added files.
This commit is contained in:
commit
8aa2a15c64
124 files changed
+14297
No files matched your search
@@ -0,0 +1,30 @@
|
||||
package me.konsolas.aac.util.general;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ItemUseUtil {
|
||||
private static Method getHandleMethod;
|
||||
private static Field activeItemField;
|
||||
|
||||
public static boolean isUsingItem(Player player) {
|
||||
try {
|
||||
if (getHandleMethod == null) {
|
||||
getHandleMethod = player.getClass().getDeclaredMethod("getHandle");
|
||||
getHandleMethod.setAccessible(true);
|
||||
}
|
||||
|
||||
Object entityPlayer = getHandleMethod.invoke(player);
|
||||
if (activeItemField == null) {
|
||||
activeItemField = entityPlayer.getClass().getSuperclass().getSuperclass().getDeclaredField("bo");
|
||||
activeItemField.setAccessible(true);
|
||||
}
|
||||
|
||||
return activeItemField.get(entityPlayer) != null;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user