Skip to content

Commit

Permalink
Update for Minecraft 1.21.2 (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko authored Oct 22, 2024
1 parent d512e01 commit f03cf44
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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 {
Expand All @@ -40,7 +40,7 @@ java {
withSourcesJar()
withJavadocJar()
toolchain {
languageVersion = JavaLanguageVersion.of(17)
languageVersion = JavaLanguageVersion.of(21)
}
}

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -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/.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##########################################################################
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/me/lucko/fabric/api/permissions/v0/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -136,7 +138,8 @@ static <T> T get(@NotNull CommandSource source, @NotNull String key, T defaultVa
*/
static @NotNull Optional<String> 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);
}

/**
Expand All @@ -151,7 +154,8 @@ static <T> 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);
}

/**
Expand All @@ -176,7 +180,8 @@ static String get(@NotNull Entity entity, @NotNull String key, String defaultVal
*/
static <T> @NotNull Optional<T> get(@NotNull Entity entity, @NotNull String key, @NotNull Function<String, ? extends T> 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);
}

/**
Expand Down Expand Up @@ -204,7 +209,8 @@ static String get(@NotNull Entity entity, @NotNull String key, String defaultVal
@Contract("_, _, !null, _ -> !null")
static <T> T get(@NotNull Entity entity, @NotNull String key, T defaultValue, @NotNull Function<String, ? extends T> 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);
}

/**
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/me/lucko/fabric/api/permissions/v0/Permissions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand Down

0 comments on commit f03cf44

Please sign in to comment.