Search in sources :

Example 76 with Constructor

use of java.lang.reflect.Constructor in project SpaciousLib by anhcraft.

the class ItemsNBT method setFloat.

public ItemStack setFloat(String name, float 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;
    }
}
Also used : Constructor(java.lang.reflect.Constructor) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 77 with Constructor

use of java.lang.reflect.Constructor in project SpaciousLib by anhcraft.

the class ActionBar method send.

@Override
public void send(World world, String text) {
    try {
        Class e = Class.forName("org.anhcraft.spaciouslib.Server.ActionBar.ActionBar_" + GameVersion.getVersion().toString().replace("v", ""));
        Constructor c = e.getConstructor();
        ActionBarWarpper i = (ActionBarWarpper) c.newInstance();
        i.send(world, text);
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException x) {
        x.printStackTrace();
    }
}
Also used : Constructor(java.lang.reflect.Constructor) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 78 with Constructor

use of java.lang.reflect.Constructor in project SpaciousLib by anhcraft.

the class Title method sendTitle.

@Override
public void sendTitle(Player player, String text, int fadeIn, int stay, int fadeOut) {
    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(player, text, fadeIn, stay, fadeOut);
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException x) {
        x.printStackTrace();
    }
}
Also used : Constructor(java.lang.reflect.Constructor) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 79 with Constructor

use of java.lang.reflect.Constructor in project SpaciousLib by anhcraft.

the class Title method sendSubTitle.

@Override
public void sendSubTitle(World world, String text, int fadeIn, int stay, int fadeOut) {
    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.sendSubTitle(world, text, fadeIn, stay, fadeOut);
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException x) {
        x.printStackTrace();
    }
}
Also used : Constructor(java.lang.reflect.Constructor) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 80 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, int fadeIn, int stay, int fadeOut) {
    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, fadeIn, stay, fadeOut);
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException x) {
        x.printStackTrace();
    }
}
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