# API

To include the LanguageAPI in your project, you can put the .jar file in the folder `recources` of your project and make this entry in the `pom.xml` under the dependencies:

{% code title="pom.xml" lineNumbers="true" %}

```xml
<dependency>
    <groupId>de.herrtechniker</groupId>
    <artifactId>LanguageAPI</artifactId>
    <version>1.0-SNAPSHOT</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/src/main/resources/LanguageAPI-1.0.0-SNAPSHOT-OBF.jar</systemPath>
</dependency>
```

{% endcode %}

Or for the BungeeCord version:

{% code title="pom.xml" lineNumbers="true" %}

```xml
<dependency>
    <groupId>de.herrtechniker</groupId>
    <artifactId>LanguageAPI</artifactId>
    <version>1.0-SNAPSHOT</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/src/main/resources/LanguageAPI-Bungee-1.0.0-SNAPSHOT-OBF.jar</systemPath>
</dependency>
```

{% endcode %}

## LanguageAPI

To see if the player is already registered in the database, you can check it with the following query.

```java
LanguageAPI().getApi().isPlayerEntryExists(UUID uuid); // return boolean
```

To get the language of the player, you can query the following.

```java
LanguageAPI().getApi().getPlayerLanguage(UUID uuid); // return String
```

To set the player's language, do the following.

```java
LanguageAPI().getApi().setPlayerLanguage(UUID uuid, String language);
```

To change the language, you can simply do the following.

```java
LanguageAPI().getApi().changePlayerLanguage(UUID uuid, String language);
```

To add a language that you want your server network to support, you can do the following.

```java
LanguageAPI().getApi().addSupportedLanguage(String language);
```

Of course, you can also remove a language that you have supported and no longer want to support. To do this, simply execute the following.

```java
LanguageAPI().getApi().removeSupportedLanguage(String language);
```

To see if the language is already supported, you can do the following.

```java
LanguageAPI().getApi().isLanguageSupported(String language); // return boolean
```

To get all supported languages in one list, simply execute the following

```java
LanguageAPI().getApi().getAllSupportedLanguage(); // return List<String>
```

To see if the default language is set, do the following.

```java
LanguageAPI().getApi().isDefaultLanguageSet(); // return boolean
```

To set the default language do the following.

```java
LanguageAPI().getApi().setDefaultLanguage(String defaultLanguage);
```

To get the default language, perform the following.

```java
LanguageAPI().getApi().getDefaultLanguage(); // return String
```

To change the default language, do the following.

```java
LanguageAPI().getApi().changeDefaultLanguage(String defaultLanguage);
```

To see if the LanguageAPI is running in the `multi-file system`, run the following.

```java
LanguageAPI().getApi().isMultiFile(); // return boolean
```

To get a message from the file from the `single-file system`, do the following.

```java
LanguageAPI().getApi().getSingleFileMessage(String language, String path); // return String
```

To get a message from a file when `multi-file system` is enabled, do the following. Pass the name of the file as `fileName`.

```java
LanguageAPI().getApi().getMultiFileMessage(String fileName, String language, String path); // return String
```

## Namefetcher

{% hint style="info" %}
The Namefetcher is a "module" which stores the name and the corresponding UUID of the player.
{% endhint %}

To check if a player's entry already exists, do the following.

```java
LanguageAPI().getApi().isNamefetcherEntryExists(UUID uuid); // return boolean
```

To check if a player's entry already exists, do the following.

```java
LanguageAPI().getApi().isNamefetcherEntryExists(String name); // return boolean
```

To enter an entry in the Namefetcher for a player, do the following.

{% hint style="warning" %}
Make sure that there is only one entry per player, if possible.
{% endhint %}

```java
LanguageAPI().getApi().setNamefetcher(UUID uuid, String name);
```

To change a player's entry, for example if the player has changed his name, do the following.

```java
LanguageAPI().getApi().changeNamefetcher(UUID uuid, String name);
```

To get the name of a player by UUID, do the following.

```java
LanguageAPI().getApi().getName(UUID uuid); // return String
```

To get the UUID of a player by name, do the following.

{% code fullWidth="false" %}

```java
LanguageAPI().getApi().getUUID(String name); // return UUID
```

{% endcode %}
