use of java.lang.reflect.Constructor in project SpaciousLib by anhcraft.
the class ItemsNBT method getFloat.
public float getFloat(String name) {
try {
Class<?> e = Class.forName("org.anhcraft.spaciouslib.Inventory.ItemNBT.NBTCompound_" + GameVersion.getVersion().toString().replace("v", ""));
Constructor c = e.getConstructor();
NBTCompoundWarpper i = (NBTCompoundWarpper) c.newInstance();
i.importFromItem(item);
return i.getFloat(name);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException x) {
x.printStackTrace();
return 0;
}
}
use of java.lang.reflect.Constructor in project SpaciousLib by anhcraft.
the class ItemsNBT method getLong.
public long getLong(String name) {
try {
Class<?> e = Class.forName("org.anhcraft.spaciouslib.Inventory.ItemNBT.NBTCompound_" + GameVersion.getVersion().toString().replace("v", ""));
Constructor c = e.getConstructor();
NBTCompoundWarpper i = (NBTCompoundWarpper) c.newInstance();
i.importFromItem(item);
return i.getLong(name);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException x) {
x.printStackTrace();
return 0;
}
}
use of java.lang.reflect.Constructor in project SpaciousLib by anhcraft.
the class ItemsNBT method setBoolean.
public ItemStack setBoolean(String name, Boolean value) {
try {
Class<?> e = Class.forName("org.anhcraft.spaciouslib.Inventory.ItemNBT.NBTCompound_" + GameVersion.getVersion().toString().replace("v", ""));
Constructor c = e.getConstructor();
NBTCompoundWarpper i = (NBTCompoundWarpper) c.newInstance();
i.importFromItem(item);
i.set(name, value);
return i.exportToItem(item);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException x) {
x.printStackTrace();
return null;
}
}
use of java.lang.reflect.Constructor in project SpaciousLib by anhcraft.
the class ItemsNBT method getAllTags.
public LinkedHashMap<String, Object> getAllTags() {
try {
Class<?> e = Class.forName("org.anhcraft.spaciouslib.Inventory.ItemNBT.NBTCompound_" + GameVersion.getVersion().toString().replace("v", ""));
Constructor c = e.getConstructor();
NBTCompoundWarpper i = (NBTCompoundWarpper) c.newInstance();
i.importFromItem(item);
return i.getAllTags();
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException x) {
x.printStackTrace();
return null;
}
}
use of java.lang.reflect.Constructor in project SpaciousLib by anhcraft.
the class ItemsNBT method getList.
public List<NBTCompoundWarpper> getList(String name) {
try {
Class<?> e = Class.forName("org.anhcraft.spaciouslib.Inventory.ItemNBT.NBTCompound_" + GameVersion.getVersion().toString().replace("v", ""));
Constructor c = e.getConstructor();
NBTCompoundWarpper i = (NBTCompoundWarpper) c.newInstance();
i.importFromItem(item);
return i.getList(name);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException x) {
x.printStackTrace();
return null;
}
}
Aggregations