-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9fd9e56
commit 16d50f3
Showing
17 changed files
with
239 additions
and
37 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minVersionIncluded=1.3 | ||
maxVersionIncluded=1.6.4 |
62 changes: 62 additions & 0 deletions
62
...ns-api-v1/1.6.4/src/main/java/net/legacyfabric/fabric/impl/permission/PermissionImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...6.4/src/main/java/net/legacyfabric/fabric/mixin/permission/CommandBlockExecutorMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
Binary file added
BIN
+1.54 KB
...pi-v1/1.6.4/src/main/resources/assets/legacy-fabric-permissions-api-v1/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions
43
legacy-fabric-permissions-api-v1/1.6.4/src/main/resources/fabric.mod.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...-permissions-api-v1/1.6.4/src/main/resources/legacy-fabric-permissions-api-v1.mixins.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"required": true, | ||
"package": "net.legacyfabric.fabric.mixin.permission", | ||
"compatibilityLevel": "JAVA_8", | ||
"mixins": [ | ||
"CommandBlockExecutorMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
minVersionIncluded=1.3 | ||
minVersionIncluded=1.7.10 | ||
maxVersionIncluded=1.12.2 |
62 changes: 62 additions & 0 deletions
62
...ns-api-v1/1.8.9/src/main/java/net/legacyfabric/fabric/impl/permission/PermissionImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...ions-api-v1/common/src/main/resources/legacy-fabric-permissions-api-v1-common.mixins.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"required": true, | ||
"package": "net.legacyfabric.fabric.mixin.permission", | ||
"compatibilityLevel": "JAVA_8", | ||
"mixins": [ | ||
"ConsoleMixin", | ||
"EntityMixin", | ||
"ServerPlayerEntityMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |