Solved Package does not exist error.

Discussion in 'Spigot Plugin Development' started by _BooH_, Mar 28, 2020.

  1. Hello! I'm creating a spigot plugin that will spawn NPCs in IntelliJ IDEA. IntelliJ doesn't see any errors, but when I'm trying to compile the plugin I get a lot of errors of the same type: "Package ... does not exist". E.g. "Package com.mojang.authlib doesn't exist".

    Here's the class that has the errors:
    Code (Java):
    package me.booh.aplugin;

    import com.mojang.authlib.GameProfile;                      //The errors are here,
    import net.minecraft.server.v1_14_R1.*;                     //Here,
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.craftbukkit.v1_14_R1.CraftServer;         //Here,
    import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;          //Here
    import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;  //And here
    import org.bukkit.entity.Player;

    import java.util.UUID;

    public class NPCCreator {


        public void createNPC(Player player, String name, Location location) {
            MinecraftServer nmsServer = ((CraftServer) Bukkit.getServer()).getServer();
            WorldServer nmsWorld = ((CraftWorld) location.getWorld()).getHandle();
            GameProfile gameProfile = new GameProfile(UUID.fromString("ebb39700-7069-11ea-bc55-0242ac130003"), ChatColor.DARK_GREEN.BOLD + name);

            EntityPlayer npc = new EntityPlayer(nmsServer, nmsWorld, gameProfile, new PlayerInteractManager(nmsWorld));
            Player npcPlayer = npc.getBukkitEntity().getPlayer();
            npcPlayer.setPlayerListName("");

            npc.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());

            PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
            connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc));
            connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
        }

    }
     
    "C:\Program Files\Java\jdk1.8.0_172\bin\java.exe" -Dmaven.multiModuleProjectDirectory=D:\Minecraft\Plugins\APlugin "-Dmaven.home=D:\JetBrains\IntelliJ IDEA Community Edition 2018.1.1\plugins\maven\lib\maven3" "-Dclassworlds.conf=D:\JetBrains\IntelliJ IDEA Community Edition 2018.1.1\plugins\maven\lib\maven3\bin\m2.conf" "-javaagent:\JetBrains\IntelliJ IDEA Community Edition 2018.1.1\lib\idea_rt.jar=6673:\JetBrains\IntelliJ IDEA Community Edition 2018.1.1\bin" -Dfile.encoding=UTF-8 -classpath "D:\JetBrains\IntelliJ IDEA Community Edition 2018.1.1\plugins\maven\lib\maven3\boot\plexus-classworlds-2.5.2.jar" org.codehaus.classworlds.Launcher -Didea.version=2018.1.1 package -f pom.xml
    [INFO] Scanning for projects...
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] Building APlugin 1.0-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ APlugin ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 1 resource
    [INFO]
    [INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ APlugin ---
    [INFO] Changes detected - recompiling the module!
    [INFO] Compiling 5 source files to D:\Minecraft\Plugins\APlugin\target\classes
    [INFO] -------------------------------------------------------------
    [ERROR] COMPILATION ERROR :
    [INFO] -------------------------------------------------------------
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[3,26] package com.mojang.authlib does not exist
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[4,1] package net.minecraft.server.v1_14_R1 does not exist
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[8,39] package org.bukkit.craftbukkit.v1_14_R1 does not exist
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[9,39] package org.bukkit.craftbukkit.v1_14_R1 does not exist
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[10,46] package org.bukkit.craftbukkit.v1_14_R1.entity does not exist
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[19,9] cannot find symbol
    symbol: class MinecraftServer
    location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[19,39] cannot find symbol
    symbol: class CraftServer
    location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[20,9] cannot find symbol
    symbol: class WorldServer
    location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[20,34] cannot find symbol
    symbol: class CraftWorld
    location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[21,9] cannot find symbol
    symbol: class GameProfile
    location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[21,39] cannot find symbol
    symbol: class GameProfile
    location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[23,9] cannot find symbol
    symbol: class EntityPlayer
    location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[23,32] cannot find symbol
    symbol: class EntityPlayer
    location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[23,83] cannot find symbol
    symbol: class PlayerInteractManager
    location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[29,9] cannot find symbol
    symbol: class PlayerConnection
    location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[29,41] cannot find symbol
    symbol: class CraftPlayer
    location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[30,35] cannot find symbol
    symbol: class PacketPlayOutPlayerInfo
    location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[30,82] package PacketPlayOutPlayerInfo does not exist
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[31,35] cannot find symbol
    symbol: class PacketPlayOutNamedEntitySpawn
    location: class me.booh.aplugin.NPCCreator
    [INFO] 19 errors
    [INFO] -------------------------------------------------------------
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 1.909 s
    [INFO] Finished at: 2020-03-28T21:24:43+02:00
    [INFO] Final Memory: 15M/175M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project APlugin: Compilation failure: Compilation failure:
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[3,26] package com.mojang.authlib does not exist
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[4,1] package net.minecraft.server.v1_14_R1 does not exist
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[8,39] package org.bukkit.craftbukkit.v1_14_R1 does not exist
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[9,39] package org.bukkit.craftbukkit.v1_14_R1 does not exist
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[10,46] package org.bukkit.craftbukkit.v1_14_R1.entity does not exist
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[19,9] cannot find symbol
    [ERROR] symbol: class MinecraftServer
    [ERROR] location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[19,39] cannot find symbol
    [ERROR] symbol: class CraftServer
    [ERROR] location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[20,9] cannot find symbol
    [ERROR] symbol: class WorldServer
    [ERROR] location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[20,34] cannot find symbol
    [ERROR] symbol: class CraftWorld
    [ERROR] location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[21,9] cannot find symbol
    [ERROR] symbol: class GameProfile
    [ERROR] location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[21,39] cannot find symbol
    [ERROR] symbol: class GameProfile
    [ERROR] location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[23,9] cannot find symbol
    [ERROR] symbol: class EntityPlayer
    [ERROR] location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[23,32] cannot find symbol
    [ERROR] symbol: class EntityPlayer
    [ERROR] location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[23,83] cannot find symbol
    [ERROR] symbol: class PlayerInteractManager
    [ERROR] location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[29,9] cannot find symbol
    [ERROR] symbol: class PlayerConnection
    [ERROR] location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[29,41] cannot find symbol
    [ERROR] symbol: class CraftPlayer
    [ERROR] location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[30,35] cannot find symbol
    [ERROR] symbol: class PacketPlayOutPlayerInfo
    [ERROR] location: class me.booh.aplugin.NPCCreator
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[30,82] package PacketPlayOutPlayerInfo does not exist
    [ERROR] /D:/Minecraft/Plugins/APlugin/src/main/java/me/booh/aplugin/NPCCreator.java:[31,35] cannot find symbol
    [ERROR] symbol: class PacketPlayOutNamedEntitySpawn
    [ERROR] location: class me.booh.aplugin.NPCCreator
    [ERROR] -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
    Picked up _JAVA_OPTIONS: -Xmx2048m

    Process finished with exit code 1
     
  2. MrGeneralQ

    MrGeneralQ Previously qintinator
    Supporter

    My guess would be that you don't use the exact same spigot version as your server jar compared to the one you compiled the plugin for. The problem with NMS is exactly this. Whenever the minecraft version changes, you will need to update your plugin accordingly. There are some ways to still have it work, but unless you are a very experienced developer, you won't be able to keep your code nice and clean.
     
    • Useful Useful x 1
  3. My spigot.jar is version 1.14.4. How can I see the plugin's version?
     
  4. Ok, I fixed the errors by changing the spigot dependency version in pom.xml (It was 1.15.2). But now my plugin is 23.68 MB. Before this it was like 10 KB. I can also see spigot.jar in the compiled plugin.
    upload_2020-3-29_0-4-25.png
     
  5. OMG! It's finally done! I cleaned the code with maven and it's now 13 KB. I spent 3 hours to resolve this stupid mistake.