Skip to content
sqlongithub edited this page Apr 30, 2021 · 33 revisions

Maven

First things first, add the repository and the dependency to your pom.xml

while obviously having the platform's repositories and dependencies ready.

such as Bukkit/Spigot, Paper, Sponge, BungeeCord, or JDA

** WARNING: Do not skip the section below this!! **

<repositories>
    <repository>
        <id>aikar</id>
        <url>https://repo.aikar.co/content/groups/aikar/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>co.aikar</groupId>
        <artifactId>acf-[PLATFORM]</artifactId> <!-- Don't forget to replace this -->
        <version>[VERSION]</version> <!-- Replace this as well -->
        <!-- Example Platform/Version
        <artifactId>acf-paper</artifactId>
        <version>0.5.0-SNAPSHOT</version>
		-->
    </dependency>
</dependencies>

Replace [PLATFORM] and [VERSION] with the platform you're using and the latest version of acf, that can be found here.

You will also need to shade the library into your plugin .jar file.

    <build>
        <plugins>
            <plugin>
                <version>3.8.1</version>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArgs>
                        <arg>-parameters</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <configuration>
                    <dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
                    <relocations>
                        <relocation>
                            <pattern>co.aikar.commands</pattern>
                            <shadedPattern>[YOUR PLUGIN PACKAGE].acf</shadedPattern> <!-- Replace this -->
                        </relocation>
                        <relocation>
                            <pattern>co.aikar.locales</pattern>
                            <shadedPattern>[YOUR PLUGIN PACKAGE].locales</shadedPattern> <!-- Replace this -->
                        </relocation>
                    </relocations>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

Replace [YOUR PLUGIN PACKAGE] with a package to your plugin so that ACF is relocated to it.

Enabling -parameters on the compiler lets ACF automatically generate Syntax messages for you, using the parameter names. If you don't set this, the syntax messages will use confusing names.

Kotlin

For Kotlin projects you will also need to include this to pass -parameters onto the Kotlin compiler:

<configuration>
    <jvmTarget>1.8</jvmTarget>
    <javaParameters>true</javaParameters>
</configuration>