Skip to content
Loving11ish edited this page Jun 10, 2024 · 1 revision

API Implementation

Current API Version:

Adding EpicHomes To Your Project

To start, you're going to want to add EpicHomes as a dependency or soft dependancy to your project. While you could download the jar file and add it as a classpath dependency, we highly recommend using a build system such as Maven or Gradle.

Using Maven

  • Repository
	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>
  • Dependency
	<dependency>
	    <groupId>com.github.CraptiCraft-Development</groupId>
	    <artifactId>EpicHomes</artifactId>
	    <version>[CURRENT-VERSION]</version>
            <scope>provided</scope>
	</dependency>

Using Gradle

  • build.gralde
	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}
  • Dependency
	dependencies {
	        implementation 'com.github.CraptiCraft-Development:EpicHomes:[CURRENT-VERSION]'
	}

Getting The API Instance

Once you have added the API to your project, you can start interfacing with it.
EpicHomes API methods are located at: me.loving11ish.epichomes.api.EpicHomesAPI. All of the available methods are static so the API class does NOT need to be instantiated before using the methods.

For example using the Bukkit PlayerJoinEvent:

package me.loving11ish.epichomesapidemo.listeners;

import me.loving11ish.epichomes.api.EpicHomesAPI;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerJoinEvent;

public class PlayerConnectionEvent implements Listener {

    @EventHandler
    public void onConnection(PlayerJoinEvent event) {
        // Get the player that joined
        Player player = event.getPlayer();

        // Check if the EpicHomes plugin is enabled
        if (!EpicHomesAPI.isPluginEnabled()) {
            return;
        }

        // Check if the player is already registered in the EpicHomes plugin
        if (EpicHomesAPI.getUserByBukkitPlayer(player) == null) {
            return;
        }
        
        // Create a new home for the player
        if (EpicHomesAPI.addNewHomeToUser(EpicHomesAPI.getUserByBukkitPlayer(player), "home", player.getLocation())) {
            // Tell the player that the home was created
            player.sendMessage("Home created!");
        } else {
            // Tell the player that the home creation failed
            player.sendMessage("Failed to create home!");
        }
    }
}

Home Page

Click Here

Clone this wiki locally