Skip to content

Installation

Amaury Carrade edited this page Dec 30, 2015 · 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 JavaPlugn 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);

  2. use inside onEnable() the loadComponents method to load the components you will use. Example:

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

A note about overriden methods
The zLibrary overrides the onLoad and onDisable methods. If your plugin use them, you have to call super.onLoad() at the beginning of onLoad, and super.onDisable() at the end of onDisable().

Clone this wiki locally