PvpBotdocs
Reference

Add-on API

For plugin developers: teach bots to use your own gear and ways of getting about.

An add-on API, BotAddons, lets another plugin teach bots to use its own gear and ways of getting about: guns, grenades, medical items, special armour, a lift or a launcher. With no add-on installed nothing changes.

Hooks

An add-on implements BotAddon (every hook defaults to "not mine") and is asked at fixed points in every bot's tick:

HookWhen
overrideRight after the target is chosen, ahead of eating, pearls and retreats.
fightWith a target, ahead of every built-in attack. Returning false falls through to PvpBot's own play.
idleWith no target, ahead of guarding, escorting and wandering.
routeWhenever a bot walks somewhere, ahead of its own pathfinding: a transport the add-on runs.
blocksSightWhenever a bot looks for a target: something only the add-on knows about (a smoke cloud) can hide a player.

holdsHand, reserved and armourScore keep PvpBot's own auto-equip, hotbar sorting, bow code and armour picker out of the add-on's way. Add-ons are asked in the order they registered, the first to claim something has it, and a plugin's add-ons are dropped when it is disabled. The hooks run on the main thread for every bot every tick, so keep them cheap.

Example

BotAddons.register(plugin, new BotAddon() {
    @Override
    public boolean fight(Player bot, Entity target, BotSettings settings) {
        return false;   // fight with your gear, or hand the tick back
    }
});