更好的白名单

更好的白名单

一个可配置的Minecraft白名单系统

管理

Better-Whitelist 为你的服务器提供了一个基础的白名单系统,你可以根据自己的使用场景进行调整。

该模组需要在服务器和所有连接到服务器的客户端上安装。

白名单使用 μScript 进行配置,但你不需要精通编程就能使用这个模组。

当你第一次使用该模组启动服务器时,会创建一个包含一些附加细节的配置文件。

一个简单的 Better-Whitelist 配置可能如下所示(请注意,使用此配置时,你可能需要为带有可选服务端组件的客户端模组添加例外):

// convert a mod to a simpler representation to save bandwidth
simplify = { mod -> { id = mod.id, version = mod.version } }

// all non-serverside mods present on the server
sharedMods = mods::values()
  ::filter({ v -> v.environment != 'server' & v.id != 'java' })
  ::map(simplify)

// ensure the client has the correct version of every non-serverside mod on the server
clientMissing = challenge({ arg ->
  arg::filter({ v -> !mods::values()::anyMatch({ m -> v.id == m.id & v.version == m.version }) })
}, sharedMods)
assert(clientMissing::isEmpty(), 'You lack required mods: ' || clientMissing)

// ensure the client has no additional mods that would be required on the server
clientAdditional = challenge({ arg, fn ->
  clientSideMods = mods::values()::filter({ v -> v.environment != 'client' & v.id != 'java' })
  clientSideMods::filter({ v -> !arg::anyMatch({ m -> v.id == m.id & v.version == m.version }) })::map(fn)
}, sharedMods, simplify)
assert(clientAdditional::isEmpty(), 'You have unsupported mods: ' || clientAdditional)

// filter resource packs for X-Ray packs
bannedWords = listOf('xray', 'x-ray', 'cheat')
assert(!challenge({ ->
  resourcePacks::map({ pack -> pack.name || ' ' || pack.displayName || ' ' || pack.description })
})::anyMatch({ v -> bannedWords::anyMatch({ word -> v::toLower()::contains(word) }) }), "Please don't cheat, " || user.name)

以下内容可供你的脚本使用:

  • μScript 标准库中的所有方法(包括日期/时间,意味着你可以临时将用户加入白名单或黑名单,或创建倒计时)
  • resourcePacks(仅客户端):资源包列表,每个资源包都有 name、displayName 和 description
  • println('message')(两者皆可):用于调试的函数
  • mods(两者皆可):已加载模组的列表,字段与 mod() 的结果相同
  • mod('id')(两者皆可):特定模组的信息(或 null):id、name、description、authors(字符串列表)、contributors(字符串列表)、version、environment(client、server 或 *)、license、contact(与 FMJ 相同)、depends(字符串列表)
  • assert(bool)(服务端):断言某事为真,如果不是则踢出玩家(可选,在第二个参数中添加一条消息)
  • challenge({->closure}, additional arguments...)(服务端):将一个闭包发送到客户端在那里执行。参数中可能包含其他闭包。
  • user(服务端):尝试登录的用户的信息,即其 id 和 name
Suggestions and Support