for (ReflectionMethod method : ReflectionMethod.values()) { if (method.isCompatible() && !method.isLoaded()) { getLogger().warning(method.name() + " did not find the method!"); compatible = false;
public static Object setEntityNBTTag(Object NBTTag, Object NMSEntity) { try { ReflectionMethod.NMS_ENTITY_SET_NBT.run(NMSEntity, NBTTag); return NMSEntity; } catch (Exception ex) { ex.printStackTrace(); } return null; }
public static Object readNBTFile(FileInputStream stream) { try { return ReflectionMethod.NBTFILE_READ.run(null, stream); } catch (Exception e) { e.printStackTrace(); } return null; }
public static Object saveNBTFile(Object nbt, FileOutputStream stream) { try { return ReflectionMethod.NBTFILE_WRITE.run(null, nbt, stream); } catch (Exception e) { e.printStackTrace(); } return null; }
public int size() { try { return (int) ReflectionMethod.LIST_SIZE.run(listObject); } catch (Exception ex) { ex.printStackTrace(); } return -1; }
@SuppressWarnings("unchecked") public Set<String> getKeys() { try { return (Set<String>) ReflectionMethod.LISTCOMPOUND_GET_KEYS.run(compound); } catch (Exception ex) { ex.printStackTrace(); } return new HashSet<>(); }
public String getString(int i) { if (type != NBTType.NBTTagString) { new Throwable("Using String method on a non String list!").printStackTrace(); return null; } try { return (String) ReflectionMethod.LIST_GET_STRING.run(listObject, i); } catch (Exception ex) { ex.printStackTrace(); } return null; }
public NBTContainer(String nbtString) throws IllegalArgumentException { super(null, null); try{ nbt = ReflectionMethod.PARSE_NBT.run(null, nbtString); }catch(Exception ex){ ex.printStackTrace(); throw new IllegalArgumentException("Malformed Json: " + ex.getMessage()); } }
public static Object getEntityNBTTagCompound(Object NMSEntity) { try { Object nbt = ClassWrapper.NMS_NBTTAGCOMPOUND.getClazz().newInstance(); Object answer = ReflectionMethod.NMS_ENTITY_GET_NBT.run(NMSEntity, nbt); if (answer == null) answer = nbt; return answer; } catch (Exception e) { e.printStackTrace(); } return null; }
public void remove(int i) { try { ReflectionMethod.LIST_REMOVE_KEY.run(listObject, i); save(); } catch (Exception ex) { ex.printStackTrace(); } }
public NBTListCompound getCompound(int id) { if (type != NBTType.NBTTagCompound) { new Throwable("Using Compound method on a non Compound list!").printStackTrace(); return null; } try { Object compound = ReflectionMethod.LIST_GET.run(listObject, id); return new NBTListCompound(this, compound); } catch (Exception ex) { ex.printStackTrace(); } return null; }
public static Object getNMSEntity(Entity entity) { try { return ReflectionMethod.CRAFT_ENTITY_GET_HANDLE.run(ClassWrapper.CRAFT_ENTITY.getClazz().cast(entity)); } catch (Exception e) { e.printStackTrace(); } return null; }
public static NBTContainer convertItemtoNBT(ItemStack item){ return NBTReflectionUtil.convertNMSItemtoNBTCompound(ReflectionMethod.ITEMSTACK_NMSCOPY.run(null, item)); }
public static ItemStack convertNBTtoItem(NBTCompound comp){ return (ItemStack) ReflectionMethod.ITEMSTACK_BUKKITMIRROR.run(null, NBTReflectionUtil.convertNBTCompoundtoNMSItem(comp)); }
public void addString(String s) { if (type != NBTType.NBTTagString) { new Throwable("Using String method on a non String list!").printStackTrace(); return; } try { ReflectionMethod.LIST_ADD.run(listObject, ClassWrapper.NMS_NBTTAGSTRING.getClazz().getConstructor(String.class).newInstance(s)); save(); } catch (Exception ex) { ex.printStackTrace(); } }
public void setString(int i, String s) { if (type != NBTType.NBTTagString) { new Throwable("Using String method on a non String list!").printStackTrace(); return; } try { ReflectionMethod.LIST_SET.run(listObject, i, ClassWrapper.NMS_NBTTAGSTRING.getClazz().getConstructor(String.class).newInstance(s)); save(); } catch (Exception ex) { ex.printStackTrace(); } }
protected Object getCompound() { return NBTReflectionUtil.getItemRootNBTTagCompound(ReflectionMethod.ITEMSTACK_NMSCOPY.run(null, bukkitItem)); }
public NBTListCompound addCompound() { if (type != NBTType.NBTTagCompound) { new Throwable("Using Compound method on a non Compound list!").printStackTrace(); return null; } try { Object compound = ClassWrapper.NMS_NBTTAGCOMPOUND.getClazz().newInstance(); ReflectionMethod.LIST_ADD.run(listObject, compound); return new NBTListCompound(this, compound); } catch (Exception ex) { ex.printStackTrace(); } return null; }
public static void setTileEntityNBTTagCompound(BlockState tile, Object comp) { try { Object pos = ObjectCreator.NMS_BLOCKPOSITION.getInstance(tile.getX(), tile.getY(), tile.getZ()); Object cworld = ClassWrapper.CRAFT_WORLD.getClazz().cast(tile.getWorld()); Object nmsworld = ReflectionMethod.CRAFT_WORLD_GET_HANDLE.run(cworld); Object o = ReflectionMethod.NMS_WORLD_GET_TILEENTITY.run(nmsworld, pos); ReflectionMethod.TILEENTITY_SET_NBT.run(o, comp); } catch (Exception e) { e.printStackTrace(); } }