TrueCompanies Docs

🖥️TrueCompanies API Documentation

Introduction

Welcome to the TrueCompanies API Documentation. This comprehensive guide is tailored for developers seeking to integrate, expand, or customize the core functionalities of the TrueCompanies plugin. Dive in to understand how you can harness our API to build a richer Minecraft corporate experience!


API Basics

The CompanyAPI class serves as the main entry point to perform operations related to companies, employees, and groups.

package it.mikeslab.truecompanies.api;

Initialization

To instantiate the API with default dependencies:

CompanyAPI api = CompanyAPI.createDefaultAPI();

Key Methods & Descriptions

1. Firing an Employee

void fireEmployee(Company company, String employeeUsername);

Fires a specified employee from a given company.

2. Hiring an Employee

void hireEmployee(Company company, String employeeUsername, int group);

Hires a specific player into a company, assigning them to a designated group/role.

3. Changing an Employee's Group/Role

void changeEmployeeGroup(Company company, String employeeUsername, int newGroup);

Alters the role or group of an existing employee within a company.

4. Transferring Company Ownership

void transferCompanyOwnership(Company company, Player newOwner, Player oldOwner);

Facilitates the transfer of a company's ownership from the current owner to a new individual.

5. Updating Company Balance

void updateBalance(Company company, double amount);

Modifies the balance of a specified company by the provided amount.

6. Updating Group Permissions

void updateGroupPermissions(Company company, Group group);

Adjusts the permissions associated with a particular group within a company.

7. Retrieving a Company by ID

Company getCompany(String companyID);

Fetches a Company object based on its unique identifier.

Events

Events are critical touchpoints allowing developers to inject custom behaviors during specific occurrences. TrueCompanies offers events like CompanyFireEvent and CompanyHireEvent to enable this.

Example - Listening to a Hiring Event

@EventHandler
public void onCompanyHire(CompanyHireEvent event) {
    Player hiredPlayer = event.getSelectedPlayer();
    Company company = event.getCompany();
    
    // Add custom behaviors or actions here.
}

Last updated