Skip to content
Justin_SGD edited this page May 21, 2025 · 9 revisions

JuByteCaseAPI Installation

To use the JuByteCaseAPI in your project, you can add it as a dependency in your pom.xml or build.gradle file.

Maven

Add the following repository and dependency to your pom.xml file:

<repositories>
     <repository>
      <id>jubyte</id>
      <name>JuByte</name>
      <url>https://repo.jubyte.com/artifactory/jubyte/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.jubyte.caseopening</groupId>
        <artifactId>JuByteCaseApi</artifactId>
        <version>1.9.2-RELEASE</version>
    </dependency>
</dependencies>

Gradle

Add the following repository and dependency to your build.gradle file:

repositories {
    maven {
        url 'https://repo.jubyte.com/artifactory/jubyte/'
    }
}

dependencies {
    implementation 'com.jubyte.caseopening:JuByteCaseApi:1.9.2-RELEASE'
}

After adding the dependency, you can use the classes and methods provided by the JuByteCaseAPI in your project.

Registering JuByteCaseAPI in your Plugin

To use the JuByteCaseAPI in your plugin, you need to first add the API as a dependency to your project, as explained in the previous answer. Then, you can register the API in your plugin by calling the getInstance() method and storing the returned instance in a variable:

CaseAPI api = CaseAPI.getInstance();

Once you have an instance of the API, you can use it to get instances of the CasePlayerAPI and CaseLogAPI interfaces, which allow you to manage player cases and their logs, respectively:

CasePlayerAPI playerApi = api.getCasePlayerApi();
CaseLogAPI logApi = api.getCaseLogApi();

With these interfaces, you can interact with the case opening system and access player data and case opening logs.


Note that to use the API, you need to have JuByteCase plugin installed on your server, since the API interacts with the plugin's database.

To use the JuByteCaseAPI in your plugin, you need to first import the necessary classes:

```java
import com.jubyte.caseopening.api.CaseAPI;
import com.jubyte.caseopening.api.log.CaseLogAPI;
import com.jubyte.caseopening.api.player.CasePlayerAPI;

import java.util.UUID;

Then, you can get an instance of the CaseAPI interface, which is the entry point to the API:

CaseAPI caseAPI = CaseAPI.getInstance();

From there, you can use the getCasePlayerApi() and getCaseLogApi() methods to get instances of the CasePlayerAPI and CaseLogAPI interfaces, respectively:

CasePlayerAPI casePlayerAPI = caseAPI.getCasePlayerApi();
CaseLogAPI caseLogAPI = caseAPI.getCaseLogApi();

Usage JuByteCaseAPI

To interact with player cases, you can use methods such as getCaseAmount(), setCaseAmount(), addCaseAmount(), and removeCaseAmount() from the CasePlayerAPI interface:

UUID playerUUID = UUID.randomUUID();
String caseName = "my_case";

// Get the amount of cases the player has for a specific case
int amount = casePlayerAPI.getCaseAmount(playerUUID, caseName);

// Set the amount of cases the player has for a specific case
casePlayerAPI.setCaseAmount(playerUUID, 10, caseName);

// Add cases to the player's inventory for a specific case
casePlayerAPI.addCaseAmount(playerUUID, 5, caseName);

// Remove cases from the player's inventory for a specific case
casePlayerAPI.removeCaseAmount(playerUUID, 3, caseName);

To interact with case opening logs, you can use methods such as getCaseLog() from the CaseLogAPI interface:

// Get the case log for a specific player
caseLogAPI.getCaseLog(playerUUID);

// Get the case log for a specific player and case name
caseLogAPI.getCaseLog(playerUUID, caseName);

These methods allow you to interact with the JuByteCaseAPI and manage player cases and logs within your plugin.

Clone this wiki locally