My whole class is underlined in red!

Discussion in 'Spigot Plugin Development' started by avighnash, Jun 19, 2016.

  1. Hello! I am using intellij, and just recently imported one of my projects from eclipse, to intellij. When I viewed one of the classes, thigns like IChatSerializer and all that nms stuff was underlined in read. In my pom.xml, I had the spigot dependency, and everything other than nms was not underlined. Why is this happening?
    Here is the pom.xml I have:

    Code (Text):
    <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>us.universalpvp</groupId>
        <artifactId>te</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>jar</packaging>

        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        </properties>

        <repositories>
            <repository>
                <id>spigot-repo</id>
                <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
            </repository>
            <repository>
                <id>vault-repo</id>
                <url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
            </repository>
        </repositories>

        <dependencies>
            <!--Spigot API-->
            <dependency>
                <groupId>org.spigotmc</groupId>
                <artifactId>spigot-api</artifactId>
                <version>1.8.8-R0.1-SNAPSHOT</version>
                <scope>provided</scope>
            </dependency>
            <!--Vault API-->
            <dependency>
                <groupId>net.milkbowl.vault</groupId>
                <artifactId>VaultAPI</artifactId>
                <version>1.5</version>
                <scope>provided</scope>
            </dependency>
            <!--Bukkit API-->
            <dependency>
                <groupId>org.bukkit</groupId>
                <artifactId>bukkit</artifactId>
                <version>1.8.8-R0.1-SNAPSHOT</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>

        <build>
            <finalName>UniversalCore</finalName>
            <defaultGoal>clean package install</defaultGoal>
            <plugins>
                <plugin>
                    <!-- maven compiler plugin -->
                    <version>3.1</version>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
            </plugins>
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <filtering>true</filtering>
                </resource>
            </resources>
        </build>
    </project>
     
  2. You need to download and run BuildTools for the version that you need.
     
  3. Doesn't look like you have the server implementation as depencency...
    Also, why do you have both bukkit and spigot-api?
    Haven't you added the api by mistake instead of the server?
     
  4. 1) You're depending on the API, not the server.
    2) You're depending on Spigot API and Bukkit at the same time – you only need one.

    fuck i got ninja'd
     
    • Like Like x 1
    • Funny Funny x 1
  5. So for the server itself, I would have to use spigot as the artifactId instead of spigot-api?
     
  6. How do I add the server? And I have run build tools on my PC.
     
  7. Yes, but be sure to have at least run BuildTools once for that version
     
  8. You probably won't find the server jar in any repo, so, add the result jar from the build tools as a dependency from your own computer. You have an option to specify the path of the file when adding the dependency.
    There might be an easier way though, I don't usually work with maven.
     
  9. Just run BuildTools, this will add the jar to your local repo.
     
    • Like Like x 1
  10. So basically, I have to add the jar file to my build path? Then do I remove the repository and dependency in the pom.xml?
     
  11. I have done that.
     
  12. Can you show us the pom.xml and the error you get whilr hovering over the red lines?
     
  13. Here is pom:

    Code (Text):
    <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>us.universalpvp</groupId>
        <artifactId>te</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>jar</packaging>

        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        </properties>

        <repositories>
            <!--Spigot API repository-->
            <repository>
                <id>spigot-repo</id>
                <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
            </repository>
            <!--Vault API repository-->
            <repository>
                <id>vault-repo</id>
                <url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
            </repository>
            <!--Fanciful API repository-->
            <repository>
                <id>stealthyone-repo</id>
                <url>http://repo.stealthyone.com/content/groups/public</url>
            </repository>
        </repositories>

        <dependencies>
            <!--Fanciful API-->
            <dependency>
                <groupId>mkremins</groupId>
                <artifactId>fanciful</artifactId>
                <version>0.3.5-SNAPSHOT</version>
            </dependency>
            <!--Spigot API-->
            <dependency>
                <groupId>org.spigotmc</groupId>
                <artifactId>spigot</artifactId>
                <version>1.8.8-R0.1-SNAPSHOT</version>
                <scope>provided</scope>
            </dependency>
            <!--Vault API-->
            <dependency>
                <groupId>net.milkbowl.vault</groupId>
                <artifactId>VaultAPI</artifactId>
                <version>1.5</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>

        <build>
            <finalName>UniversalCore</finalName>
            <defaultGoal>clean package install</defaultGoal>
            <plugins>
                <plugin>
                    <!-- maven compiler plugin -->
                    <version>3.1</version>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
            </plugins>
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <filtering>true</filtering>
                </resource>
            </resources>
        </build>
    </project>
    and it says "Cannot resolve symbol IChatBaseComponent"
     
  14. Why would he need Build Tools? As far as I understood it, you only get the server jars by using it. But since he's using Maven he doesn't have to run it by hand.

    @avighnash I think you are missing the NMS dependency. You need the artifact ids spigot-api and spigot.
     
  15. He needs to have the server as dependency, and you can only have it as dependency if it's in you local repo because it isnt on a public repo.
    You get it in your local repo by running BuildTools.

    Also if you have spigot as dependency you also have the spigot-api, so use spigot OR spigot-api not both
     
  16. Still not working :/ I just now finished running build tools again.
     
  17. I don't know why it doesn't work, I din't see the error.

    But going to sleep now, need to wake up in 6h30
     
  18. What about the repo tag in the pom.xml?

    And yes only the spigot dependency is needed, that was a wrong assumption because just using the spigot-api doesn't work when using NMS code^^

    What exactly does the error say? Are the imports underlined as well?
     
  19. Yes, the imports are underlined too. And what do you mean repo tag?
     
  20. No.

    Make sure you have your JDK file specified.

    Your project should have something like this. Try right clicking in the pom.xml and go to Maven then do add as maven project
    [​IMG]

    Try hitting
    CRTL + SHIFT + S