Skip to content

ProtocolLib Hook

Vitor Albert edited this page Mar 6, 2026 · 1 revision

📡 ProtocolLib Hook (Automatic Packet Translation)

IGLanguages can automatically translate %lang_*% placeholders in outgoing server packets — no need for PlaceholderAPI support in every plugin! This means scoreboards, titles, bossbars, tab lists, chat messages, kick messages, and even item names/lores are translated on-the-fly before reaching the player.

Requirements

  • ProtocolLib must be installed on your server.

How it works

When enabled, IGLanguages intercepts packets sent to each player and replaces any %lang_*% placeholder found in the packet's text/JSON with the correct translation for that player's language. This happens transparently — you just write %lang_key% in any plugin config and it gets translated automatically.

Supported packet types

Packet What it translates Versions
Chat / System Chat Chat messages, system messages, action bar (JSON) All
Disguised Chat Disguised chat messages (1.19.3+ format) 1.19.3+
Open Window Inventory/container titles All
Set Slot / Window Items Item display names and lore lines All
Title (legacy) Title & subtitle packets 1.8 – 1.16
Title / Subtitle / Action Bar (modern) Modern title packets 1.17+
Boss Bar Boss bar title text (including action structures) All
Tab List Header & footer of the player list All
Scoreboard Objective Objective display names All
Scoreboard Score Score entry names and display text All
Scoreboard Team Team prefix and suffix All
Kick Disconnect Kick/disconnect reason message All
Server Data Server MOTD displayed to the player 1.19.4+

Note: Packet types that don't exist in your server version are silently skipped — no errors in console.

Configuration

In your config.yml:

protocollib:
  # Enable or disable the ProtocolLib hook entirely
  enabled: true
  # Cache size for processed packet translations
  # Higher values reduce CPU usage for repeated packets (e.g. scoreboard updates)
  cacheSize: 200
Setting Description Default
protocollib.enabled Enables/disables packet interception. true
protocollib.cacheSize Max entries in the processed-packet cache. Cached results expire after 5 minutes. 200

Example: Translating a scoreboard without PlaceholderAPI support

Even if your scoreboard plugin does not support PlaceholderAPI, IGLanguages can still translate it via packet interception.

In your scoreboard plugin config:

title: "%lang_systems.board_title%"
lines:
  - "%lang_systems.board_money%: $1000"
  - "%lang_systems.board_online%"

In langs/en_us/systems/board.yml:

title: "&bMy Server"
money: "Money"
online: "Players Online"

In langs/pt_br/systems/board.yml:

title: "&aMeu Servidor"
money: "Dinheiro"
online: "Jogadores Online"

The ProtocolLib hook will intercept the scoreboard packets and replace the placeholders with the correct translation for each player — even though the scoreboard plugin has no idea IGLanguages exists.

Performance

  • Caching: Processed packet results are cached by language + content, so repeated packets (like scoreboard ticks) are resolved from cache instead of being re-processed every time.
  • Thread-safe: The hook runs on Netty I/O threads and uses only thread-safe data structures. Translation data uses volatile atomic swaps during reloads so packets never see a partially-loaded state.
  • Cache invalidation: Running /lang reload automatically clears both the translation cache and the packet cache, ensuring updated translations take effect immediately.

ProtocolLib Hook vs PlaceholderAPI

Feature PlaceholderAPI ProtocolLib Hook
Requires plugin support Yes — plugin must call PAPI No — works with any plugin
Resolves PAPI placeholders Yes (%player_name%, etc.) No — only %lang_*%
Thread Main thread Netty I/O thread (async)
Best for Plugins with PAPI support Scoreboards, titles, bossbars, menus without PAPI

Tip: Both systems work together! PlaceholderAPI resolves %lang_*% + other placeholders in supported plugins, while the ProtocolLib hook catches everything else at the packet level.


Next: Commands-and-Permissions

Clone this wiki locally