# cancelling events

```csharp
event.cancel()
```

call this to stop the action from happening. for example, preventing players from breaking a block

### it only does something on cancellable events

not every event can be cancelled. `event.cancel()` is always safe to call, it just quietly returns `false` and does nothing if the event doesn't support cancellation (for example, `player_join`/`player_quit`

events that **do** support cancellation include interactions, block break/place, and item drop/pickup

### example: disable breaking certain blocks

```csharp
@Katton.listen("block_break")
function protectSpawn(event) {
    if (event.block.type == "glass") {
        event.player.sendMessage("&cyou can't break that!")
        event.cancel()
    }
}
```

### checking the return value

if you want to know whether the cancel actually took effect (useful mostly for debugging):

```csharp
val wasCancelled = event.cancel()
if (!wasCancelled) {
    Katton.log.warn("tried to cancel a noncancellable event")
}
```
