> For the complete documentation index, see [llms.txt](https://plugins-1.gitbook.io/plugins/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://plugins-1.gitbook.io/plugins/apis/lib/general/plugin-hooks.md).

# Plugin Hooks

Often hooking into plugins requires repetitive code and methods may not always be the same, we've implemented an easy system for fast plugin hooking.

## 1. Create your Hook Class.

```java
public class TestHook extends Hook {

    @Override
    public String getPlugin() {
        return "SomePlugin";
    }

    @Override
    public void onEnable() {
        Bukkit.getLogger().info("Woo, hooking into SomePlugin!");
    }
}
```

Where "**SomePlugin**" is the plugin you wish to hook into, and onEnable is the method that gets called if the plugin is installed on the server.

## 2. Add to Plugin.yml.

Sadly it's not possible to modify a plugin via code for this, so you'll need to go to your plugin.yml and either set it to`softdepend: ["SomePlugin"]` meaning the plugin isn't required, but it's an option (usually what hooks do) or `depend: ["SomePlugin"]` which tells Bukkit that this plugin is required.

That easy!
