Search in sources :

Example 81 with Constructor

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();
    }
}
Also used : Constructor(java.lang.reflect.Constructor) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 82 with Constructor

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;
    }
}
Also used : Constructor(java.lang.reflect.Constructor) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 83 with Constructor

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;
    }
}
Also used : Constructor(java.lang.reflect.Constructor) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 84 with Constructor

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;
    }
}
Also used : Constructor(java.lang.reflect.Constructor) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 85 with Constructor

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;
    }
}
Also used : Constructor(java.lang.reflect.Constructor) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

Constructor (java.lang.reflect.Constructor)1314 InvocationTargetException (java.lang.reflect.InvocationTargetException)283 Method (java.lang.reflect.Method)253 IOException (java.io.IOException)128 Field (java.lang.reflect.Field)112 ArrayList (java.util.ArrayList)106 Test (org.junit.Test)92 DOMTestDocumentBuilderFactory (org.w3c.domts.DOMTestDocumentBuilderFactory)74 JUnitTestSuiteAdapter (org.w3c.domts.JUnitTestSuiteAdapter)73 List (java.util.List)61 JAXPDOMTestDocumentBuilderFactory (org.w3c.domts.JAXPDOMTestDocumentBuilderFactory)58 Map (java.util.Map)50 Type (java.lang.reflect.Type)39 Annotation (java.lang.annotation.Annotation)38 HashMap (java.util.HashMap)38 HashSet (java.util.HashSet)31 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)31 ParameterizedType (java.lang.reflect.ParameterizedType)30 File (java.io.File)20 URL (java.net.URL)20