警告:下载此插件前请阅读
在下载此插件之前,请注意,更改 UUID 可能会导致现有在线玩家数据的丢失。
请从官方 Minecraft 网站购买正版 Minecraft。本插件作者仅认可和支持正版 Minecraft。
ahiropg-online
这是一个小型的 Velocity 代理插件,它能在离线模式的代理上为正版玩家提供其真实的 Mojang UUID,而没有 Mojang 会话的玩家仍会获得通常的离线 UUID。一旦某个账号以正版身份加入,它将被永久锁定为正版模式。
每个连接仅在登录时执行一次任务。
它解决的问题
运行 online-mode=false 的代理是接受没有 Minecraft 账号玩家的唯一方式,但它有一个副作用:Velocity 会给所有人分配一个离线 UUID(基于 OfflinePlayer:<name> 的哈希值)。
对于确实拥有游戏的玩家来说,这会破坏所有依赖其 Mojang UUID 的功能:排名、游戏时长、经济余额、区域所有权、白名单、跨服务器玩家数据等。将代理切换为 online-mode=true 可以修复这些问题,但会立即将所有未认证的玩家拒之门外。
本插件保留了混合模式设置。正版玩家保留其 Mojang UUID;其他所有人保留离线 UUID。
| 谁登录 |
转发到后端的 UUID |
| 正版账号,正版客户端 |
真实的 Mojang UUID,例如 5c89121b-4e93-46bd-80c9-3022a01c5bbd |
| 之前以正版身份加入过、现在离线的正版账号 |
拒绝,见 单向正版锁定 |
| 从未成为正版的玩家 |
离线 UUID,例如 0b5461e0-ea56-3019-8b05-6f4330752d8b |
| 没有 Mojang 账号的玩家 |
离线 UUID |
| 第三方认证启动器(皮肤站) |
离线 UUID |
如何判断谁是正版
自 Minecraft 1.20.2 起,客户端在登录时始终发送自己的 UUID。Velocity 通过 PreLoginEvent#getUniqueId() 暴露该值,并揭示客户端的意图:
| 客户端 |
声明 |
| 拥有有效会话的正版启动器 |
账号的真实 Mojang UUID |
| 离线启动器 |
自行计算的离线 UUID |
| 第三方认证启动器 |
该站点自己的 UUID |
因此,插件会将声明的 UUID 与该名称的离线 UUID 进行比较:
- 相等 → 客户端意在离线加入 → 允许作为离线玩家进入
- 等于该名称的 Mojang UUID → 客户端声称自己是正版 → 尽管代理处于离线状态,但告诉 Velocity 验证此单个连接(调用
forceOnlineMode());真实的会话将返回正版 UUID,伪造的会话将通过加密握手失败并被 Velocity 断开连接
- 其他任何情况 → 可配置的后备方案;默认情况下,玩家被视为离线并允许进入,而不是被踢出
会话验证本身由 Velocity 完成,而非本插件。本插件从不伪造登录;它仅决定连接应使用哪种登录模式。
由于准入取决于声明的 UUID 而非名称,因此即使名称恰好与正版账号匹配的玩家也不会被阻止,也不会意外地被当作正版处理。他们发送离线 UUID 并按照与其他人一样的路径进行离线登录。
单向正版锁定
账号的首次已验证正版会话会将该名称锁定为正版。该标志存储在 users.yml 中,从那一刻起,该名称的离线登录将被拒绝,并显示可配置的消息,而不是允许进入。
| 账号历史 |
本次登录 |
结果 |
| 从未成为正版 |
离线 |
允许,离线 UUID |
| 从未成为正版 |
正版 |
允许,并从此刻起锁定 |
| 之前已是正版 |
正版 |
允许,正版 UUID |
| 之前已是正版 |
离线 |
拒绝,offline-notice.premium-required-message |
- 切换回离线模式无法绕过锁定。 拒绝发生在登录阶段,在任何验证可能被跳过之前。
- 升级只允许一次。 曾经仅以离线身份加入的账号稍后仍可以正版身份加入,从那次登录开始,它也会被锁定。
- 锁定不依赖于 Mojang API。 它仅要求 Velocity 验证会话,因此 API 故障不会导致任何人被锁定。
- 没有任何内容会自动清除该标志。 从
users.yml 中删除条目将解锁该名称,因此请将此文件视为管理界面。
设置 hybrid.lock-to-premium: false 以发出警告而非拒绝:以前曾是正版的账号随后可以离线加入,并仅收到 offline-notice.message 作为提示,表明其会话可能已中断(令牌过期、启动器切换到离线登录、新设备)。
将 UUID 传递到您的后端
路线 1 — 登录握手,无需安装任何东西。 当 Velocity 连接到后端时,它会转发包含 UUID 的玩家 GameProfile,而插件已经将 UUID 设置为其判定结果。您的后端从第一个 tick 就获得了正确的 UUID。如果您的后端已经读取 GameProfile UUID(BungeeGuard 风格的设置,bungeecord: true + 现代转发),您到此为止就完成了。
路线 2 — 插件消息,供想要双重检查或存储判定结果的后端插件使用。一旦玩家进入后端,插件会推送 ahiropg:online:
| 字段 |
类型 |
| 协议版本 |
byte,当前为 1 |
| 玩家名称 |
UTF |
| UUID |
UTF,带连字符形式 |
| 是否正版 |
boolean |
UTF 是 DataOutputStream#writeUTF(2 字节长度 + UTF-8 字节)。接收方:
public final class OnlineBridge extends JavaPlugin implements PluginMessageListener {
private static final String CHANNEL = "ahiropg:online";
@Override
public void onEnable() {
getServer().getMessenger().registerIncomingPluginChannel(this, CHANNEL, this);
}
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (!CHANNEL.equals(channel)) {
return;
}
try (DataInputStream in = new DataInputStream(new ByteArrayInputStream(message))) {
byte version = in.readByte();
String name = in.readUTF();
UUID uuid = UUID.fromString(in.readUTF());
boolean premium = in.readBoolean();
getLogger().info(name + " uuid=" + uuid + " premium=" + premium);
} catch (IOException e) {
getLogger().warning("Failed to parse an ahiropg:online message: " + e);
}
}
}
频道名称是可配置的,因此请同时更改两端的设置。
记录机制
每次登录都会记录在 plugins/ahiropg-online/users.yml 中:包括用户名、账号是否曾通过正版验证、Mojang UUID、离线 UUID、实际转发的 UUID,以及首次/末次在线的时间戳。该文件会在定时器触发和服务器关闭时批量刷新,通过临时文件加原子移动的方式写入。
记录的正版标志(premium flag)是上述锁定逻辑的依据。该标志具有持久性:一旦为 true 便不会变回 false,且以用户名作为键。因此,如果玩家更改了其 Mojang 账号名称,将以新条目的形式出现。
配置
插件在首次启动时会创建 plugins/ahiropg-online/config.yml。每个键都在文件中有所说明;以下是关键配置项:
| 键 |
默认值 |
含义 |
session-policy |
HYBRID |
HYBRID 按连接单独判断;PROXY 不执行任何操作,遵循 velocity.toml 的设置 |
hybrid.allow-offline-connections |
true |
设置为 false 以拒绝离线连接,运行仅限正版的网络 |
hybrid.lock-to-premium |
true |
一旦账号以正版身份加入,则拒绝其离线登录 |
hybrid.legacy-client-policy |
offline |
对于 1.19.2 及更早版本且不声明 UUID 的客户端采取的操作 |
hybrid.mojang-unavailable-policy |
offline |
当无法访问 Mojang API 时的回退策略 |
forward.channel |
ahiropg:online |
插件消息通道 |
forward.on-server-switch |
true |
在后端切换时再次推送身份信息 |
forward.override-uuid |
true |
强制将转发的 GameProfile UUID 设为最终判定结果 |
mojang.proxy |
disabled |
用于 Mojang 查询的可选 HTTP 或 SOCKS5 代理,支持用户名/密码认证 |
offline-notice.enabled |
true |
启用下方的聊天提示信息 |
offline-notice.message |
— |
“你的会话已断开”提示,仅在 lock-to-premium 为 false 时使用 |
offline-notice.premium-required-message |
— |
当被锁定的账号尝试离线加入时显示 |
所有消息均支持 %player%、%uuid%、& 颜色代码以及 MiniMessage 格式。
无命令、无权限——配置即全部界面。
从受限网络访问 Mojang API
如果你的机器上 api.mojang.com 超时,可以通过代理路由查询请求。默认情况下此功能处于关闭状态,不影响其他流量——本插件发送的流量仅限于查询请求。
| 选项 |
默认值 |
备注 |
mojang.proxy.enabled |
false |
开启后通过代理路由查询请求 |
mojang.proxy.type |
HTTP |
HTTP 或 SOCKS5 |
mojang.proxy.host / port |
— |
启动时验证;若值不可用则记录警告并回退到直连 |
mojang.proxy.username / password |
空 |
可选,两种代理类型均支持 |
对于两种类型的代理,域名解析均在代理端进行,因此本地 DNS 污染不会导致查询失败。代理故障并非致命错误:查询会失败,日志中会包含代理地址和原因,插件将根据 hybrid.mojang-unavailable-policy 进行回退。玩家自身的会话 UUID 仍会填入 users.yml。密码以明文形式存储在 config.yml 中。
本插件不做什么
直言不讳地说,以免大家产生误解:
- 它不会将你的代理切换到在线模式。 它仅要求 Velocity 验证那些声称是正版的个别连接。
- 除非你设置
allow-offline-connections: false,否则它不会阻止没有账号的玩家。 开箱即用,网络保持混合模式。
- 它不是身份验证插件。 它不会为离线玩家添加密码或双重认证(2FA)。它也不会检查你的后端服务器上的任何内容。
- 它不能保护被盗的正版账号。 如果有人拥有真实的会话,Velocity 会对其进行验证——这与原版在线模式相同。
- 它不能让盗版客户端变成正版。 没有任何方法可以做到这一点;伪造的 UUID 只会导致连接被强制进入一个无法完成的握手流程。
- 锁定并不与 Mojang 账号本身绑定。 它是
users.yml 中的本地记录,以用户名为键,可以通过编辑该文件来清除。
要求与安装
- Velocity 3.x(基于
velocity-api 3.4.0 构建),Java 17+
- 将 jar 包放入代理的
plugins/ 目录,启动一次,调整 config.yml,然后重启
- 后端服务器无需安装任何插件即可接收正确的 UUID;如果你需要额外数据,请读取插件消息
兼容性说明
- 1.19.2 及更早版本的客户端不会发送 UUID,因此无法确定其意图;它们将回退到
legacy-client-policy。
- 第三方身份验证启动器被视为离线状态(因为它们会发送自己的 UUID),因此如果你使用了后端服务,请确保它接受离线 UUID。
- Mojang API 速率限制:查找失败时会根据
hybrid.mojang-unavailable-policy 进行回退,并记录警告日志。离线连接永远不会等待 API 响应;查找操作是异步执行的,并且结果会被缓存。
- **锁定账户需要一个正常运行的会话服务。**拒绝离线登录意味着当 Mojang 的会话服务器从玩家的网络不可达时,被锁定的玩家将无法加入。这正是锁定的预期行为,但在启用此功能之前,了解这一支持负担是值得的。
- 大小写敏感性:离线 UUID 是根据客户端登录时使用的确切名称派生的。对于本插件以及 Velocity 本身而言,
NapCatt_owo 和 Napcatt_owo 代表不同的玩家。
源代码与许可证
源代码、问题追踪器和发行说明:
采用 MIT 许可证。
WARNING:before download this plugin
Before downloading this plugin, please be aware that changes to UUIDs may result in the loss of existing online player data.
Please purchase the legitimate version of Minecraft from the official Minecraft website. The plugin author endorses and recognizes only legitimate copies of Minecraft.
ahiropg-online
A small Velocity proxy plugin that gives premium players their real Mojang UUID
on an offline-mode proxy, while players without a Mojang session still get the
usual offline UUID. Once an account has joined as premium, it is locked to premium
from then on.
One job, done at login, per connection.
The problem it solves
Running a proxy with online-mode=false is the only way to accept players who do not
own a Minecraft account, but it has a side effect: Velocity hands everyone an
offline UUID (a hash of OfflinePlayer:<name>).
For players who do own the game, that breaks everything keyed to their Mojang UUID:
ranks, playtime, economy balances, region ownership, whitelists, cross-server player
data. Switching the proxy to online-mode=true fixes that and immediately locks out
every unauthenticated player.
This plugin keeps the mixed-mode setup. Premium players keep their Mojang UUID;
everyone else keeps the offline UUID.
| Who logs in |
UUID forwarded to your backend |
| Premium account, premium client |
the real Mojang UUID, e.g. 5c89121b-4e93-46bd-80c9-3022a01c5bbd |
| Premium account that has joined as premium before, now offline |
refused, see the one-way premium lock |
| Player who has never been premium |
the offline UUID, e.g. 0b5461e0-ea56-3019-8b05-6f4330752d8b |
| Player with no Mojang account |
the offline UUID |
| Third-party auth launcher (skin sites) |
the offline UUID |
How it decides who is premium
Since Minecraft 1.20.2, a client always sends its own UUID during login. Velocity
exposes it as PreLoginEvent#getUniqueId(), and it reveals what the client intends:
| Client |
Declares |
| Premium launcher with a valid session |
the account's real Mojang UUID |
| Offline launcher |
the offline UUID it computed itself |
| Third-party auth launcher |
that site's own UUID |
So the plugin compares the declared UUID against the offline UUID for that name:
- equal → the client means to join offline → allowed in as an offline player
- equals the Mojang UUID of that name → the client claims to be premium → Velocity
is told to verify this one connection even though the proxy is offline
(
forceOnlineMode()); a real session yields the premium UUID, a forged one fails the
encryption handshake and Velocity disconnects it
- anything else → configurable fallback; by default the player is let in as offline
rather than kicked
Session verification itself is done by Velocity, not by this plugin. The plugin
never fakes a login; it only decides which login mode a connection gets.
Because admission depends on the declared UUID rather than on the name, a player whose
name happens to match a premium account is not blocked and not accidentally
treated as premium. They send the offline UUID and take the offline path like anyone
else.
The one-way premium lock
An account's first verified premium session locks that name to premium. The flag is
stored in users.yml, and from that moment an offline login for the name is refused
with a configurable message instead of being admitted.
| Account history |
This login |
Result |
| never premium |
offline |
allowed, offline UUID |
| never premium |
premium |
allowed, and locked from now on |
| premium before |
premium |
allowed, premium UUID |
| premium before |
offline |
refused, offline-notice.premium-required-message |
- Switching back to offline cannot sidestep the lock. The refusal happens at login,
before any verification could be skipped.
- Upgrading is allowed once. An account that has only ever joined offline may still
join with premium later, and from that login it is locked as well.
- The lock does not depend on the Mojang API. It only asks Velocity to verify the
session, so an API outage cannot lock anyone out.
- Nothing clears the flag automatically. Deleting an entry from
users.yml unlocks
that name, so treat the file as an administrative surface.
Set hybrid.lock-to-premium: false to warn instead of refusing: a previously premium
account may then join offline and only receives offline-notice.message as a hint that
its session probably dropped (expired token, launcher switched to offline login, new
device).
Getting the UUID to your backend
Route 1 — the login handshake, nothing to install. When Velocity connects to a
backend it forwards the player's GameProfile including the UUID, and the plugin has
already set that UUID to its verdict. Your backend has the correct UUID from the first
tick. If your backend already reads the GameProfile UUID (BungeeGuard-style setups,
bungeecord: true + modern forwarding), you are done at this point.
Route 2 — a plugin message, for backend plugins that want to double-check or store
the verdict. Once the player is on a backend, the plugin pushes ahiropg:online:
| Field |
Type |
| protocol version |
byte, currently 1 |
| player name |
UTF |
| UUID |
UTF, dashed form |
| premium |
boolean |
UTF is DataOutputStream#writeUTF (2-byte length + UTF-8 bytes). Receiving side:
public final class OnlineBridge extends JavaPlugin implements PluginMessageListener {
private static final String CHANNEL = "ahiropg:online";
@Override
public void onEnable() {
getServer().getMessenger().registerIncomingPluginChannel(this, CHANNEL, this);
}
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (!CHANNEL.equals(channel)) {
return;
}
try (DataInputStream in = new DataInputStream(new ByteArrayInputStream(message))) {
byte version = in.readByte();
String name = in.readUTF();
UUID uuid = UUID.fromString(in.readUTF());
boolean premium = in.readBoolean();
getLogger().info(name + " uuid=" + uuid + " premium=" + premium);
} catch (IOException e) {
getLogger().warning("Failed to parse an ahiropg:online message: " + e);
}
}
}
The channel name is configurable, so change both sides together.
Recording
Every login is recorded in plugins/ahiropg-online/users.yml: name, whether the account
has ever passed premium verification, its Mojang UUID, its offline UUID, the UUID
actually forwarded, and first/last seen timestamps. The file is flushed in batches on a
timer and on shutdown, written through a temp file plus an atomic move.
The recorded premium flag is what drives the lock above. It is sticky: it never returns
to false, and it is keyed to the name, so a player who renames their Mojang account
arrives as a new entry.
Configuration
The plugin creates plugins/ahiropg-online/config.yml on first start. Every key is
documented in the file; the important ones:
| Key |
Default |
Meaning |
session-policy |
HYBRID |
HYBRID decides per connection; PROXY does nothing and follows velocity.toml |
hybrid.allow-offline-connections |
true |
set false to reject offline connections and run a premium-only network |
hybrid.lock-to-premium |
true |
once an account has joined as premium, refuse its offline logins |
hybrid.legacy-client-policy |
offline |
what to do with clients 1.19.2 and older, which declare no UUID |
hybrid.mojang-unavailable-policy |
offline |
fallback when the Mojang API cannot be reached |
forward.channel |
ahiropg:online |
plugin messaging channel |
forward.on-server-switch |
true |
push the identity again on every backend switch |
forward.override-uuid |
true |
force the forwarded GameProfile UUID to the verdict |
mojang.proxy |
disabled |
optional HTTP or SOCKS5 proxy for Mojang lookups, with username/password support |
offline-notice.enabled |
true |
enable the chat messages below |
offline-notice.message |
— |
"your session dropped" hint, only used when lock-to-premium is false |
offline-notice.premium-required-message |
— |
shown when a locked account tries to join offline |
All messages support %player%, %uuid%, & colour codes and MiniMessage.
No commands, no permissions — configuration is the whole interface.
Reaching the Mojang API from a restricted network
If api.mojang.com times out on your machine, route the lookups through a proxy. It is
off by default and affects nothing else — lookups are the only traffic this plugin sends.
| Option |
Default |
Notes |
mojang.proxy.enabled |
false |
turn it on to route lookups through a proxy |
mojang.proxy.type |
HTTP |
HTTP or SOCKS5 |
mojang.proxy.host / port |
— |
validated at startup; an unusable value logs a warning and falls back to direct |
mojang.proxy.username / password |
empty |
optional, supported by both proxy types |
Name resolution happens at the proxy for both types, so a polluted local DNS cannot
break the lookup. A broken proxy is not fatal: the lookup fails, the log carries the
proxy address and the reason, and the plugin falls back according to
hybrid.mojang-unavailable-policy. The player's own session UUID still fills
users.yml. The password is stored in plain text in config.yml.
What this plugin does not do
Stated plainly, so nobody buys into the wrong thing:
- It does not switch your proxy to online mode. It only asks Velocity to verify
individual connections that claim to be premium.
- It does not block players without an account unless you set
allow-offline-connections: false. Out of the box the network stays mixed.
- It is not an authentication plugin. It does not add passwords or 2FA for offline
players. It does not check anything on your backend servers.
- It does not protect against a compromised premium account. If someone has the
real session, Velocity verifies them — same as vanilla online mode.
- It does not make a cracked client premium. Nothing can; a forged UUID only gets
the connection forced into a handshake it cannot complete.
- The lock is not tied to the Mojang account itself. It is a local record in
users.yml, keyed to the name, and it can be cleared by editing that file.
Requirements and installation
- Velocity 3.x (built against
velocity-api 3.4.0), Java 17+
- Drop the jar into the proxy's
plugins/, start once, adjust config.yml, restart
- Backend servers need no plugin to receive the correct UUID; only read the plugin
message if you want the extra data
Compatibility notes
- Clients 1.19.2 and older send no UUID, so intent cannot be determined; they fall
back to
legacy-client-policy.
- Third-party auth launchers count as offline (they send their own UUID), so make
sure your backend accepts offline UUIDs if you use one.
- Mojang API rate limits: a failed lookup falls back according to
hybrid.mojang-unavailable-policy and logs a warning. Offline connections never wait
on the API; lookups run asynchronously and are cached.
- Locked accounts need a working session service. Refusing offline logins means a
locked player cannot join while Mojang's session servers are unreachable from their
network. That is the intent of the lock, but it is a support burden worth knowing
before enabling it.
- Case sensitivity: offline UUIDs derive from the exact name the client logged in
with.
NapCatt_owo and Napcatt_owo are different players to this plugin, as they are
to Velocity itself.
Source and licence
Source code, issue tracker and release notes:
MIT licensed.
评论 0
登录后参与评分
还没有评论,来抢沙发吧