Solved Need help with importing NMS

Discussion in 'Plugin Development' started by RealSmileyguy, May 3, 2015.

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

    RealSmileyguy

    Hello, I am making a plugin where it is necessary for a player to be "force respawned," and this requires the use of packets. All seemed fine until I needed to import NMS from CraftBukkit. Because of the DMCA, I figured I could just add the CraftBukkit jar to the build path, and did so. However, when I do Run as>maven clean and Run as>maven install, I get an error:
    Error (open)

    Code:
    [INFO] Scanning for projects...
    [WARNING]
    [WARNING] Some problems were encountered while building the effective model for games.crafting:CraftingGames:jar:0.2.35-SNAPSHOT
    [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 9, column 19
    [WARNING]
    [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
    [WARNING]
    [WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
    [WARNING]
    [INFO]
    [INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
    [INFO]                                                                        
    [INFO] ------------------------------------------------------------------------
    [INFO] Building CraftingGames 0.2.35-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ CraftingGames ---
    [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] Copying 2 resources
    [INFO]
    [INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ CraftingGames ---
    [WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
    [INFO] Compiling 2 source files to C:\Users\kayfamily\workspace\TheCraftingGames\target\classes
    [INFO] -------------------------------------------------------------
    [ERROR] COMPILATION ERROR :
    [INFO] -------------------------------------------------------------
    [ERROR] C:\Users\kayfamily\workspace\TheCraftingGames\src\main\java\games\crafting\plugin\PlayerListener.java:[24,35] error: package net.minecraft.server.v1_7_R3 does not exist
    [ERROR] C:\Users\kayfamily\workspace\TheCraftingGames\src\main\java\games\crafting\plugin\PlayerListener.java:[25,35] error: package net.minecraft.server.v1_7_R3 does not exist
    [ERROR] C:\Users\kayfamily\workspace\TheCraftingGames\src\main\java\games\crafting\plugin\PlayerListener.java:[26,35] error: package net.minecraft.server.v1_7_R3 does not exist
    [ERROR] C:\Users\kayfamily\workspace\TheCraftingGames\src\main\java\games\crafting\plugin\PlayerListener.java:[27,35] error: package net.minecraft.server.v1_7_R3 does not exist
    [ERROR] C:\Users\kayfamily\workspace\TheCraftingGames\src\main\java\games\crafting\plugin\PlayerListener.java:[28,0] error: package net.minecraft.server.v1_7_R3 does not exist
    [ERROR] C:\Users\kayfamily\workspace\TheCraftingGames\src\main\java\games\crafting\plugin\PlayerListener.java:[30,44] error: package org.bukkit.craftbukkit.v1_7_R3.entity does not exist
    [INFO] 6 errors
    [INFO] -------------------------------------------------------------
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 2.866 s
    [INFO] Finished at: 2015-05-03T20:50:04-06:00
    [INFO] Final Memory: 12M/149M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project CraftingGames: Compilation failure: Compilation failure:
    [ERROR] C:\Users\kayfamily\workspace\TheCraftingGames\src\main\java\games\crafting\plugin\PlayerListener.java:[24,35] error: package net.minecraft.server.v1_7_R3 does not exist
    [ERROR] C:\Users\kayfamily\workspace\TheCraftingGames\src\main\java\games\crafting\plugin\PlayerListener.java:[25,35] error: package net.minecraft.server.v1_7_R3 does not exist
    [ERROR] C:\Users\kayfamily\workspace\TheCraftingGames\src\main\java\games\crafting\plugin\PlayerListener.java:[26,35] error: package net.minecraft.server.v1_7_R3 does not exist
    [ERROR] C:\Users\kayfamily\workspace\TheCraftingGames\src\main\java\games\crafting\plugin\PlayerListener.java:[27,35] error: package net.minecraft.server.v1_7_R3 does not exist
    [ERROR] C:\Users\kayfamily\workspace\TheCraftingGames\src\main\java\games\crafting\plugin\PlayerListener.java:[28,0] error: package net.minecraft.server.v1_7_R3 does not exist
    [ERROR] C:\Users\kayfamily\workspace\TheCraftingGames\src\main\java\games\crafting\plugin\PlayerListener.java:[30,44] error: package org.bukkit.craftbukkit.v1_7_R3.entity does not exist
    [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
    

    These are lines 24-30, the "import net.minecraft.server.v1_7_3.*" was out of desperation and hours f unsuccessful work:
    Code:
    import net.minecraft.server.v1_7_R3.EntityPlayer;
    import net.minecraft.server.v1_7_R3.EnumClientCommand;
    import net.minecraft.server.v1_7_R3.PacketPlayInClientCommand;
    import net.minecraft.server.v1_7_R3.PacketPlayOutCustomPayload;
    import net.minecraft.server.v1_7_R3.*;
    
    import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer;
    Here is part of my pom.xml if it helps at all:
    Code:
       <repositories>
           <repository>
               <id>bukkit-repo</id>
               <url>http://repo.bukkit.org/content/groups/public/</url>
           </repository>
       </repositories>
          <dependencies>
           <dependency>
               <groupId>org.bukkit</groupId>
               <artifactId>bukkit</artifactId>
               <version>1.7.9-R0.2</version>
               <type>jar</type>
               <scope>provided</scope>
           </dependency>
       </dependencies>
    </project>
    Thanks in advance.
     
  2. Offline

    RingOfStorms

    Your pom shows that your only dependency is bukkit. bukkit does not include any nms at all as it is just the API, and therefore it will not compile. You need to add craftbukkit as a dependency in order to use nms.
     
  3. Offline

    mine-care

  4. Offline

    RealSmileyguy

    Problem solved. Turns out I had accidentally added the craftbukkit.jar as a "Referenced Library," not a "Maven dependency." Thanks for the help!
     
Thread Status:
Not open for further replies.

Share This Page