Help please

Discussion in 'Spigot Plugin Help' started by GHStudios, May 23, 2016.

  1. Trying to get this pom file to work with the current code

    Im trying to get the Import net.minecraft.server stuff to work. I believe its a problem with my pom file.

    Code (Text):

    package ca.duckcraftpvp.duckcraftmobai.entities;

    import java.lang.reflect.Field;
    import java.util.Map;
    import net.minecraft.server.v1_9_4_R0.BiomeBase;
    import net.minecraft.server.v1_9_4_R0.EntityBlaze;
    import net.minecraft.server.v1_9_4_R0.EntityCaveSpider;
    import net.minecraft.server.v1_9_4_R0.EntityChicken;
    import net.minecraft.server.v1_9_4_R0.EntityEnderman;
    import net.minecraft.server.v1_9_4_R0.EntityGhast;
    import net.minecraft.server.v1_9_4_R0.EntityInsentient;
    import net.minecraft.server.v1_9_4_R0.EntityMagmaCube;
    import net.minecraft.server.v1_9_4_R0.EntityPigZombie;
    import net.minecraft.server.v1_9_4_R0.EntitySilverfish;
    import net.minecraft.server.v1_9_4_R0.EntitySkeleton;
    import net.minecraft.server.v1_9_4_R0.EntitySlime;
    import net.minecraft.server.v1_9_4_R0.EntitySpider;
    import net.minecraft.server.v1_9_4_R0.EntityTypes;
    import net.minecraft.server.v1_9_4_R0.EntityWitch;
    import net.minecraft.server.v1_9_4_R0.EntityZombie;
    import org.apollodevs.duckcraftmobai.entities.types.CustomEntityBlaze;
    import org.apollodevs.duckcraftmobai.entities.types.CustomEntityCaveSpider;
    import org.apollodevs.duckcraftmobai.entities.types.CustomEntityCreeper;
    import org.apollodevs.duckcraftmobai.entities.types.CustomEntityEnderman;
    import org.apollodevs.duckcraftmobai.entities.types.CustomEntityGhast;
    import org.apollodevs.duckcraftmobai.entities.types.CustomEntityLavaSlime;
    import org.apollodevs.duckcraftmobai.entities.types.CustomEntityPigZombie;
    import org.apollodevs.duckcraftmobai.entities.types.CustomEntitySilverfish;
    import org.apollodevs.duckcraftmobai.entities.types.CustomEntitySkeleton;
    import org.apollodevs.duckcraftmobai.entities.types.CustomEntitySlime;
    import org.apollodevs.duckcraftmobai.entities.types.CustomEntitySpider;
    import org.apollodevs.duckcraftmobai.entities.types.CustomEntityWitch;
    import org.apollodevs.duckcraftmobai.entities.types.CustomEntityZombie;
    import org.bukkit.entity.EntityType;

    public enum CustomEntityType
    {
        CREEPER("Creeper", 50, EntityType.CREEPER, EntityChicken.class, CustomEntityCreeper.class),  SKELETON("Skeleton", 51, EntityType.SKELETON, EntitySkeleton.class, CustomEntitySkeleton.class),  SPIDER("Spider", 52, EntityType.SPIDER, EntitySpider.class, CustomEntitySpider.class),  ZOMBIE("Zombie", 54, EntityType.ZOMBIE, EntityZombie.class, CustomEntityZombie.class),  SLIME("Slime", 55, EntityType.SLIME, EntitySlime.class, CustomEntitySlime.class),  GHAST("Ghast", 56, EntityType.GHAST, EntityGhast.class, CustomEntityGhast.class),  PIGZOMBIE("PigZombie", 57, EntityType.PIG_ZOMBIE, EntityPigZombie.class, CustomEntityPigZombie.class),  ENDERMAN("Enderman", 58, EntityType.ENDERMAN, EntityEnderman.class, CustomEntityEnderman.class),  CAVESPIDER("CaveSpider", 59, EntityType.CAVE_SPIDER, EntityCaveSpider.class, CustomEntityCaveSpider.class),  SILVERFISH("Silverfish", 60, EntityType.SILVERFISH, EntitySilverfish.class, CustomEntitySilverfish.class),  BLAZE("Blaze", 61, EntityType.BLAZE, EntityBlaze.class, CustomEntityBlaze.class),  LAVASLIME("LavaSlime", 62, EntityType.MAGMA_CUBE, EntityMagmaCube.class, CustomEntityLavaSlime.class),  WITCH("Witch", 66, EntityType.WITCH, EntityWitch.class, CustomEntityWitch.class);

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

        private CustomEntityType(String name, int id, EntityType entityType, Class<? extends EntityInsentient> nmsClass, Class<? extends EntityInsentient> 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 EntityInsentient> getNMSClass()
        {
            return this.nmsClass;
        }

        public Class<? extends EntityInsentient> getCustomClass()
        {
            return this.customClass;
        }

        public static void registerEntities()
        {
            CustomEntityType[] arrayOfCustomEntityType;
            int j = (arrayOfCustomEntityType = values()).length;
            for (int i = 0; i < j; i++)
            {
                CustomEntityType entity = arrayOfCustomEntityType[i];
                a(entity.getCustomClass(), entity.getName(), entity.getID());
            }
            try
            {
                biomes = (BiomeBase[])getPrivateStatic(BiomeBase.class, "biomes");
            }
            catch (Exception exc)
            {
                BiomeBase[] biomes;
                return;
            }
            BiomeBase[] biomes;
        }

        public static void unregisterEntities()
        {
            CustomEntityType[] arrayOfCustomEntityType;
            int j = (arrayOfCustomEntityType = values()).length;
            for (int i = 0; i < j; i++)
            {
                CustomEntityType entity = arrayOfCustomEntityType[i];
                try
                {
                    ((Map)getPrivateStatic(EntityTypes.class, "d")).remove(entity
                            .getCustomClass());
                }
                catch (Exception e)
                {
                    e.printStackTrace();
                }
                try
                {
                    ((Map)getPrivateStatic(EntityTypes.class, "f")).remove(entity
                            .getCustomClass());
                }
                catch (Exception e)
                {
                    e.printStackTrace();
                }
            }
            j = (arrayOfCustomEntityType = values()).length;
            for (i = 0; i < j; i++)
            {
                CustomEntityType entity = arrayOfCustomEntityType[i];
                try
                {
                    a(entity.getNMSClass(), entity.getName(), entity.getID());
                }
                catch (Exception e)
                {
                    e.printStackTrace();
                }
            }
            try
            {
                biomes = (BiomeBase[])getPrivateStatic(BiomeBase.class, "biomes");
            }
            catch (Exception exc)
            {
                BiomeBase[] biomes;
                return;
            }
            BiomeBase[] biomes;
        }

        private static Object getPrivateStatic(Class<?> clazz, String f)
                throws Exception
        {
            Field field = clazz.getDeclaredField(f);
            field.setAccessible(true);
            return field.get(null);
        }

        private static void a(Class<?> paramClass, String paramString, int paramInt)
        {
            try
            {
                ((Map)getPrivateStatic(EntityTypes.class, "c")).put(paramString,
                        paramClass);
                ((Map)getPrivateStatic(EntityTypes.class, "d")).put(paramClass,
                        paramString);
                ((Map)getPrivateStatic(EntityTypes.class, "e")).put(
                        Integer.valueOf(paramInt), paramClass);
                ((Map)getPrivateStatic(EntityTypes.class, "f")).put(paramClass,
                        Integer.valueOf(paramInt));
                ((Map)getPrivateStatic(EntityTypes.class, "g")).put(paramString,
                        Integer.valueOf(paramInt));
            }
            catch (Exception localException) {}
        }
    }

    Code (Text):
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>

        <groupId>ca.duckcraftpvp</groupId>
        <artifactId>NoMobAi</artifactId>
        <version>1.9.0-SNAPSHOT</version>


        <repositories>
            <repository>
                <id>spigot-repo</id>
                <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
            </repository>
        </repositories>
        <dependencies>
            <!--Spigot API-->
            <dependency>
                <groupId>org.spigotmc</groupId>
                <artifactId>spigot-api</artifactId>
                <version>1.9.4-R0.1-SNAPSHOT</version>
                <scope>provided</scope>
            </dependency>
            <!--Bukkit API-->
            <dependency>
                <groupId>org.bukkit</groupId>
                <artifactId>bukkit</artifactId>
                <version>1.9.4-R0.1-SNAPSHOT</version>
            </dependency>
        </dependencies>
    </project>
     
  2. MiniDigger

    Supporter

    you need to build against spigot if you want to use nms. change your spigot dependency to have spigot as artifact id
     
  3. Ok how do i do that?
     
  4. MiniDigger

    Supporter

     
  5. So just where it asks for Artifact id put spigot?
     
  6. Sorry if im a lil slow, Im just learning java and trying to update a plugin i ordered.