Create A Plugin With A Development Build

Discussion in 'Plugin Development' started by Ratismal, Nov 12, 2014.

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

    Ratismal

    Salutations,

    I am trying my hand at developing bukkit plugins, however I am having difficulties starting with it. I am currently following the tutorial at http://wiki.bukkit.org/Plugin_Tutorial, but have run into an issue.

    I want to develop my plugin using the 1.7.10-R0.1 development build, however I can't figure out how to do it. The tutorial says nothing about using development builds that are unlisted here. Any help in this matter would be greatly appreciated. I hope that this question hasn't already been asked, but I skimmed through a few pages in the forums to no avail.

    tl;dr: How would I make a plugin using the 1.7.10-R0.1 development build?
     
  2. Offline

    Skionz

    Same way as you would if you were using beta or recommended
     
    Konato_K and es359 like this.
  3. Offline

    es359

    Uh so... What exactly is the problem..? Just use the development build? Ratismal
     
  4. Offline

    Ratismal

    Which is?
    The tutorial said to edit my pom.xml file as follows:
    Code:
    <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>io.github.ratismal</groupId>
      <artifactId>confNBT</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <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>
    It said that to use a different version of bukkit, I should modify the 1.7.9-R0.2 to whatever version I want to use, as provided by the maven-metadata.xml file. However, the 1.7.10-R0.1 version cannot be found in this file. Would it be right to assume that I can simply change the <version> tag and expect it to work? Am I overthinking the whole ordeal?

    As a side note, would a plugin developed with the 1.7.9-R0.2 version of bukkit be compatible with CraftBukkit on a 1.7.10 server?



    Yes. I'm probably just being silly, but I am having immense difficulties wrapping my head around how to do this.
     
  5. Offline

    Skionz

    Depends if anything in the api changed
     
  6. Offline

    es359


    Well.. I would consider doing that the hard way... I would just add it like a normal dependency.
     
    Ratismal likes this.
  7. Offline

    Ratismal

    So essentially, I should disregard what the tutorial tells me to do and set it up as an normal dependency? If that is the case, then I should be able to figure out what to do! Thank you for your help in this matter.
     
  8. Offline

    es359

    Which tutorial are you using?
     
  9. Offline

    Europia79

    You are correct that the plugin tutorial does NOT answer your question.

    First, download the Bukkit version that you want: (or compile a new version)
    http://dl.bukkit.org/downloads/bukkit/

    Next, install it into your local maven repository:
    Code:
    // on Linux
    mvn install:install-file -Dfile=/var/minecraft/lib/craftbukkit-1.8.0-R0.1.jar -DgroupId=org.bukkit -DartifactId=craftbukkit -Dversion=1.8.0-R0.1 -Dpackaging=jar -DcreateChecksum=true
    
    // on Windows
    mvn install:install-file -Dfile="C:\Users\Nikolai\Documents\lib\bukkit\1.8.0\craftbukkit.jar" -DgroupId=org.bukkit -DartifactId=craftbukkit -Dversion=1.8.0-R0.1 -Dpackaging=jar -DcreateChecksum=true
    Just substitute the above example file locations with the correct location on your system. Also, this assumes that you have Maven installed. If not, install it.

    Then, your pom.xml would look something like this:
    pom.xml (open)

    HTML:
    <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>mc.euro</groupId>
        <artifactId>demolition</artifactId>
        <version>1.2.1</version>
        <packaging>jar</packaging>
        <name>Demolition</name>
        <properties>
            <maven.build.timestamp.format>MMdd</maven.build.timestamp.format>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        </properties>
        <url>http://dev.bukkit.org/bukkit-plugins/bombarena/</url>
        <!-- Locations for jar repositories -->
        <repositories>
            <repository>
                <id>rainbowcraft-repo</id>
                <url>http://23.29.127.102/maven/repository/</url>
            </repository>
            <repository>
                <id>bukkit-repo</id>
                <url>http://repo.bukkit.org/content/groups/public</url>
            </repository>
            <repository>
                <id>md_5-snapshots</id>
                <url>http://repo.md-5.net/content/repositories/snapshots/</url>
            </repository>
            <repository>
                <id>sk89q-repo</id>
                <url>http://maven.sk89q.com/repo/</url>
            </repository>
            <repository>
                <id>vault-repo</id>
                <url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
            </repository>
            <repository>
                <id>kitteh-repo</id>
                <url>http://repo.kitteh.org/content/repositories/public/</url>
            </repository>
            <repository>
                <id>hawk-repo</id>
                <url>http://ci.hawkfalcon.com/plugin/repository/everything/</url>
            </repository>
        </repositories>
        <!-- Dependencies -->
        <dependencies>
            <!-- Dependencies that have maven repos -->
            <dependency>
                <groupId>org.bukkit</groupId>
                <artifactId>bukkit</artifactId>
                <version>1.7.2-R0.3</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>mc.alk</groupId>
                <artifactId>BattleArena</artifactId>
                <version>3.9.9.12</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>mc.alk</groupId>
                <artifactId>BattleTracker</artifactId>
                <version>2.5.8.8</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.gmail.filoghost</groupId>
                <artifactId>holograms</artifactId>
                <version>1.8.5</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.dsh105</groupId>
                <artifactId>HoloAPI</artifactId>
                <version>1.2.3</version>
            </dependency>
            <dependency>
                <groupId>unknown.plugins</groupId>
                <artifactId>EnjinMinecraftPlugin</artifactId>
                <version>2.6.8</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>mc.euro</groupId>
                <artifactId>Version</artifactId>
                <version>1.1.1</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>3.8.1</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
        <!-- How we will compile the plugin -->
        <build>
            <finalName>BombArena</finalName>
            <extensions>
                <extension>
                    <groupId>org.apache.maven.wagon</groupId>
                    <artifactId>wagon-ssh</artifactId>
                    <version>2.4</version>
                </extension>
            </extensions>
            <defaultGoal>package</defaultGoal>
            <!-- Where our source directory is -->
            <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
            <testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
            <!-- Include all the resources we need -->
            <resources>
                <resource>
                    <targetPath>.</targetPath>
                    <filtering>true</filtering>
                    <directory>${basedir}/src/main/java</directory>
                    <includes>
                        <include>*.yml</include>
                    </includes>
                </resource>
            </resources>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>1.6</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <!-- Shade (includes these in the final jar) -->
                            <goals>
                                <goal>shade</goal>
                            </goals>
                            <configuration>
                                <relocations>
                                    <relocation>
                                        <pattern>mc.euro.version</pattern>
                                        <shadedPattern>${project.groupId}.${project.artifactId}.version</shadedPattern>
                                    </relocation>
                                </relocations>
    
                                <artifactSet>
                                    <includes>
                                        <include>mc.euro:Version</include>
                                    </includes>
                                </artifactSet>
                                <!-- Specify to remove all unneeded classes -->
                                <minimizeJar>true</minimizeJar>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <!-- Specify how we build the plugin.jar -->
                <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <configuration>
                    <tasks>
                        <copy file="target/BombArena.jar" tofile="../server/plugins/BombArena.jar"/>
                    </tasks>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            </plugins>
        </build>
        <distributionManagement>
          <repository>
            <id>rainbowcraft-repo</id>
            <url>scp://23.29.127.102/var/www/maven/repository</url>
          </repository>
        </distributionManagement>
    </project>
    

    A couple of things to note: I'm using Bukkit v1.7.2-R0.3 because my plugin does not need to persist player data beyond a server reset. So if your plugin does need to save player data, then use one of the Bukkit versions that has UUID support.

    Next, take a step back and consider if you really need to use Bukkit v1.7.10 ? For the most part, you can use ANY of the older versions and your plugin will work on a newer Craftbukkit (with a few exceptions: like if you use Bukkit.getOnlinePlayers() ). So... you can build your plugin with the Bukkit API for 1.7.9 and it will work on a Craftbukkit server using 1.7.10

    In other words: Just because your server is running Craftbukkit 1.7.10 does not mean that you have to build your plugin with Bukkit 1.7.10

    Is there a specific API method that you want to use in 1.7.10 ?

    And finally, just to inject my opinion here... But i think the plugin tutorial should have put the Maven instructions at the end for advanced users with a short FAQ of what are some common reasons to use Maven. The Create a Project section makes it seem like that's the only way you can setup your project. It should specify the alternatives: "You can create a Java Project or Maven Project. The instructions below are for a simple Java Project. Want to use Maven ? (click-here)"
     
Thread Status:
Not open for further replies.

Share This Page