Skip to content

Getting Started

BlackyPaw edited this page Dec 9, 2016 · 2 revisions

Ready to integrate I18N into your next project? Great, let's start right ahead then!

Depending on the IDE you are working with, the following steps will differ a little. Still, all of them should be repeatable by looking up where to find the mentioned functionality in your respective IDE.

Before we begin I would like to point out what is meant by the following terms you will find throughout this and the following guides:

  • API - The general interface you - as a developer - will be making use of to access the functions provided by I18N
  • Platform Adapter - Due to the fact that different platforms such as BungeeCord or Spigot handle certain things such as networking a little differently there is no general way to implement all of I18N functionality on all platforms in the same way. This is why each supported platform got its own Adapter which is basically nothing more than an implementation of I18N's API
  • Extensions - Extensions are cross-platform additions to I18N's API (e.g. additional implementations of the TranslationStorage class) which require additional dependencies that are not bundled with the bare API in order to keep it small in size

First of all, as of version 1.0.0 I18N is separated into three major components namely its API, platform adapters and extensions. All projects using I18N - no matter the platform - can make use of I18N's API. The only difference between each platform is the way you gain access to the API. The central entrypoint for all of I18N's functions is the I18N interface found inside the com.blackypaw.mc.i18n package. In order to get an instance of said interface you must query the respective platform adapter for the platform you are developing on. Essentially this boils down to adding one dependency when developing for Spigot and another when developing for BungeeCord. Depending on whether you use Maven as your build-system or not you should follow the respective sections below for grabbing the correct dependencies to add to your project.

For Maven Users

If you are using Maven or another similar build-system such as Gradle you can grab all current and previous releases of I18N from a custom repository. The procedure of doing so in Maven will be outlined below - you should be able to repeat this steps for your respective build-system as well.

First off you will want to add the following repository to your <repositories> list inside your pom.xml:

<repositories>
    <repository>
        <id>blackypaw-repo</id>
        <name>BlackyPaw Public Repository</name>
        <url>http://repo.blackypaw.com/content/groups/public/</url>
    </repository>
</repositories>

After you have done so, just import the latest version or the version you require of the platform adapter you need (i18n-spigot for Spigot development, i18n-bungeecord for BungeeCord development). Make sure to set the <scope> property of the dependency to provided so that other plugins such as Maven's shade plugin will not copy the entire adapter into your custom plugin .JAR-file. Doing so could easily screw up your user's installation and is therefore to be prevented.

<dependencies>
    <dependency>
        <dependency>
            <groupId>com.blackypaw.mc</groupId>
            <artifactId>i18n-spigot</artifactId>
            <version>1.3.0</version>
            <!-- Do NOT include adapter in Uber jar created by Maven -->
            <scope>provided</scope>
        </dependency>
    </dependency>
</dependencies>

That's it already! Due to the fact that the adapter includes I18N's API you do not need to import it manually unless you are developing your own platform adapter.

For Non-Maven Users

If you are not using Maven as your build-system you will have to manually download the .JAR-file of the platform adapter you would like to import. Download your required version of i18n-bungeecord when developing a BungeeCord plugin or of i18n-spigot when developing a regular Spigot/Bukkit plugin. After that, just add the according .JAR-file to your project's Build-/Classpath and you should be ready to take off! Please ensure, that you do not copy the contents of the downloaded .JAR-file into your plugin's own .JAR-file as doing so might screw up your user's installation completely.