Skip to content

Installation

Amaury Carrade edited this page May 16, 2016 · 7 revisions

You'll need approximately two minutes to integrate the zLibrary inside your plugin, if you are using Maven already.

Currently, the zLib requires Java 7 or later, Bukkit 1.8.3 or later. This document explains how to install the zLib if you are using Maven, but it works too with other system, as long as a shading-like feature is present.
 

Integration of the library files inside your plugin

  1. Add our Maven repository to your pom.xml file.

        <repository>
            <id>zDevelopers</id>
            <url>http://maven.carrade.eu/artifactory/snapshots</url>
        </repository>
  2. Add the zLib as a dependency.

        <dependency>
            <groupId>fr.zcraft</groupId>
            <artifactId>zlib</artifactId>
            <version>0.99-SNAPSHOT</version>
        </dependency>
  3. Add the shading plugin to the build. Replace YOUR.OWN.PACKAGE with your own package.

         <build>
             ...
             <plugins>
                 ...
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-shade-plugin</artifactId>
                     <version>2.3</version>
                     <configuration>
                         <artifactSet>
                             <includes>
                                 <include>fr.zcraft:zlib</include>
                             </includes>
                         </artifactSet>
                         <relocations>
                             <relocation>
                                 <pattern>fr.zcraft.zlib</pattern>
                                 <shadedPattern>YOUR.OWN.PACKAGE</shadedPattern>
                             </relocation>
                         </relocations>
                     </configuration>
                     <executions>
                         <execution>
                             <phase>package</phase>
                             <goals>
                                 <goal>shade</goal>
                             </goals>
                         </execution>
                     </executions>
                 </plugin>
                 ...
             </plugins>
             ...
         </build>
  4. Build your project as usual, as example with the following command from your working directory, or using an integrated tool from your IDE.

    mvn clean install

 

Library & components auto-loading

Currently, there is only one simple way to integrate this library. The zLib provides his own version of the JavaPlugin main class, to semi-automatically load and unload the zLib components and core.

  1. In your main class, replace extends JavaPlugin with extends ZPlugin (in fr.zcraft.zlib.core.ZPlugin).

    import fr.zcraft.zlib.core.ZPlugin;
    
    public class Toaster extends ZPlugin
    {
        // ...
    }
  2. Use inside onEnable() the loadComponents method to load the components you will use.

    @Override
    public void onEnable()
    {
        loadComponents(Gui.class, Commands.class, SidebarScoreboard.class);
    }

 

A note about overridden methods

The zLibrary overrides the onLoad method.
If your plugin uses it you have to call super.onLoad() like this.

@Override
public void onLoad()
{
    super.onLoad();
    // Your code, placed after.
}
Clone this wiki locally