The JVM can't find the path to my class when all the classes used are packaged in a jar plugin

Discussion in 'Plugin Development' started by 555Jeka555, Nov 2, 2022.

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

    555Jeka555

    Code:
    [16:09:32 ОШИБКА]: Произошла ошибка при включении BedwarsRel v1.3.3 (она обновлена?)
    java.lang.NoClassDefFoundError: net/minecraft/entity/monster/EntityIronGolem
            at ru.mineplay.bedwars.entity.CustomEntityType.<clinit>(CustomEntityType.java:31) ~[?:?]
            на io.github.yannici.bedwars.Main.onEnable(Main.java:179) ~[?:?]
            в org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[patched_1.12.2.jar:git-Paper-1618]
            в org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:316) ~[patched_1.12.2.jar:git-Paper-1618]
            в org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) ~[patched_1.12.2.jar:git-Paper-1618]
            на org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin(CraftServer.java:395) ~[patched_1.12.2.jar:git-Paper-1618]
            на org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins(CraftServer.java:344) ~[patched_1.12.2.jar:git-Paper-1618]
            на net.minecraft.server.v1_12_R1.MinecraftServer.t(MinecraftServer.java:442) ~[patched_1.12.2.jar:git-Paper-1618]
            на net.minecraft.server.v1_12_R1.MinecraftServer.l(MinecraftServer.java:403) ~[patched_1.12.2.jar:git-Paper-1618]
            на net.minecraft.server.v1_12_R1.MinecraftServer.a(MinecraftServer.java:341) ~[patched_1.12.2.jar:git-Paper-1618]
            в net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:289) ~[patched_1.12.2.jar:git-Paper-1618]
            на net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:616) ~[patched_1.12.2.jar:git-Paper-1618]
            на java.lang.Thread.run (неизвестный источник) [?: 1.8.0_51]
    Вызвано: java.lang.ClassNotFoundException: net.minecraft.entity.monster.EntityIronGolem
            в org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:109) ~[patched_1.12.2.jar:git-Paper-1618]
            в org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:104) ~[patched_1.12.2.jar:git-Paper-1618]
            в java.lang.ClassLoader.loadClass (неизвестный источник) ~[?:1.8.0_51]
            в java.lang.ClassLoader.loadClass (неизвестный источник) ~[?:1.8.0_51]
            ... еще 13
    
    I want to register new entities, through my NMS, which I add as a local dependency. Everything is being built, but when I run the plugin on the server, it outputs this error, saying that it cannot find the path to the class when the class was transferred along with my NMS, as shown in the photo. I have another plugin that also registers new entities, using the same code, and it works and initializes, but this one does not. The working plugin is written in bukkit, non-working on spigot
    Code:
    import java.lang.reflect.Field;
    
    import org.bukkit.entity.EntityType;
    
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.EntityList;
    import net.minecraft.entity.EntityLiving;
    import net.minecraft.entity.monster.EntityIronGolem;
    import net.minecraft.entity.passive.EntityVillager;
    
    //import net.minecraft.server.v1_12_R1.Entity;
    //import net.minecraft.server.v1_12_R1.EntityLiving;
    //import net.minecraft.server.v1_12_R1.EntityIronGolem;
    //import net.minecraft.server.v1_12_R1.EntityVillager;
    
    public enum CustomEntityType {
    
        IRON_GOLEM("GolemDefender", 99, EntityType.IRON_GOLEM, EntityIronGolem.class, GolemDefender.class),
        VILLAGER("ShopVillager", 120, EntityType.VILLAGER, EntityVillager.class, ShopVillager.class);
    
        private String name;
        private int id;
        private EntityType entityType;
        private Class<? extends EntityLiving> nmsClass;
        private Class<? extends EntityLiving> customClass;
    
        private CustomEntityType(String name, int id, EntityType entityType, Class<? extends EntityLiving> nmsClass, Class<? extends EntityLiving> customClass) {
            this.name = name;
            this.id = id;
            this.entityType = entityType;
            this.nmsClass = nmsClass;
            this.customClass = customClass;
        }
    
        public String getName() {
            return this.name;
        }
    
        public int getID() {
            return this.id;
        }
    
        public EntityType getEntityType() {
            return this.entityType;
        }
    
        public Class<? extends EntityLiving> getNMSClass() {
            return this.nmsClass;
        }
    
        public Class<? extends EntityLiving> getCustomClass() {
            return this.customClass;
        }
    
        public static void registerEntities() {
            for (CustomEntityType entity : CustomEntityType.values()) {
                CustomEntityType.a(entity.getCustomClass(), entity.getName(), entity.getID());
            }
        }
    
        public static void unregisterEntities() {
            for (CustomEntityType entity : CustomEntityType.values()) {
                try {
                    CustomEntityType.a(entity.getNMSClass(), entity.getName(), entity.getID());
                }
                catch (Exception e) {
                    e.printStackTrace();
                }
            }
            throw new UnsupportedOperationException();
        }
    
        private static void a(Class<? extends Entity> paramClass, String paramString, int paramInt) {
            try {
            	//EntityList.register(paramInt, "mineplaybedwars:" + paramString, paramClass, "mineplaybedwars." + paramString);
                CustomEntityRegistry.registerCustomEntity(paramInt, "mineplaybedwars:" + paramString, paramClass);
            }
            catch (Exception exception) {
                // empty catch block
            }
        }
    }
     

    Attached Files:

    Last edited by a moderator: Nov 2, 2022
Thread Status:
Not open for further replies.

Share This Page