API

King of the Hill has an extensive API that developers may use to their pleasure to create add-ons for the plugin. The Github Repository offers extensive documentation for most methods in the plugin.

Note that maven integration is only available for KotH v1.3 and later

Getting Started

To get started, you will have to use King of the Hill as a dependency. There are two methods of accomplishing this task.

Adding KotH as a dependency

  • Recommended: Adding KotH via maven dependency -
    • In your pom.xml file, add the following repository code along with your Bukkit repository.
<repository>
	<id>koth-repo</id>
	<url>https://dl.bintray.com/aohruthless/maven/</url>
</repository>

Now add KotH as a dependency along with your Bukkit dependency.

<dependency>
	<groupId>com.valygard.KotH</groupId>
	<artifactId>KotH</artifactId>
	<version>1.3</version> <!-- Must be v1.3 or later -->
	<type>jar</type>
	<scope>provided</scope>
	<optional>false</optional>
</dependency>
  • Method 2: Adding KotH as a hard-dependency (all versions) -
    • Download the file of your choice.
    • Go into your IDE > Right-Click project > Find 'Build Path' > Find 'Configure Build Path' > 'Libraries' tab > 'Add External Jar' > Find your downloaded KotH.jar

Please make sure you depend or soft-depend to ensure your plugin is loaded after King of the Hill.

Defining your KotH instance

In your main class, you must define your KotH plugin instance.

public class YourMainClass extends JavaPlugin {

    private KotH plugin; // KotH.java is the main class of King of the Hill.
    
    @Override
    public void onEnable() {
        plugin = (KotH) getServer().getPluginManager().getPlugin("KotH");
    }
    
    // Getter
    public KotH getKotHPlugin() {
        return plugin;
    }

}

Arenas

Once you retrieve the main plugin instance, you can call the getter function

koth.getArenaManager()

to retrieve the instance of the class that handles all the arenas. Please note that all existing and enabled arenas will have been loaded at this point in time, provided that the world has also been loaded. From there, you can use

koth.getArenaManager().getArenas()

to retrieve a List of all loaded arenas.

Custom Events

There are several custom events you may listen to, and you can find them all here. Several of them are cancellable, and all of them offer distinct methods as well as access to a certain arena, for all of them are ArenaEvents. You listen to them as you would any Bukkit Event.

Abilities

Adding your own abilities is simple and easy. For the sake of this tutorial, we are attempting to create an ability in which if the player clicks a piece of dirt in their inventory, they die.

/**
* Note that there are defaults for both of the following annotations
*/
@AbilityPermission("koth.abilities.dirt") // the permission for your custom ability
@AbilityCooldown(5) // the cooldown for your ability in seconds
public class DirtAbility extends Ability implements Listener { // extend the ability super
   
    public DirtAbility(Arena arena, Player player) {
        super(arena, player, Material.DIRT); // the super constructor initializes the arena and player for you, and selects the material type for your ability.
        Bukkit.getPluginManager(registerEvents(this, arena.getPlugin());
    }

    // do everything for your ability in this class
    @EventHandler
    public void onPlayerClickedTheirDirt(PlayerInteractEvent event) {
        // check if player is holding the material, kill them.
    }
}