====== Hooks ======

A plugin can register to be called whenever an "interesting event" occurs. It does so by calling cPluginManager's AddHook() function and implementing a callback function with your desired name to handle the event. Note that MCServer checks the function's presence when adding the hook, emitting a warning message when the callback function doesn't exist.

A plugin can decide whether it will let the event pass through to the rest of the plugins, or hide it from them. This is determined by the return value from the hook callback function. If the function returns false or no value, the event is propagated further. If the function returns true, the processing is stopped, no other plugin receives the notification (and possibly MCServer disables the default behavior for the event). See each hook's details to see the exact behavior.

===== Hook types =====
^ Hook Name ^ Called when ^
| [[API:Plugin:OnBlockToPickups|HOOK_BLOCK_TO_PICKUPS]] | A block is about to be dug (player, entity or natural reason), plugins may override what pickups that will produce. |
| [[API:Plugin:OnChat|HOOK_CHAT]] | Player sends a message to chat |
| [[API:Plugin:OnChunkAvailable|HOOK_CHUNK_AVAILABLE]] | A chunk has just been added to world, either generated or loaded. |
| [[API:Plugin:OnChunkGenerated|HOOK_CHUNK_GENERATED]]  | After a chunk was generated. Notification only. |
| [[API:Plugin:OnChunkGenerating|HOOK_CHUNK_GENERATING]]  | A chunk is about to be generated. Plugin can override built-in generator. |
| [[API:Plugin:OnChunkUnloaded|HOOK_CHUNK_UNLOADED]] | A chunk has been unloaded from the memory. |
| [[API:Plugin:OnChunkUnloading|HOOK_CHUNK_UNLOADING]] | A chunk is about to be unloaded from the memory. Plugins may refuse the unload. |
| [[API:Plugin:OnCollectingPickup|HOOK_COLLECTING_PICKUP]] | Player is about to collect a pickup. Plugin can refuse / override behavior. |
| [[API:Plugin:OnCraftingNoRecipe|HOOK_CRAFTING_NO_RECIPE]] | No built-in crafting recipe is found. Plugin may provide a recipe. |
| [[API:Plugin:OnDisconnect|HOOK_DISCONNECT]] | A player has disconnected |
| [[API:Plugin:OnExecuteCommand|HOOK_EXECUTE_COMMAND]] | A player executes an in-game command, or the admin issues a console command. Note that built-in console commands are exempt to this hook - they are always performed and the hook is not called. |
| [[API:Plugin:OnHandshake|HOOK_HANDSHAKE]] | A client is connecting. |
| [[API:Plugin:OnHopperPullingItem|HOOK_HOPPER_PULLING_ITEM]] | A hopper is pulling an item from another block entity. |
| [[API:Plugin:OnHopperPushingItem|HOOK_HOPPER_PUSHING_ITEM]] | A hopper is pushing an item into another block entity. |
| [[API:Plugin:OnKilling|HOOK_KILLING]]  | A player or a mob is dying. |
| [[API:Plugin:OnLogin|HOOK_LOGIN]]  | Right after player authentication. If auth is disabled, right after the player sends their name. |
| [[API:Plugin:OnPlayerAnimation|HOOK_PLAYER_ANIMATION]] | A client has sent an Animation packet (0x12) |
| [[API:Plugin:OnPlayerBreakingBlock|HOOK_PLAYER_BREAKING_BLOCK]] | Just before a player breaks a block. Plugin may override / refuse. |
| [[API:Plugin:OnPlayerBrokenBlock|HOOK_PLAYER_BROKEN_BLOCK]] | After a player has broken a block. Notification only. |
| [[API:Plugin:OnPlayerEating|HOOK_PLAYER_EATING]] | When a player's client sends the STATUS_EATING packet. Subject to change! |
| [[API:Plugin:OnPlayerJoined|HOOK_PLAYER_JOINED]]  | After OnLogin() and before OnPlayerSpawned(), but before being added to world. |
| [[API:Plugin:OnPlayerLeftClick|HOOK_PLAYER_LEFT_CLICK]] | When a left-click packet is received from the client. Plugin may override / refuse. |
| [[API:Plugin:OnPlayerMoving|HOOK_PLAYER_MOVING]]  | Player tried to move in the tick being currently processed. Plugin may refuse movement. |
| [[API:Plugin:OnPlayerPlacedBlock|HOOK_PLAYER_PLACED_BLOCK]] | After a player has placed a block. Notification only. |
| [[API:Plugin:OnPlayerPlacingBlock|HOOK_PLAYER_PLACING_BLOCK]] | Just before a player places a block. Plugin may override / refuse. |
| [[API:Plugin:OnPlayerRightClick|HOOK_PLAYER_RIGHT_CLICK]] | When a right-click packet is received from the client. Plugin may override / refuse. |
| [[API:Plugin:OnPlayerShooting|HOOK_PLAYER_SHOOTING]] | When the client sends a STATUS_SHOOTING packet. Subject to change! |
| [[API:Plugin:OnPlayerSpawned|HOOK_PLAYER_SPAWNED]]  | After a player spawns in the world to which they belong to |
| [[API:Plugin:OnPlayerTossingItem|HOOK_PLAYER_TOSSING_ITEM]] | A player is tossing an item. Plugin may override / refuse. |
| [[API:Plugin:OnPlayerUsedBlock|HOOK_PLAYER_USED_BLOCK]] | A player has just used a block (chest, furnace...). Notification only. |
| [[API:Plugin:OnPlayerUsedItem|HOOK_PLAYER_USED_ITEM]] | A player has just used an entity (storage minecart...). Notification only. |
| [[API:Plugin:OnPlayerUsingBlock|HOOK_PLAYER_USING_BLOCK]] | Just before a player uses a block (chest, furnace...). Plugin may override / refuse. |
| [[API:Plugin:OnPlayerUsingItem|HOOK_PLAYER_USING_ITEM]] | Just before a player uses an entity (storage minecart...). Plugin may override / refuse. |
| [[API:Plugin:OnPostCrafting|HOOK_POST_CRAFTING]] | After the built-in recipes are checked and a recipe was found. |
| [[API:Plugin:OnPreCrafting|HOOK_PRE_CRAFTING]] | Before the built-in recipes are checked. |
| [[API:Plugin:OnSpawnedEntity|HOOK_SPAWNED_ENTITY]] | Before an entity is spawned in the world |
| [[API:Plugin:OnSpawnedMonster|HOOK_SPAWNED_MONSTER]] | Before a monster is spawned in the world |
| [[API:Plugin:OnSpawningEntity|HOOK_SPAWNING_ENTITY]] | After an entity is spawned in the world |
| [[API:Plugin:OnSpawningMonster|HOOK_SPAWNING_MONSTER]] | After a monster is spawned in the world |
| [[API:Plugin:OnTakeDamage|HOOK_TAKE_DAMAGE]]  | Player or mob take damage. |
| [[API:Plugin:OnTick|HOOK_TICK]] | Every server tick (approximately 20 times per second) |
| [[API:Plugin:OnUpdatedSign|HOOK_UPDATED_SIGN]] | After the sign text is updated. Notification only. |
| [[API:Plugin:OnUpdatingSign|HOOK_UPDATING_SIGN]] | Before the sign text is updated. Plugin may modify the text / refuse. |
| [[API:Plugin:OnWeatherChanged|HOOK_WEATHER_CHANGED]] | When the weather has changed. |
| [[API:Plugin:OnWorldTick|HOOK_WORLD_TICK]] | Every world tick (about 20 times per second). |