0

Even though I'm working with Bukkit, this is a Java problem;

I don't know, why Java says the constructor is undefined, since it is defined

import org.bukkit.entity.EntityType;
import net.minecraft.server.v1_10_R1.EntityCow;
import net.minecraft.server.v1_10_R1.EntityInsentient;

public enum Pets
{
    COW("Cow", 92, EntityType.COW, EntityCow.class, Pets.class);

    private String name;
    private int id;
    private EntityType et;
    private Class<? extends EntityInsentient> nmsClass;
    private Class<? extends EntityInsentient> customClass;

    Pets(String name, int id, EntityType et, Class<? extends EntityInsentient> nmsClass, Class<? extends EntityInsentient> customClass)
    {
        this.name = name;
        this.id = id;
        this.et = et;
        this.nmsClass = nmsClass;
        this.customClass = customClass;
    }

    public String getName()
    {
        return name;
    }
    public int getID()
    {
        return id;
    }
    public EntityType getET()
    {
        return et;
    }
    public Class<? extends EntityInsentient> getNMSClass()
    {
        return nmsClass;
    }
    public Class<? extends EntityInsentient> getCustomClass()
    {
        return customClass;
    }
}

Any ideas how tho solve this, because I looked around and found nothing other than this syntax and it seems like all the conversations regarding topics like this are at least 5 years old and very vague.

1 Answers1

5

The constructor of your enum Pets expects 5 parameters:

 Pets(String name, int id, EntityType et,
      Class<? extends EntityInsentient> nmsClass,
      Class<? extends EntityInsentient> customClass)

When you declare the constant COW you are using this constructor:

COW("Cow", 92, EntityType.COW, EntityCow.class, Pets.class);

Note that the 5th parameter, Pets.class, does not conform to what the constructor expects, because enum Pets does not extend or implement EntityInsentient.

There are several ways to solve this, but which one you should use depends on the rest of your program and what you're trying to achieve:

  • You could change the constructor and the field customClass, remove the bound extends EntityInsentient.

  • You could make the enum implement EntityInsentient (public enum Pets implements EntityInsentient); this will only work if that is an interface (enums cannot extend classes).

Jesper
  • 202,709
  • 46
  • 318
  • 350