Problem/Bug Problem using MNS with Bukkit 1.14

Discussion in 'Bukkit Help' started by Minicarpet, Aug 11, 2019.

Thread Status:
Not open for further replies.
  1. Offline

    Minicarpet

    Hello,

    I am actually developping Plugin with Bukkit 1.14 with some dependencies :
    Code:
            <dependency>
                <groupId>org.bukkit</groupId>
                <artifactId>bukkit</artifactId>
                <version>1.14.4-R0.1-SNAPSHOT</version>
                <type>jar</type>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.spigotmc</groupId>
                <artifactId>spigot-api</artifactId>
                <version>1.14.4-R0.1-SNAPSHOT</version>
                <type>jar</type>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.sk89q.worldguard</groupId>
                <artifactId>worldguard-core</artifactId>
                <version>7.0.1-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>com.sk89q.worldguard</groupId>
                <artifactId>worldguard-bukkit</artifactId>
                <version>7.0.1-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>com.sk89q.worldguard.worldguard-libs</groupId>
                <artifactId>core</artifactId>
                <version>7.0.1-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>com.googlecode.json-simple</groupId>
                <artifactId>json-simple</artifactId>
                <version>1.1.1</version>
            </dependency>
    I am trying to use NMS to call class but I got strange error :
    I don't understand why my EntityEnderDragon got no init function with World parameter.
    Here is my code :
    Code:
    Class<?> nmsDragonClass = NMSUtils.getNMSClass("EntityEnderDragon");
                nmsDragon = ReflectionUtils.newInstance(nmsDragonClass, new Class<?>[] { NMSUtils.getNMSClass("World") }, NMSUtils.getHandle(player.getLocation().getWorld()));
    Code:
        public static Class<?> getNMSClass(String name) {
            String className = "net.minecraft.server." + version  + "." + name;
            Class<?> clazz = null;
            try {
                clazz = Class.forName(className);
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
            return clazz;
        }
    Code:
        public static Object newInstance(Class<?> cls, Class<?>[] params, Object... args) {
            try {
                return cls.getConstructor(params).newInstance(args);
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            } catch (SecurityException e) {
                e.printStackTrace();
            }
            return null;
        }
    I got finally yhis error :
    but it is probably link to this warning error...

    Could you explain me what am I doing wrong ?

    Thanks a lot
     
  2. Online

    timtower Moderator Moderator

    @Minicarpet Did you try to print all constructors?
     
Thread Status:
Not open for further replies.

Share This Page