LightVision
将夜视效果作为开关使用。玩家可以使用 /lv 自行开启或关闭夜视,工作人员可以为其他人设置,阻止滥用该功能的玩家,并允许插件在玩家进入黑暗区域时自动开启夜视。
状态会在重启后保留,被拉黑的世界无论如何都会保持黑暗,且插件绝不会干扰它未发放的夜视效果——药水或信标提供的夜视效果仍会按玩家预期正常工作。
要求
- Minecraft 1.21+ 上的 Paper、Purpur 或 Spigot
- Java 21
- PlaceholderAPI(可选,仅用于占位符)
命令
/lv 和 /lightvision 是同一个命令。
| 命令 |
描述 |
权限 |
/lv |
切换自己的夜视效果 |
lv.use |
/lv <player> [on|off] |
切换或为他人设置夜视效果 |
lv.admin |
/lv block <player> |
禁止某玩家使用夜视效果 |
lv.admin |
/lv unblock <player> |
解除禁止 |
lv.admin |
/lv reload |
重新加载 config.yml 并应用于所有在线玩家 |
lv.admin |
lv.use 默认为 true,lv.admin 默认为 op。lv.bypass.block(op)可保护玩家不被其他工作人员屏蔽。
/lv unblock 也适用于离线玩家,只要服务器之前见过该玩家即可。原始 UUID 也可以使用。
占位符
| 占位符 |
值 |
%lightvision_enabled% |
当玩家手动开启夜视时为 true |
%lightvision_auto% |
当黑暗触发器提供夜视时为 true |
%lightvision_active% |
上述两种情况之一 |
%lightvision_blocked% |
如果工作人员屏蔽了该玩家则为 true |
配置
config.yml 包含两个部分,均在内部进行了文档说明:
settings - 跨重启保存状态、使用动作栏而非聊天栏、标题、关闭夜视时的失明闪烁、黑暗触发器以及世界黑名单
messages - 所有面向玩家的文本,采用
MiniMessage 格式
黑暗触发器
默认关闭。启用后,低于 light-level(光照等级)的玩家会自动获得夜视效果,并在光线变亮时失去效果。自动获得的夜视效果与玩家手动切换的效果分开处理:它不会写入 data.yml,一旦有人使用 /lv 就会让位,且关闭触发器并运行 /lv reload 会移除当前拥有该效果的所有玩家的夜视。
光照检测在移动时进行(每个玩家每秒最多两次),并通过后台任务每 check-interval-ticks(检查间隔刻数)执行一次。
数据
data.yml 存储了开启夜视效果的玩家的 UUID 以及屏蔽列表。未开启夜视的玩家则不会出现在文件中,因此文件体积保持较小。它在主线程之外写入,最多每分钟一次,并在服务器关闭时写入。
构建
mvn clean package
着色后的 jar 包位于 target/lightvision-<version>.jar。bStats 和 MiniMessage 已着色并重定位到 de.empireblocks.lightVision.libs;spigot-api 标记为 provided,不包含在 jar 包中。
许可证
GNU General Public License v3.0。请参阅 LICENSE。
LightVision
Night vision as a toggle. Players switch it on and off for themselves with /lv,
staff can set it for others, block anyone who abuses it, and let the plugin turn
it on automatically whenever someone walks into the dark.
The state survives restarts, blacklisted worlds stay dark no matter what, and the
plugin never touches a night vision effect it did not hand out itself - a potion
or a beacon keeps working exactly as the player expects.
Requirements
- Paper, Purpur or Spigot on Minecraft 1.21+
- Java 21
- PlaceholderAPI (optional, only for the placeholders)
Commands
/lv and /lightvision are the same command.
| Command |
Description |
Permission |
/lv |
Toggle your own night vision |
lv.use |
/lv <player> [on|off] |
Toggle or set night vision for someone else |
lv.admin |
/lv block <player> |
Block a player from using night vision |
lv.admin |
/lv unblock <player> |
Lift the block again |
lv.admin |
/lv reload |
Reload config.yml and apply it to everyone online |
lv.admin |
lv.use defaults to true, lv.admin to op. lv.bypass.block (op) protects a
player from being blocked by other staff members.
/lv unblock also works on offline players, as long as the server has seen them
before. A raw UUID works too.
Placeholders
| Placeholder |
Value |
%lightvision_enabled% |
true while the player switched night vision on |
%lightvision_auto% |
true while the darkness trigger gives it to them |
%lightvision_active% |
either of the two |
%lightvision_blocked% |
true if staff blocked the player |
Configuration
config.yml holds two sections, both documented inline:
settings - remember state across restarts, actionbar instead of chat, titles,
the blindness flash when night vision goes off, the darkness trigger, and the
world blacklist
messages - every player-facing text, in
MiniMessage format
Darkness trigger
Off by default. Once enabled, players below light-level get night vision
automatically and lose it again when it gets bright. Automatic night vision is
kept apart from what a player toggled themselves: it is never written to
data.yml, it gives way the moment someone uses /lv, and switching the trigger
off and running /lv reload takes it away from everyone who currently has it.
Light is checked on movement (at most twice a second per player) and by a
background task every check-interval-ticks.
Data
data.yml stores the UUIDs of players whose night vision is on, plus the
blocklist. Players who are off are simply absent, so the file stays small. It is
written off the main thread, once a minute at most, and on shutdown.
Building
mvn clean package
The shaded jar lands in target/lightvision-<version>.jar. bStats and MiniMessage
are shaded and relocated into de.empireblocks.lightVision.libs; spigot-api is
provided and stays out of the jar.
License
GNU General Public License v3.0. See LICENSE.
评论 0
登录后参与评分
还没有评论,来抢沙发吧