use of java.lang.reflect.Constructor in project SpaciousLib by anhcraft.
the class Title method sendTitle.
@Override
public void sendTitle(World world, String text) {
try {
Class e = Class.forName("org.anhcraft.spaciouslib.Server.Title.Title_" + GameVersion.getVersion().toString().replace("v", ""));
Constructor c = e.getConstructor();
TitleWarpper i = (TitleWarpper) c.newInstance();
i.sendTitle(world, text);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException x) {
x.printStackTrace();
}
}
use of java.lang.reflect.Constructor in project SpaciousLib by anhcraft.
the class ItemsNBT method getShort.
public short getShort(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.getShort(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 NBTCompounds method newWarpper.
public static NBTCompoundWarpper newWarpper() {
try {
Class<?> e = Class.forName("org.anhcraft.spaciouslib.Inventory.ItemNBT.NBTCompound_" + GameVersion.getVersion().toString().replace("v", ""));
Constructor c = e.getConstructor();
return (NBTCompoundWarpper) c.newInstance();
} 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 getByteArray.
public byte[] getByteArray(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.getByteArray(name);
} 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 getDouble.
public double getDouble(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.getDouble(name);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException x) {
x.printStackTrace();
return 0;
}
}
Aggregations