Velocity 配置
在 Velocity 3.0.0+ 上配置 NDPR
概述
Velocity 是现代 Minecraft 代理服务器。NDPR 提供原生 Velocity 插件实现高性能封禁检查。
环境要求
安装
1. 下载插件
Text
ndpr-velocity.jar
2. 安装
将插件放入 plugins 目录:
Text
/path/to/velocity/plugins/ndpr-velocity.jar
3. 配置
创建 plugins/ndpr/config.json:
JSON
{
"api": {
"url": "http://localhost:5030",
"timeout": 5000
},
"auth": {
"token": "your_api_token"
},
"check": {
"on_login": true,
"on_join": true,
"cache_time": 60
},
"actions": {
"kick_message": "§c你已被封禁,原因:{reason}",
"notify_admins": true
},
"logging": {
"enabled": true,
"level": "INFO"
}
}
4. 重启 Velocity
Text
/velocity reload
配置说明
API 配置
| 参数 | 类型 | 说明 |
|---|---|---|
| url | string | NDPR API 地址 |
| timeout | int | 请求超时(毫秒) |
认证配置
| 参数 | 类型 | 说明 |
|---|---|---|
| token | string | API Token |
检查配置
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| on_login | boolean | true | 登录时检查 |
| on_join | boolean | true | 加入时检查 |
| cache_time | int | 60 | 缓存时间(秒) |
动作配置
| 参数 | 类型 | 说明 |
|---|---|---|
| kick_message | string | 踢出显示的消息 |
| notify_admins | boolean | 是否通知管理员 |
权限
| 权限节点 | 说明 |
|---|---|
ndpr.ban | 封禁玩家 |
ndpr.unban | 解封玩家 |
ndpr.lookup | 查询封禁状态 |
ndpr.reload | 重载配置 |
ndpr.admin | 管理员权限 |
命令
游戏内命令
| 命令 | 说明 | 权限 |
|---|---|---|
/ndpr ban <玩家> [原因] | 封禁玩家 | ndpr.ban |
/ndpr unban <玩家> | 解封玩家 | ndpr.unban |
/ndpr check <玩家> | 查询状态 | ndpr.lookup |
/ndpr reload | 重载配置 | ndpr.admin |
控制台命令
Text
ndpr ban <玩家> <原因>
ndpr unban <玩家>
ndpr reload
API 集成
Java
// Velocity Java API 示例
public class BanCheck {
public boolean isBanned(String username) {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("http://localhost:5030/bans/check"))
.header("Authorization", "Bearer " + token)
.POST(HttpRequest.BodyPublishers.ofString(
"{\"player\":\"" + username + "\"}"))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
return response.statusCode() == 200;
}
}
性能优化
<div class="custom-block tip">
<div class="custom-block-title">性能建议</div>
1. 合理设置缓存时间<br>
2. 使用连接池<br>
3. 启用日志记录监控<br>
4. 定期检查 API 状态
</div>