Better-Whitelist/README.md

47 lines
3.1 KiB
Markdown
Raw Permalink Normal View History

2023-03-12 21:34:52 +01:00
Better-Whitelist provides a basic whitelist system for your server that you can adapt to your use case.
2023-03-12 22:33:05 +01:00
2023-03-12 21:34:52 +01:00
The mod is required both on the server and any clients connecting to the server.
2023-03-12 22:33:05 +01:00
2023-03-12 21:34:52 +01:00
The whitelist is configured using [μScript](https://git.frohnmeyer-wds.de/Johannes/java-commons/src/branch/master/muscript), but you don't have to be good at programming to use this mod.
2023-03-12 22:33:05 +01:00
2023-03-12 21:34:52 +01:00
A config file with some additional details will be created when you first start your server with the mod.
2023-03-12 22:33:05 +01:00
2023-03-12 21:34:52 +01:00
A simple config for Better-Whitelist could look as follows (please note that you'd probably have to add exceptions for client-side mods with optional server-side components when using this):
```
2023-03-12 22:33:05 +01:00
// 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)
2023-03-12 21:34:52 +01:00
// ensure the client has the correct version of every non-serverside mod on the server
2023-03-12 22:33:05 +01:00
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)
2023-03-12 21:34:52 +01:00
// ensure the client has no additional mods that would be required on the server
2023-03-12 22:33:05 +01:00
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)
2023-03-12 21:34:52 +01:00
// filter resource packs for X-Ray packs
bannedWords = listOf('xray', 'x-ray', 'cheat')
assert(!challenge({ ->
resourcePacks::map({ pack -> pack.name || ' ' || pack.displayName || ' ' || pack.description })
2023-03-12 22:33:05 +01:00
})::anyMatch({ v -> bannedWords::anyMatch({ word -> v::toLower()::contains(word) }) }), "Please don't cheat, " || user.name)
2023-03-12 21:34:52 +01:00
```
The following things are available to your scripts:
2023-03-13 14:20:03 +01:00
- All methods from the μScript standard library (including date/time, meaning you can temporarily whitelist or blacklist users or create countdowns)
2023-03-12 21:34:52 +01:00
- `resourcePacks` (client only): a list of resource packs, each of which has a `name`, `displayName` and `description`
- `println('message')` (both): a function for debugging
- `mods` (both): a list of loaded mods with the same fields as the result of `mod()`
- `mod('id')` (both): information about a specific mod (or null): `id`, `name`, `description`, `authors` (list of strings), `contributors` (list of strings), `version`, `environment` (either `client`, `server` or `*`), `license`, `contact` (same as FMJ), `depends` (list of strings)
- `assert(bool)` (server): assert that something is true and kick the player if it's not (optionally, add a message as the second parameter)
- `challenge({->closure}, additional arguments...)` (server): send a closure to the client to be executed there. The arguments may contain other closures.
- `user` (server): information about the user trying to log in, namely their `id` and `name`