diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c57930e..bcc78f5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: 'temurin' - java-version: 17 + java-version: 21 - uses: gradle/actions/setup-gradle@v3 # gradle-build-action doesn't support caching files in the project dir - uses: actions/cache@v4 diff --git a/build.gradle b/build.gradle index 64b0e7b..6a2622e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.6-SNAPSHOT' + id 'fabric-loom' version '1.7-SNAPSHOT' id 'maven-publish' id 'net.kyori.indra.publishing.sonatype' version '3.1.3' id 'net.kyori.indra.publishing' version '3.1.3' @@ -9,13 +9,13 @@ repositories { maven { url 'https://maven.fabricmc.net/' } } -def minecraftVersion = '1.20.4' -def yarnBuild = 3 -def loaderVersion = '0.15.10' -def fabricApiVersion = '0.97.0+1.20.4' +def minecraftVersion = '1.21.2' +def yarnBuild = 1 +def loaderVersion = '0.16.7' +def fabricApiVersion = '0.106.1+1.21.2' group = 'me.lucko' -version = '0.3.2-SNAPSHOT' +version = '0.3.3-SNAPSHOT' description = 'A simple permissions API for Fabric' dependencies { @@ -40,7 +40,7 @@ java { withSourcesJar() withJavadocJar() toolchain { - languageVersion = JavaLanguageVersion.of(17) + languageVersion = JavaLanguageVersion.of(21) } } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e644113..a4b76b9 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b82aa23..0aaefbc 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.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a4..f5feea6 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,8 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 25da30d..9d21a21 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## diff --git a/src/main/java/me/lucko/fabric/api/permissions/v0/Options.java b/src/main/java/me/lucko/fabric/api/permissions/v0/Options.java index 90197cd..7678a77 100644 --- a/src/main/java/me/lucko/fabric/api/permissions/v0/Options.java +++ b/src/main/java/me/lucko/fabric/api/permissions/v0/Options.java @@ -28,7 +28,9 @@ import com.mojang.authlib.GameProfile; import net.minecraft.command.CommandSource; import net.minecraft.entity.Entity; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.world.World; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; @@ -136,7 +138,8 @@ static T get(@NotNull CommandSource source, @NotNull String key, T defaultVa */ static @NotNull Optional get(@NotNull Entity entity, @NotNull String key) { Objects.requireNonNull(entity, "entity"); - return get(entity.getCommandSource(), key); + World world = entity.getWorld(); + return get(entity.getCommandSource(world instanceof ServerWorld ? (ServerWorld) world : null), key); } /** @@ -151,7 +154,8 @@ static T get(@NotNull CommandSource source, @NotNull String key, T defaultVa @Contract("_, _, !null -> !null") static String get(@NotNull Entity entity, @NotNull String key, String defaultValue) { Objects.requireNonNull(entity, "entity"); - return get(entity.getCommandSource(), key, defaultValue); + World world = entity.getWorld(); + return get(entity.getCommandSource(world instanceof ServerWorld ? (ServerWorld) world : null), key, defaultValue); } /** @@ -176,7 +180,8 @@ static String get(@NotNull Entity entity, @NotNull String key, String defaultVal */ static @NotNull Optional get(@NotNull Entity entity, @NotNull String key, @NotNull Function valueTransformer) { Objects.requireNonNull(entity, "entity"); - return get(entity.getCommandSource(), key, valueTransformer); + World world = entity.getWorld(); + return get(entity.getCommandSource(world instanceof ServerWorld ? (ServerWorld) world : null), key, valueTransformer); } /** @@ -204,7 +209,8 @@ static String get(@NotNull Entity entity, @NotNull String key, String defaultVal @Contract("_, _, !null, _ -> !null") static T get(@NotNull Entity entity, @NotNull String key, T defaultValue, @NotNull Function valueTransformer) { Objects.requireNonNull(entity, "entity"); - return get(entity.getCommandSource(), key, defaultValue, valueTransformer); + World world = entity.getWorld(); + return get(entity.getCommandSource(world instanceof ServerWorld ? (ServerWorld) world : null), key, defaultValue, valueTransformer); } /** diff --git a/src/main/java/me/lucko/fabric/api/permissions/v0/Permissions.java b/src/main/java/me/lucko/fabric/api/permissions/v0/Permissions.java index cbb090d..188cab8 100644 --- a/src/main/java/me/lucko/fabric/api/permissions/v0/Permissions.java +++ b/src/main/java/me/lucko/fabric/api/permissions/v0/Permissions.java @@ -31,7 +31,9 @@ import net.minecraft.entity.Entity; import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.ServerCommandSource; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.world.World; import org.jetbrains.annotations.NotNull; import java.util.Objects; @@ -144,7 +146,8 @@ static boolean check(@NotNull CommandSource source, @NotNull String permission) */ static @NotNull TriState getPermissionValue(@NotNull Entity entity, @NotNull String permission) { Objects.requireNonNull(entity, "entity"); - return getPermissionValue(entity.getCommandSource(), permission); + World world = entity.getWorld(); + return getPermissionValue(entity.getCommandSource(world instanceof ServerWorld ? (ServerWorld) world : null), permission); } /** @@ -158,7 +161,8 @@ static boolean check(@NotNull CommandSource source, @NotNull String permission) */ static boolean check(@NotNull Entity entity, @NotNull String permission, boolean defaultValue) { Objects.requireNonNull(entity, "entity"); - return check(entity.getCommandSource(), permission, defaultValue); + World world = entity.getWorld(); + return check(entity.getCommandSource(world instanceof ServerWorld ? (ServerWorld) world : null), permission, defaultValue); } /** @@ -172,7 +176,8 @@ static boolean check(@NotNull Entity entity, @NotNull String permission, boolean */ static boolean check(@NotNull Entity entity, @NotNull String permission, int defaultRequiredLevel) { Objects.requireNonNull(entity, "entity"); - return check(entity.getCommandSource(), permission, defaultRequiredLevel); + World world = entity.getWorld(); + return check(entity.getCommandSource(world instanceof ServerWorld ? (ServerWorld) world : null), permission, defaultRequiredLevel); } /** @@ -185,7 +190,8 @@ static boolean check(@NotNull Entity entity, @NotNull String permission, int def */ static boolean check(@NotNull Entity entity, @NotNull String permission) { Objects.requireNonNull(entity, "entity"); - return check(entity.getCommandSource(), permission); + World world = entity.getWorld(); + return check(entity.getCommandSource(world instanceof ServerWorld ? (ServerWorld) world : null), permission); } /**