Solved Importing->org.bukkit.plugin.java.JavaPlugin;

Discussion in 'Plugin Development' started by DrDowfin, Mar 24, 2014.

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

    DrDowfin

    Im just trying to follow the bukkit tutorial here->http://wiki.bukkit.org/Plugin_Tutorial
    I got to creating a plugins class and it told me to put->
    Code:java
    1. package {$GroupName}.{$ArtifactName};
    2.  
    3. import org.bukkit.plugin.java.JavaPlugin;
    4.  
    5. public final class {$ArtifactName} extends JavaPlugin {
    6.  
    7. }

    So I have->
    Code:java
    1. package io.github.DrDowfin.CitiesMC;
    2.  
    3. import org.bukkit.plugin.java.JavaPlugin;
    4.  
    5. public class CitiesMC {
    6.  
    7. }
    8.  

    And over the "org.bukkit" it has that red squiggly line and when I hover over it is says "The import org.bukkit cannot be resolved" I have some experience with Java but nothing with plugins and I honestly feel really, really dumb not being able to figure this bug out.


    And yea I think you may need to see my POM so here you go->
    Code:java
    1. <project xmlns="[url]http://maven.apache.org/POM/4.0.0[/url]" xmlns:xsi="[url]http://www.w3.org/2001/XMLSchema-instance[/url]" xsi:schemaLocation="[url]http://maven.apache.org/POM/4.0.0[/url] [url]http://maven.apache.org/xsd/maven-4.0.0.xsd[/url]">
    2. <modelVersion>4.0.0</modelVersion>
    3. <groupId>io.github.DrDowfin</groupId>
    4. <artifactId>CitiesMC</artifactId>
    5. <version>0.0.1-SNAPSHOT</version>
    6. <repositories>
    7. <repository>
    8. <id>bukkit-repo</id>
    9. <url>[url]http://repo.bukkit.org/content/groups/public/</url>[/url]
    10. </repository>
    11. </repositories>
    12. <build>
    13. <plugins>
    14. <plugin>
    15. <groupId>org.apache.maven.plugins</groupId>
    16. <artifactId>maven-compiler-plugin</artifactId>
    17. <configuration>
    18. <source>1.7</source>
    19. <target>1.7</target>
    20. </configuration>
    21. </plugin>
    22. </plugins>
    23. </build>
    24. </project>


    If you need anything else from me please ask, otherwise pleeeaaase help if you know what to do!
     
  2. Offline

    AoH_Ruthless

    DrDowfin
    You need to have added the jar in your build path. Read the tutorial more closely.

    Also, you don't always need maven!
     
  3. Offline

    DrDowfin

    AoH_Ruthless
    How do I add the jar to my build path? Sorry I have never done anything close to modding in all my life, I reread what the tut said and I didnt see it?
    I did see that I didnt add the extends JavaPlugin onto the class and now under the JavaPlugin after extends it says "Cannot be resolved to a type"

    AoH_Ruthless
    How do I add the jar to my build path? Sorry I have never done anything close to modding in all my life, I reread what the tut said and I didnt see it?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  4. Offline

    TwoPointDuck

    DrDowfin

    Might I suggest you check out the tutorial I just posted on youtube. I won't link it, just look for my name.

    Skip to where I start coding.

    EDIT: I really dont know if its ok for me to promote myself like that...
     
  5. Offline

    amhokies

    To add a Bukkit as a dependency via Maven, you need to add the repository and dependency into the pom.xml file:

    PHP:
        <repositories>
            <!-- 
    The Bukkit Maven Repository -->
            <
    repository>
                <
    id>Bukkit Official</id>
                <
    url>http://repo.bukkit.org/content/repositories/public</url>
            
    </repository>
        </
    repositories>
     
        <
    dependencies>
            <!-- 
    Bukkit API -->
            <
    dependency>
                <
    groupId>org.bukkit</groupId>
                <
    artifactId>bukkit</artifactId>
                <
    version>LATEST</version>
                <
    type>jar</type>
                <
    scope>compile</scope>
            </
    dependency>
        </
    dependencies>
     
  6. Offline

    DrDowfin

    amhokies
    This is my respitories now
    Code:java
    1. <repositories>
    2. <repository>
    3. <id>bukkit-repo</id>
    4. <url>[url]http://repo.bukkit.org/content/groups/public/</url>[/url]
    5. </repository>
    6. <repository>
    7. <id>Bukkit Official</id>
    8. <url>[url]http://repo.bukkit.org/content/repositories/public</url>[/url]
    9. </repository>
    10. </repositories>

    Without everything else in the POM, but that did not seem to fix it.
    TwoPointDuck
    Also I will check out that tutorial
     
  7. Offline

    amhokies

    You need to add the dependency section too.
     
  8. Offline

    TwoPointDuck


    I realized a bit late that you are using Maven. I suggest you don't. Using what I have setup in the video is far easier to use.

    EDIT: On that note, use one of the other tutorials on that website, they are more complete.
    EDIT 2: Or use @amhokies tutorials
     
  9. Offline

    DrDowfin

    amhokies
    Could you give me a code example on how to do that, I have no idea what you are talking about
    TwoPointDuck
    I can always use yours to supplement:p
     
  10. Offline

    amhokies

    I already put it in my first post. Putting the repository without the depencency doesn't do anything. You need to add the dependency part as well.
     
  11. Offline

    SGrayMe

    DrDowfin If you look at the example posted by amhokies there is both a <repositories> section (which you have) and a <dependencies> section (what is missing). The repositories section tells Maven where to find jars to use, the dependencies section tell Maven which jar to use for the project. Please note that <dependencies> is outside the <repositories> section. It's alright that you may be confused by this, it takes everyone time to get used to a new tool, no matter the quality, but please look carefully when someone posts an example. :)
     
    amhokies likes this.
  12. Offline

    amhokies

    SGrayMe
    I'm going to add onto this by saying that while some people may say that Maven is a waste of time, once you understand how to use it, it's a very powerful and time-saving tool. This is especially true for larger projects with a lot of different dependencies.
     
    SGrayMe likes this.
  13. Offline

    TwoPointDuck


    DrDowfin

    But it sounds like he is a beginner to both Java coding and Bukkit. He should first learn the simple things, is what I think. Personally, I don't know Maven, so I might be wrong.
     
  14. Offline

    amhokies

    Smaller projects really don't benefit very much from Maven, yeah. I guess it all just kind of depends what you're making and what it's being made for.
     
  15. Offline

    AoH_Ruthless

    TwoPointDuck
    Yes, it's okay to advertise your own Youtube videos if they might have any relevance to the topic :)
     
  16. Offline

    DrDowfin

    amhokies
    OH I totally missed your first post amhokies! Thank you so much! I was busy typing my post when yours came along:p
     
Thread Status:
Not open for further replies.

Share This Page