Esempio n. 1
0
 /** Gets the NMS version of a Bukkit entity */
 public static Object getHandle(Object obj) {
   Object handle = null;
   Method getHandle = ReflectionUtils.getMethod(obj.getClass(), "getHandle");
   try {
     handle = getHandle.invoke(obj);
   } catch (Exception ex) {
     ex.printStackTrace();
   }
   return handle;
 }
Esempio n. 2
0
 /** Gets the NMS version of a Bukkit itemstack */
 public static Object getNMSStack(ItemStack stack) {
   try {
     Class<?> clazz =
         Class.forName("org.bukkit.craftbukkit." + version + ".inventory.CraftItemStack");
     Method m = ReflectionUtils.getMethod(clazz, "asNMSCopy", new Class<?>[] {ItemStack.class});
     return m.invoke(null, stack);
   } catch (Exception ex) {
     ex.printStackTrace();
   }
   return null;
 }