> For the complete documentation index, see [llms.txt](https://edseries-plugins.gitbook.io/p/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://edseries-plugins.gitbook.io/p/edmobswords/api/events.md).

# Events

All events live in `es.edwardbelt.edmobswords.iapi.event`.

#### `SwordHitEvent`

Fired before a sword hit (a player swing or an enchant's hit) is applied to a mob, both zone mobs and real server mobs. Usually **asynchronous** — check `isAsynchronous()` before touching Bukkit state. A player's own swing on a real server mob fires it synchronously; cancelling it cancels the damage.

* `Player getPlayer()`
* `SwordTarget getTarget()`
* `double getDamage()` / `setDamage(double)` — change the damage that lands
* `String getEnchantSource()` — the enchant the hit belongs to, or `null` for the player's own swing (`isPlayerSwing()`)
* `isCancelled()` / `setCancelled(boolean)` — a cancelled hit does nothing

```java
@EventHandler
public void onHit(SwordHitEvent event) {
    if (event.isPlayerSwing() && event.getPlayer().hasPermission("vip")) {
        event.setDamage(event.getDamage() * 1.25);
    }
}
```

#### `SwordKillEvent`

Fired right after a sword hit killed a zone mob, before its rewards are paid. Usually asynchronous. Real server mobs fire Bukkit's `EntityDeathEvent` instead.

* `Player getPlayer()`, `SwordTarget getTarget()`, `String getEnchantSource()`

#### `MobSpawnEvent`

Fired (asynchronously) when a packet mob has been spawned in a zone — first spawn or respawn.

* `String getZoneId()`, `SwordTarget getMob()`
* `boolean isShared()` — the mob belongs to a global-session population
* `Player getTrigger()` — the player whose join or kill caused the spawn (its health placeholders were resolved for them), may be `null`

#### `MobZoneJoinEvent`

Fired on the main thread when a player's mob session starts (their mobs spawn right after).

* `Player getPlayer()`, `String getZoneId()`, `boolean isShared()`

#### `MobZoneLeaveEvent`

Fired when a player's mob session ends (left the zone, switched session type, quit). May be asynchronous; `getPlayer()` may be `null` after a quit.

* `UUID getUuid()`, `Player getPlayer()`, `String getZoneId()`
