Installation
Repository
- Maven
- Gradle (Groovy DSL)
- Gradle (Kotlin DSL)
<repository>
<id>JodexIndustries</id>
<name>JodexIndustries Repo</name>
<url>https://repo.jodex.xyz/releases</url>
</repository>
repositories {
maven { url = 'https://repo.jodex.xyz/releases' }
}
repositories {
maven("https://repo.jodex.xyz/releases")
}
Installation and Usage
Snippets are available for Maven, Gradle Groovy, and Gradle Kotlin DSL.
There are two ways to use the library depending on your project structure:
1. Using as a standalone plugin (api
module)
- JGuiWrapper is installed as a separate plugin on the server.
- Your plugin simply connects to its API without shading.
- Maven
- Gradle (Groovy DSL)
- Gradle (Kotlin DSL)
<dependency>
<groupId>com.jodexindustries.jguiwrapper</groupId>
<artifactId>api</artifactId>
<version>loading</version>
<scope>provided</scope>
</dependency>
dependencies {
compileOnly("com.jodexindustries.jguiwrapper:api:loading")
}
dependencies {
compileOnly("com.jodexindustries.jguiwrapper:api:loading")
}
2. Embedding into your project (common
module)
- You directly include the library and shade it into the final jar using
shade
(orshadowJar
). - No need to install JGuiWrapper as a separate plugin.
- Maven
- Gradle (Groovy DSL)
- Gradle (Kotlin DSL)
<dependency>
<groupId>com.jodexindustries.jguiwrapper</groupId>
<artifactId>common</artifactId>
<version>loading</version>
<scope>compile</scope>
</dependency>
If you want to include nms logic for title management
<dependency>
<groupId>com.jodexindustries.jguiwrapper</groupId>
<artifactId>nms</artifactId>
<version>loading</version>
<scope>compile</scope>
</dependency>
dependencies {
implementation("com.jodexindustries.jguiwrapper:common:loading")
}
If you want to include nms logic for title management
dependencies {
implementation("com.jodexindustries.jguiwrapper:nms:loading")
}
dependencies {
implementation("com.jodexindustries.jguiwrapper:common:loading")
}
If you want to include nms logic for title management
dependencies {
implementation("com.jodexindustries.jguiwrapper:nms:loading")
}
General Initialization
Using the library without the standalone JGuiWrapper plugin requires you to initialize the listeners in your main plugin class.
@Override
public void onEnable() {
JGuiInitializer.init(this); // registers all listeners
}
After calling init
, you can create and open GUIs for any player.
API
Publicly available API methods can be found in the GuiApi class,
which is the parent class of JGuiInitializer
.
GuiApi api = GuiApi.get();
It should be noted that GuiApi#get()
may throw an initialization error, as JGuiInitializer#init(Plugin)
was not called, which means that the API was not initialized.
Secure access to the API
Sometimes it happens that initialization can be called later than certain logic with interaction with GuiApi, so it is worth using GuiApi#getOptional()
GuiApi.getOptional().ifPresent(api -> {
Plugin plugin = api.getPlugin();
});