From a43f4a11b0f75e7af68e02c92fb61891f7c54f76 Mon Sep 17 00:00:00 2001 From: Luck Date: Wed, 17 Apr 2024 21:25:04 +0100 Subject: [PATCH] Update Fabric dependencies --- fabric/build.gradle | 2 +- .../FabricPermissionsApiListener.java | 10 ++++++++++ fabric/src/main/resources/fabric.mod.json | 2 +- gradle/libs.versions.toml | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew.bat | 20 +++++++++---------- settings.gradle | 2 +- 7 files changed, 25 insertions(+), 15 deletions(-) diff --git a/fabric/build.gradle b/fabric/build.gradle index 26874e97b..3afe790d0 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -28,7 +28,7 @@ dependencies { modImplementation(fabricApi.module(it, '0.91.2+1.20.4')) } - include(modImplementation('me.lucko:fabric-permissions-api:0.2-SNAPSHOT')) + include(modImplementation('me.lucko:fabric-permissions-api:0.3.1')) implementation project(':common') } diff --git a/fabric/src/main/java/me/lucko/luckperms/fabric/listeners/FabricPermissionsApiListener.java b/fabric/src/main/java/me/lucko/luckperms/fabric/listeners/FabricPermissionsApiListener.java index f25d84991..ec2baa9bc 100644 --- a/fabric/src/main/java/me/lucko/luckperms/fabric/listeners/FabricPermissionsApiListener.java +++ b/fabric/src/main/java/me/lucko/luckperms/fabric/listeners/FabricPermissionsApiListener.java @@ -25,11 +25,13 @@ package me.lucko.luckperms.fabric.listeners; +import me.lucko.fabric.api.permissions.v0.OfflineOptionRequestEvent; import me.lucko.fabric.api.permissions.v0.OfflinePermissionCheckEvent; import me.lucko.fabric.api.permissions.v0.OptionRequestEvent; import me.lucko.fabric.api.permissions.v0.PermissionCheckEvent; import me.lucko.luckperms.common.cacheddata.result.StringResult; import me.lucko.luckperms.common.cacheddata.result.TristateResult; +import me.lucko.luckperms.common.cacheddata.type.MonitoredMetaCache; import me.lucko.luckperms.common.cacheddata.type.PermissionCache; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.query.QueryOptionsImpl; @@ -63,6 +65,7 @@ public class FabricPermissionsApiListener { PermissionCheckEvent.EVENT.register(this::onPermissionCheck); OptionRequestEvent.EVENT.register(this::onOptionRequest); OfflinePermissionCheckEvent.EVENT.register(this::onOfflinePermissionCheck); + OfflineOptionRequestEvent.EVENT.register(this::onOfflineOptionRequest); } private @NonNull TriState onPermissionCheck(CommandSource source, String permission) { @@ -92,6 +95,13 @@ public class FabricPermissionsApiListener { }); } + private @NonNull CompletableFuture> onOfflineOptionRequest(UUID uuid, String key) { + return lookupUser(uuid).thenApplyAsync(user -> { + MonitoredMetaCache metaData = user.getCachedData().getMetaData(); + return Optional.ofNullable(metaData.getMetaOrChatMetaValue(key, CheckOrigin.PLATFORM_API)); + }); + } + public CompletableFuture lookupUser(UUID uuid) { User user = this.plugin.getUserManager().getIfLoaded(uuid); if (user != null) { diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index e820b2a6b..1cdbcc463 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -35,7 +35,7 @@ "fabric-command-api-v2": "*", "fabric-lifecycle-events-v1": "*", "fabric-networking-api-v1": "*", - "fabric-permissions-api-v0": "*" + "fabric-permissions-api-v0": ">=0.3.1" }, "custom": { "modmenu:api": true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a2511224f..968e3cd3b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,7 +2,7 @@ shadow = "8.1.1" blossom = "1.3.1" forgegradle = "[6.0,6.2)" -loom = "1.4-SNAPSHOT" +loom = "1.6-SNAPSHOT" licenser = "0.6.1" [plugins] diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1af9e0930..a80b22ce5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew.bat b/gradlew.bat index 93e3f59f1..25da30dbd 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/settings.gradle b/settings.gradle index 91cdf3aa2..cd050b3c3 100644 --- a/settings.gradle +++ b/settings.gradle @@ -13,7 +13,7 @@ pluginManagement { } plugins { - id("org.gradle.toolchains.foojay-resolver-convention") version("0.5.0") + id("org.gradle.toolchains.foojay-resolver-convention") version("0.8.0") } rootProject.name = 'luckperms'