diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000..f2c1117 --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1 @@ +#link https://pages.frohnmeyer-wds.de/scripts/jfmod.yml \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..577aaa6 --- /dev/null +++ b/README.md @@ -0,0 +1,35 @@ +Better-Whitelist provides a basic whitelist system for your server that you can adapt to your use case. +The mod is required both on the server and any clients connecting to the server. +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. +A config file with some additional details will be created when you first start your server with the mod. +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): +``` +sharedMods = mods::values()::filter({ v -> v.environment != 'server' })::map({ v -> { id = v.id, version = v.version } }) + +// ensure the client has the correct version of every non-serverside mod on the server +assert(challenge({ arg -> + arg::allMatch({ v -> mods::values()::anyMatch({ m -> v.id == m.id & v.version == m.version }) }) +}, sharedMods)) + +// ensure the client has no additional mods that would be required on the server +assert(challenge({ arg -> + clientSideMods = mods::values()::filter({ v -> v.environment != 'client' }) + clientSideMods::allMatch({ v -> arg::anyMatch({ m -> v.id == m.id & v.version == m.version }) }) +}, sharedMods)) + +// 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::contains(word) }) })) +``` + +The following things are available to your scripts: +- All methods from the μScript standard library +- `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` \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index d03e7af..2e083fe 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,10 +8,9 @@ dependencies { modImplementation(fabricApi.module("fabric-networking-api-v1", prop("fabric_version"))) modImplementation(fabricApi.module("fabric-command-api-v2", prop("fabric_version"))) include(modImplementation("io.gitlab.jfronny:muscript:${prop("muscript_version")}")!!) - modImplementation("io.gitlab.jfronny.libjf:libjf-config-core-v1:${prop("libjf_version")}") + modImplementation("io.gitlab.jfronny.libjf:libjf-base:${prop("libjf_version")}") // Dev env - modLocalRuntime("io.gitlab.jfronny.libjf:libjf-config-ui-tiny-v1:${prop("libjf_version")}") modLocalRuntime("io.gitlab.jfronny.libjf:libjf-devutil:${prop("libjf_version")}") modLocalRuntime("com.terraformersmc:modmenu:${prop("modmenu_version")}") } diff --git a/gradle.properties b/gradle.properties index 9671ead..c495d41 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,12 +6,8 @@ loader_version=0.14.17 maven_group=io.gitlab.jfronny archives_base_name=better-whitelist -#modrinth_id=google-chat -#modrinth_required_dependencies=libjf -#modrinth_optional_dependencies=modmenu -#curseforge_id=574331 -#curseforge_required_dependencies=libjf -#curseforge_optional_dependencies=modmenu +modrinth_id=better-whitelist +modrinth_required_dependencies=libjf, fabric-api libjf_version=3.5.0-SNAPSHOT fabric_version=0.75.3+1.19.4 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 9b0dc1a..0000000 --- a/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1 +0,0 @@ -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip diff --git a/src/client/java/io/gitlab/jfronny/betterwhitelist/client/BetterWhitelistClient.java b/src/client/java/io/gitlab/jfronny/betterwhitelist/client/BetterWhitelistClient.java index 480d37f..3634170 100644 --- a/src/client/java/io/gitlab/jfronny/betterwhitelist/client/BetterWhitelistClient.java +++ b/src/client/java/io/gitlab/jfronny/betterwhitelist/client/BetterWhitelistClient.java @@ -38,7 +38,7 @@ public class BetterWhitelistClient implements ClientModInitializer { int paramSize = buf.readInt(); List> params = new LinkedList<>(); for (int i = 0; i < paramSize; i++) { - params.add(Dynamic.deserialize(buf.readString())); + params.add(Parser.parse(buf.readString()).asDynamicExpr().get(fork)); } String resultString = Dynamic.serialize(script.call(DFinal.of(params))); BetterWhitelist.LOG.info("Sending result: " + resultString); diff --git a/src/client/resources/assets/better-whitelist/icon.png b/src/client/resources/assets/better-whitelist/icon.png new file mode 100644 index 0000000..f4c9adb Binary files /dev/null and b/src/client/resources/assets/better-whitelist/icon.png differ diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index f86aa4c..e50f074 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -32,6 +32,7 @@ "fabricloader": ">=0.14.17", "minecraft": "*", "fabric-networking-api-v1": "*", - "fabric-command-api-v2": "*" + "fabric-command-api-v2": "*", + "libjf-base": "*" } }