PacketTrigger
PacketTrigger 允许你拦截其他插件发送给玩家的消息和数据包,并用你自己的操作(如命令、标题、音效、粒子效果等)替换它们。无需编写任何代码即可实现。
许多插件(如 BattlePass、任务系统、职业插件等)通过向玩家发送隐藏的聊天消息进行通信。PacketTrigger 会在玩家看到这些消息之前捕获它们,读取其中嵌入的任何数据值,并触发你配置好的相应操作。
我能用它做什么?
- 将无声的 BattlePass XP 消息转换为带有标题 + 音效 + 粒子爆发效果的完整提示
- 让任务插件从单个配置中触发控制台命令、发放奖励并显示自定义 HUD
- 在操作中使用的捕获数据值(如 XP 数量或任务名称)
- 通过 PlaceholderAPI (
%pt_triggerName_1%) 将这些值暴露给 任何 其他插件
- 添加条件,使操作仅在满足特定标准时触发
- 设置每个触发的冷却时间,防止滥用
- 从列表中随机选择一个操作以获取神秘奖励
- 多次重复执行操作,并可配置间隔时间
- 通过权限锁定触发器,仅允许特定玩家触发
- 选择是拦截系统消息、玩家聊天还是两者兼有
要求
安装
- 下载并将 PacketEvents 放入你的
plugins/ 文件夹
- 将
PacketTrigger.jar 放入你的 plugins/ 文件夹
- 启动服务器 —
plugins/PacketTrigger/config.yml 会自动生成
- 在
config.yml 中编辑你的触发器
- 运行
/pt reload
快速示例
你的 BattlePass 插件向玩家发送以下消息:
$bp 14 ! 82
你在 config.yml 中添加以下内容:
triggers:
battlepass-xp:
enabled: true
placeholder: "$bp"
delimiter: "!"
packet-source: SYSTEM
cooldown: 2
conditions:
- "{1} > 0"
actions:
- type: SEND_TITLE
title: "&6+{1} XP"
subtitle: "&7Total: &e{2} XP"
- type: PLAY_SOUND
sound: "ENTITY_EXPERIENCE_ORB_PICKUP"
pitch: 1.2
- type: CONSOLE_COMMAND
command: "somecommand give %player% {1}"
原始消息对玩家隐藏。取而代之的是,他们会看到一个显示 +14 XP 的标题和音效,并且你的控制台命令会填入真实值后运行。
操作类型
| 类型 |
功能 |
CONSOLE_COMMAND |
以控制台身份运行命令 |
PLAYER_COMMAND |
以玩家身份运行命令 |
SEND_MESSAGE |
发送聊天消息(支持 & 颜色代码) |
SEND_ACTIONBAR |
发送动作栏消息 |
SEND_TITLE |
发送标题和副标题,可配置淡入淡出时间 |
BROADCAST |
向所有在线玩家广播 |
PLAY_SOUND |
播放声音,支持音量和音调控制 |
PLAY_PARTICLE |
在玩家周围生成粒子效果 |
REPEAT |
以指定间隔重复执行一组操作 N 次 |
RANDOM |
从列表中随机选择一个操作 |
所有操作都支持可选的 delay 字段(单位为刻,20 刻 = 1 秒)。
占位符
这些占位符可用于任何操作字段——命令、消息、标题等。
| 占位符 |
值 |
{1}, {2} ... |
从被拦截消息中捕获的数据值 |
%pt_triggerName_1% |
同上,但可通过 PlaceholderAPI 全局使用 |
%player% |
玩家名称 |
%player_uuid% |
玩家 UUID |
%player_world% |
当前世界 |
%player_health% |
当前生命值 |
%player_level% |
XP 等级 |
{math:expression} |
内联计算数学表达式,例如 {math:{1}*2+10} |
| 任意 PAPI 占位符 |
如果已安装 PlaceholderAPI |
PacketTrigger 还注册了自己的 PAPI 扩展,以便 TAB 和计分板等其他插件可以读取触发器数据:
%pt_battlepass-xp_1% → 该玩家上次触发的第 1 个值
%pt_quest-complete_2% → 该玩家上次触发的第 2 个值
条件
条件用于控制触发器是否应触发。所有条件必须同时满足。
conditions:
- "{1} > 0"
- "%player_level% >= 10"
- "{1} contains daily"
支持的运算符:== != > < >= <= contains startswith endswith
每个触发器的选项
| 选项 |
描述 |
enabled |
设置为 false 可禁用而不删除 |
placeholder |
消息必须以该字符串开头 |
delimiter |
数据值之间的分隔符(默认:!) |
packet-source |
SYSTEM(插件消息)、PLAYER(聊天)或 BOTH |
permission |
仅当玩家拥有此权限时才触发 |
cooldown |
每个玩家两次触发之间的秒数 |
conditions |
必须全部通过的检查列表 |
命令
| 命令 |
描述 |
/pt reload |
重新加载 config.yml |
/pt list |
显示所有已加载的触发器及其状态 |
/pt test <trigger> <player> [data...] |
手动为测试目的触发一个触发器 |
/pt debug [player] |
切换每玩家的日志记录 |
/pt stats |
显示每个触发器的触发次数 |
/pt resetstats |
重置触发计数 |
/pt toggle <setting> |
实时切换 log-to-console 或 log-packet-content |
/pt clearcooldowns [player] |
清除某个玩家或所有玩家的冷却时间 |
所有命令都需要 packettrigger.admin 权限(默认为 op)。请参阅 Wiki 查看各个权限节点。
许可证
MIT —— 你可以随意使用它。
PacketTrigger
PacketTrigger lets you intercept the messages and packets other plugins send to players and replace them with your own actions: commands, titles, sounds, particles, and more. All without touching a single line of code.
A lot of plugins (BattlePass, quest systems, job plugins, etc.) communicate by sending hidden chat messages to players. PacketTrigger catches those messages before the player ever sees them, reads any data values embedded in them, and fires whatever actions you've configured instead.
What can I do with this?
- Turn a silent BattlePass XP message into a proper title + sound + particle burst
- Have a quest plugin trigger console commands, give rewards, and show a custom HUD — all from one config
- Use the captured data values (like XP amounts or quest names) inside your actions
- Expose those values to any other plugin via PlaceholderAPI (
%pt_triggerName_1%)
- Add conditions so actions only fire when certain criteria are met
- Set per-trigger cooldowns so nothing can be spammed
- Pick a random action from a list for mystery rewards
- Repeat actions multiple times with a configurable interval
- Lock triggers behind permissions so only certain players trigger them
- Choose whether to intercept system messages, player chat, or both
Requirements
Installation
- Download and drop PacketEvents into your
plugins/ folder
- Drop
PacketTrigger.jar into your plugins/ folder
- Start the server —
plugins/PacketTrigger/config.yml is generated automatically
- Edit your triggers in
config.yml
- Run
/pt reload
Quick example
Your BattlePass plugin sends this message to the player:
$bp 14 ! 82
You add this to config.yml:
triggers:
battlepass-xp:
enabled: true
placeholder: "$bp"
delimiter: "!"
packet-source: SYSTEM
cooldown: 2
conditions:
- "{1} > 0"
actions:
- type: SEND_TITLE
title: "&6+{1} XP"
subtitle: "&7Total: &e{2} XP"
- type: PLAY_SOUND
sound: "ENTITY_EXPERIENCE_ORB_PICKUP"
pitch: 1.2
- type: CONSOLE_COMMAND
command: "somecommand give %player% {1}"
The original message is hidden from the player. Instead they get a title showing +14 XP with a sound, and your console command runs with the real values filled in.
Action Types
| Type |
What it does |
CONSOLE_COMMAND |
Run a command as console |
PLAYER_COMMAND |
Run a command as the player |
SEND_MESSAGE |
Send a chat message (&-colors supported) |
SEND_ACTIONBAR |
Send an action bar message |
SEND_TITLE |
Send a title and subtitle with configurable fade times |
BROADCAST |
Broadcast to all online players |
PLAY_SOUND |
Play a sound with volume and pitch control |
PLAY_PARTICLE |
Spawn particles around the player |
REPEAT |
Repeat a set of actions N times with an interval |
RANDOM |
Pick one random action from a list |
All actions support an optional delay field (in ticks, 20 ticks = 1 second).
Placeholders
These work in any action field — commands, messages, titles, etc.
| Placeholder |
Value |
{1}, {2} ... |
Captured data values from the intercepted message |
%pt_triggerName_1% |
Same, but works globally via PlaceholderAPI |
%player% |
Player name |
%player_uuid% |
Player UUID |
%player_world% |
Current world |
%player_health% |
Current health |
%player_level% |
XP level |
{math:expression} |
Evaluate math inline, e.g. {math:{1}*2+10} |
| Any PAPI placeholder |
If PlaceholderAPI is installed |
PacketTrigger also registers its own PAPI expansion so other plugins like TAB and scoreboards can read trigger data:
%pt_battlepass-xp_1% → last value 1 fired for that player
%pt_quest-complete_2% → last value 2 fired for that player
Conditions
Conditions let you control whether a trigger should fire. All conditions must pass.
conditions:
- "{1} > 0"
- "%player_level% >= 10"
- "{1} contains daily"
Supported operators: == != > < >= <= contains startswith endswith
Per-Trigger Options
| Option |
Description |
enabled |
Set to false to disable without deleting |
placeholder |
The string the message must start with |
delimiter |
Separator between data values (default: !) |
packet-source |
SYSTEM (plugin messages), PLAYER (chat), or BOTH |
permission |
Only fire for players with this permission |
cooldown |
Seconds between fires per player |
conditions |
List of checks that must all pass |
Commands
| Command |
Description |
/pt reload |
Reload config.yml |
/pt list |
Show all loaded triggers and their status |
/pt test <trigger> <player> [data...] |
Fire a trigger manually for testing |
/pt debug [player] |
Toggle per-player packet logging |
/pt stats |
Show how many times each trigger has fired |
/pt resetstats |
Reset fire counts |
/pt toggle <setting> |
Toggle log-to-console or log-packet-content live |
/pt clearcooldowns [player] |
Clear cooldowns for a player or everyone |
All commands require packettrigger.admin (op by default). See the Wiki for individual permission nodes.
License
MIT — do whatever you want with it.
评论 0
登录后参与评分
还没有评论,来抢沙发吧