diff --git a/legacy-fabric-permissions-api-v1/1.6.4/build.gradle b/legacy-fabric-permissions-api-v1/1.6.4/build.gradle new file mode 100644 index 000000000..e69de29bb diff --git a/legacy-fabric-permissions-api-v1/1.6.4/gradle.properties b/legacy-fabric-permissions-api-v1/1.6.4/gradle.properties new file mode 100644 index 000000000..72b74abca --- /dev/null +++ b/legacy-fabric-permissions-api-v1/1.6.4/gradle.properties @@ -0,0 +1,2 @@ +minVersionIncluded=1.3 +maxVersionIncluded=1.6.4 diff --git a/legacy-fabric-permissions-api-v1/1.6.4/src/main/java/net/legacyfabric/fabric/impl/permission/PermissionImpl.java b/legacy-fabric-permissions-api-v1/1.6.4/src/main/java/net/legacyfabric/fabric/impl/permission/PermissionImpl.java new file mode 100644 index 000000000..13e91de82 --- /dev/null +++ b/legacy-fabric-permissions-api-v1/1.6.4/src/main/java/net/legacyfabric/fabric/impl/permission/PermissionImpl.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.impl.permission; + +import net.minecraft.client.MinecraftClient; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.server.MinecraftServer; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.ModInitializer; +import net.fabricmc.loader.api.FabricLoader; + +import net.legacyfabric.fabric.api.permission.v1.PermissionsApiHolder; +import net.legacyfabric.fabric.api.permission.v1.PlayerPermissionsApi; + +public class PermissionImpl implements ModInitializer { + @Override + public void onInitialize() { + PermissionsApiHolder.setFallbackPlayerPermissionsApi(FallbackPlayerPermissionsApi.INSTANCE); + } + + private enum FallbackPlayerPermissionsApi implements PlayerPermissionsApi { + INSTANCE; + + @Override + public String getId() { + return "legacy-fabric-fallback-permissions-api"; + } + + @Override + public boolean hasPermission(ServerPlayerEntity player, String perm) { + return getServer().getPlayerManager().canCheat(player.getUsername()); + } + } + + protected static MinecraftServer getServer() { + try { + return MinecraftServer.getServer(); + } catch (NoSuchMethodError e) { + if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { + return MinecraftClient.getInstance().getServer(); + } else { + return (MinecraftServer) FabricLoader.getInstance().getGameInstance(); + } + } + } +} diff --git a/legacy-fabric-permissions-api-v1/1.6.4/src/main/java/net/legacyfabric/fabric/mixin/permission/CommandBlockExecutorMixin.java b/legacy-fabric-permissions-api-v1/1.6.4/src/main/java/net/legacyfabric/fabric/mixin/permission/CommandBlockExecutorMixin.java new file mode 100644 index 000000000..c492b5cbd --- /dev/null +++ b/legacy-fabric-permissions-api-v1/1.6.4/src/main/java/net/legacyfabric/fabric/mixin/permission/CommandBlockExecutorMixin.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.mixin.permission; + +import org.spongepowered.asm.mixin.Mixin; + +import net.minecraft.block.entity.CommandBlockBlockEntity; + +import net.legacyfabric.fabric.api.permission.v1.PermissibleCommandSource; + +@Mixin(CommandBlockBlockEntity.class) +public abstract class CommandBlockExecutorMixin implements PermissibleCommandSource { + @Override + public boolean hasPermission(String perm) { + return true; + } +} diff --git a/legacy-fabric-permissions-api-v1/1.6.4/src/main/resources/assets/legacy-fabric-permissions-api-v1/icon.png b/legacy-fabric-permissions-api-v1/1.6.4/src/main/resources/assets/legacy-fabric-permissions-api-v1/icon.png new file mode 100644 index 000000000..2931efbf6 Binary files /dev/null and b/legacy-fabric-permissions-api-v1/1.6.4/src/main/resources/assets/legacy-fabric-permissions-api-v1/icon.png differ diff --git a/legacy-fabric-permissions-api-v1/1.6.4/src/main/resources/fabric.mod.json b/legacy-fabric-permissions-api-v1/1.6.4/src/main/resources/fabric.mod.json new file mode 100644 index 000000000..7a960c2e7 --- /dev/null +++ b/legacy-fabric-permissions-api-v1/1.6.4/src/main/resources/fabric.mod.json @@ -0,0 +1,43 @@ +{ + "schemaVersion": 1, + "id": "legacy-fabric-permissions-api-v1", + "name": "Legacy Fabric Permissions API (v2)", + "version": "${version}", + "environment": "*", + "license": "Apache-2.0", + "icon": "assets/legacy-fabric-permissions-api-v1/icon.png", + "contact": { + "homepage": "https://legacy-fabric.github.io/", + "irc": "irc://irc.esper.net:6667/legacyfabric", + "issues": "https://github.com/Legacy-Fabric/fabric/issues", + "sources": "https://github.com/Legacy-Fabric/fabric" + }, + "authors": [ + "FabricMC" + ], + "entrypoints": { + "main": [ + "net.legacyfabric.fabric.impl.permission.PermissionImpl" + ] + }, + "depends": { + "fabricloader": ">=0.4.0", + "minecraft": "${minecraft_version}" + }, + "description": "Simple permission api", + "mixins": [ + "legacy-fabric-permissions-api-v1.mixins.json" + ], + "custom": { + "modmenu": { + "badges": [ "library" ], + "parent": { + "id": "legacy-fabric-api", + "name": "Legacy Fabric API", + "badges": [ "library" ], + "description": "Core API module providing key hooks and inter-compatibility features for Minecraft 1.7.10-1.12.2.", + "icon": "assets/legacy-fabric-permissions-api-v1/icon.png" + } + } + } +} diff --git a/legacy-fabric-permissions-api-v1/1.6.4/src/main/resources/legacy-fabric-permissions-api-v1.mixins.json b/legacy-fabric-permissions-api-v1/1.6.4/src/main/resources/legacy-fabric-permissions-api-v1.mixins.json new file mode 100644 index 000000000..c02686873 --- /dev/null +++ b/legacy-fabric-permissions-api-v1/1.6.4/src/main/resources/legacy-fabric-permissions-api-v1.mixins.json @@ -0,0 +1,11 @@ +{ + "required": true, + "package": "net.legacyfabric.fabric.mixin.permission", + "compatibilityLevel": "JAVA_8", + "mixins": [ + "CommandBlockExecutorMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/legacy-fabric-permissions-api-v1/1.8.9/gradle.properties b/legacy-fabric-permissions-api-v1/1.8.9/gradle.properties index d523a75a0..503076051 100644 --- a/legacy-fabric-permissions-api-v1/1.8.9/gradle.properties +++ b/legacy-fabric-permissions-api-v1/1.8.9/gradle.properties @@ -1,2 +1,2 @@ -minVersionIncluded=1.3 +minVersionIncluded=1.7.10 maxVersionIncluded=1.12.2 diff --git a/legacy-fabric-permissions-api-v1/1.8.9/src/main/java/net/legacyfabric/fabric/impl/permission/PermissionImpl.java b/legacy-fabric-permissions-api-v1/1.8.9/src/main/java/net/legacyfabric/fabric/impl/permission/PermissionImpl.java new file mode 100644 index 000000000..6d1861698 --- /dev/null +++ b/legacy-fabric-permissions-api-v1/1.8.9/src/main/java/net/legacyfabric/fabric/impl/permission/PermissionImpl.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.impl.permission; + +import net.minecraft.client.MinecraftClient; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.server.MinecraftServer; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.ModInitializer; +import net.fabricmc.loader.api.FabricLoader; + +import net.legacyfabric.fabric.api.permission.v1.PermissionsApiHolder; +import net.legacyfabric.fabric.api.permission.v1.PlayerPermissionsApi; + +public class PermissionImpl implements ModInitializer { + @Override + public void onInitialize() { + PermissionsApiHolder.setFallbackPlayerPermissionsApi(FallbackPlayerPermissionsApi.INSTANCE); + } + + private enum FallbackPlayerPermissionsApi implements PlayerPermissionsApi { + INSTANCE; + + @Override + public String getId() { + return "legacy-fabric-fallback-permissions-api"; + } + + @Override + public boolean hasPermission(ServerPlayerEntity player, String perm) { + return getServer().getPlayerManager().isOperator(player.getGameProfile()); + } + } + + protected static MinecraftServer getServer() { + try { + return MinecraftServer.getServer(); + } catch (NoSuchMethodError e) { + if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { + return MinecraftClient.getInstance().getServer(); + } else { + return (MinecraftServer) FabricLoader.getInstance().getGameInstance(); + } + } + } +} diff --git a/legacy-fabric-permissions-api-v1/1.8.9/src/main/resources/fabric.mod.json b/legacy-fabric-permissions-api-v1/1.8.9/src/main/resources/fabric.mod.json index 919f98876..7a960c2e7 100644 --- a/legacy-fabric-permissions-api-v1/1.8.9/src/main/resources/fabric.mod.json +++ b/legacy-fabric-permissions-api-v1/1.8.9/src/main/resources/fabric.mod.json @@ -15,6 +15,11 @@ "authors": [ "FabricMC" ], + "entrypoints": { + "main": [ + "net.legacyfabric.fabric.impl.permission.PermissionImpl" + ] + }, "depends": { "fabricloader": ">=0.4.0", "minecraft": "${minecraft_version}" diff --git a/legacy-fabric-permissions-api-v1/1.8.9/src/main/resources/legacy-fabric-permissions-api-v1.mixins.json b/legacy-fabric-permissions-api-v1/1.8.9/src/main/resources/legacy-fabric-permissions-api-v1.mixins.json index 8f85c2ebd..f01ad87f9 100644 --- a/legacy-fabric-permissions-api-v1/1.8.9/src/main/resources/legacy-fabric-permissions-api-v1.mixins.json +++ b/legacy-fabric-permissions-api-v1/1.8.9/src/main/resources/legacy-fabric-permissions-api-v1.mixins.json @@ -5,10 +5,7 @@ "mixins": [ "CommandBlockExecutorMixin", "CommandStats_1Mixin", - "ConsoleMixin", - "EntityMixin", "ExecuteCommand_1Mixin", - "ServerPlayerEntityMixin", "SignBlockEntity_1Mixin", "SignBlockEntity_2Mixin" ], diff --git a/legacy-fabric-permissions-api-v1/common/src/main/java/net/legacyfabric/fabric/api/permission/v1/PermissionsApiHolder.java b/legacy-fabric-permissions-api-v1/common/src/main/java/net/legacyfabric/fabric/api/permission/v1/PermissionsApiHolder.java index 46b3821bd..98a1cbc54 100644 --- a/legacy-fabric-permissions-api-v1/common/src/main/java/net/legacyfabric/fabric/api/permission/v1/PermissionsApiHolder.java +++ b/legacy-fabric-permissions-api-v1/common/src/main/java/net/legacyfabric/fabric/api/permission/v1/PermissionsApiHolder.java @@ -19,13 +19,6 @@ import org.jetbrains.annotations.ApiStatus; -import net.minecraft.client.MinecraftClient; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.server.MinecraftServer; - -import net.fabricmc.api.EnvType; -import net.fabricmc.loader.api.FabricLoader; - import net.legacyfabric.fabric.api.logger.v1.Logger; import net.legacyfabric.fabric.impl.logger.LoggerImpl; @@ -37,6 +30,7 @@ public class PermissionsApiHolder { private static final Logger LOGGER = Logger.get(LoggerImpl.API, "PermissionApiHolder"); private static PlayerPermissionsApi PLAYER_PERMISSIONS_API = null; + private static PlayerPermissionsApi FALLBACK_PLAYER_PERMISSIONS_API = null; public static boolean setPlayerPermissionsApi(PlayerPermissionsApi api) { if (PLAYER_PERMISSIONS_API == null) { @@ -49,32 +43,11 @@ public static boolean setPlayerPermissionsApi(PlayerPermissionsApi api) { } public static PlayerPermissionsApi getPlayerPermissionsApi() { - return PLAYER_PERMISSIONS_API != null ? PLAYER_PERMISSIONS_API : FallbackPlayerPermissionsApi.INSTANCE; + return PLAYER_PERMISSIONS_API != null ? PLAYER_PERMISSIONS_API : FALLBACK_PLAYER_PERMISSIONS_API; } - private enum FallbackPlayerPermissionsApi implements PlayerPermissionsApi { - INSTANCE; - - @Override - public String getId() { - return "legacy-fabric-fallback-permissions-api"; - } - - @Override - public boolean hasPermission(ServerPlayerEntity player, String perm) { - return getServer().getPlayerManager().isOperator(player.getGameProfile()); - } - } - - protected static MinecraftServer getServer() { - try { - return MinecraftServer.getServer(); - } catch (NoSuchMethodError e) { - if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { - return MinecraftClient.getInstance().getServer(); - } else { - return (MinecraftServer) FabricLoader.getInstance().getGameInstance(); - } - } + @ApiStatus.Internal + public static void setFallbackPlayerPermissionsApi(PlayerPermissionsApi api) { + FALLBACK_PLAYER_PERMISSIONS_API = api; } } diff --git a/legacy-fabric-permissions-api-v1/1.8.9/src/main/java/net/legacyfabric/fabric/mixin/permission/ConsoleMixin.java b/legacy-fabric-permissions-api-v1/common/src/main/java/net/legacyfabric/fabric/mixin/permission/ConsoleMixin.java similarity index 100% rename from legacy-fabric-permissions-api-v1/1.8.9/src/main/java/net/legacyfabric/fabric/mixin/permission/ConsoleMixin.java rename to legacy-fabric-permissions-api-v1/common/src/main/java/net/legacyfabric/fabric/mixin/permission/ConsoleMixin.java diff --git a/legacy-fabric-permissions-api-v1/1.8.9/src/main/java/net/legacyfabric/fabric/mixin/permission/EntityMixin.java b/legacy-fabric-permissions-api-v1/common/src/main/java/net/legacyfabric/fabric/mixin/permission/EntityMixin.java similarity index 100% rename from legacy-fabric-permissions-api-v1/1.8.9/src/main/java/net/legacyfabric/fabric/mixin/permission/EntityMixin.java rename to legacy-fabric-permissions-api-v1/common/src/main/java/net/legacyfabric/fabric/mixin/permission/EntityMixin.java diff --git a/legacy-fabric-permissions-api-v1/1.8.9/src/main/java/net/legacyfabric/fabric/mixin/permission/ServerPlayerEntityMixin.java b/legacy-fabric-permissions-api-v1/common/src/main/java/net/legacyfabric/fabric/mixin/permission/ServerPlayerEntityMixin.java similarity index 100% rename from legacy-fabric-permissions-api-v1/1.8.9/src/main/java/net/legacyfabric/fabric/mixin/permission/ServerPlayerEntityMixin.java rename to legacy-fabric-permissions-api-v1/common/src/main/java/net/legacyfabric/fabric/mixin/permission/ServerPlayerEntityMixin.java diff --git a/legacy-fabric-permissions-api-v1/common/src/main/resources/fabric.mod.json b/legacy-fabric-permissions-api-v1/common/src/main/resources/fabric.mod.json index ebf36e9a6..af01052bc 100644 --- a/legacy-fabric-permissions-api-v1/common/src/main/resources/fabric.mod.json +++ b/legacy-fabric-permissions-api-v1/common/src/main/resources/fabric.mod.json @@ -20,7 +20,9 @@ "minecraft": "${minecraft_version}" }, "description": "Simple permission api", - "mixins": [], + "mixins": [ + "legacy-fabric-permissions-api-v1-common.mixins.json" + ], "custom": { "modmenu": { "badges": [ "library" ], diff --git a/legacy-fabric-permissions-api-v1/common/src/main/resources/legacy-fabric-permissions-api-v1-common.mixins.json b/legacy-fabric-permissions-api-v1/common/src/main/resources/legacy-fabric-permissions-api-v1-common.mixins.json new file mode 100644 index 000000000..a982b0f48 --- /dev/null +++ b/legacy-fabric-permissions-api-v1/common/src/main/resources/legacy-fabric-permissions-api-v1-common.mixins.json @@ -0,0 +1,13 @@ +{ + "required": true, + "package": "net.legacyfabric.fabric.mixin.permission", + "compatibilityLevel": "JAVA_8", + "mixins": [ + "ConsoleMixin", + "EntityMixin", + "ServerPlayerEntityMixin" + ], + "injectors": { + "defaultRequire": 1 + } +}