diff --git a/build.gradle b/build.gradle index 6a9cd4cc..571d6105 100644 --- a/build.gradle +++ b/build.gradle @@ -103,6 +103,8 @@ dependencies { modApi include("eu.pb4:player-data-api:0.3.0+1.20.2") modApi include("eu.pb4:predicate-api:0.3.0+1.20.2") + modImplementation include("me.lucko:fabric-permissions-api:0.2-SNAPSHOT") + modCompileOnly('xyz.nucleoid:disguiselib-fabric:1.3.2') modCompileOnly('maven.modrinth:afkdisplay:1.1.0') modCompileOnly('eu.pb4:polymer-autohost:0.6.0+1.20.2') diff --git a/src/main/java/xyz/nucleoid/plasmid/game/GameTexts.java b/src/main/java/xyz/nucleoid/plasmid/game/GameTexts.java index fe7c7975..a91e1844 100644 --- a/src/main/java/xyz/nucleoid/plasmid/game/GameTexts.java +++ b/src/main/java/xyz/nucleoid/plasmid/game/GameTexts.java @@ -151,6 +151,10 @@ public static MutableText inOtherGame() { ) ); } + + public static MutableText notAllowed() { + return Text.translatable("text.plasmid.join_result.not_allowed"); + } } public static final class Kick { diff --git a/src/main/java/xyz/nucleoid/plasmid/game/manager/ManagedGameSpace.java b/src/main/java/xyz/nucleoid/plasmid/game/manager/ManagedGameSpace.java index 160465ac..65660758 100644 --- a/src/main/java/xyz/nucleoid/plasmid/game/manager/ManagedGameSpace.java +++ b/src/main/java/xyz/nucleoid/plasmid/game/manager/ManagedGameSpace.java @@ -1,6 +1,7 @@ package xyz.nucleoid.plasmid.game.manager; import com.google.common.collect.Lists; +import me.lucko.fabric.api.permissions.v0.Permissions; import net.minecraft.registry.RegistryKey; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayerEntity; @@ -219,6 +220,8 @@ PlayerOfferResult offerPlayer(PlayerOffer offer) { return offer.reject(GameTexts.Join.gameClosed()); } else if (this.manager.inGame(offer.player())) { return offer.reject(GameTexts.Join.inOtherGame()); + } else if (!Permissions.check(offer.player(), "plasmid.join_game", true)) { + return offer.reject(GameTexts.Join.notAllowed()); } return this.state.invoker(GamePlayerEvents.OFFER).onOfferPlayer(offer); diff --git a/src/main/resources/data/plasmid/lang/en_us.json b/src/main/resources/data/plasmid/lang/en_us.json index 17fcb078..a1829375 100644 --- a/src/main/resources/data/plasmid/lang/en_us.json +++ b/src/main/resources/data/plasmid/lang/en_us.json @@ -66,6 +66,7 @@ "text.plasmid.join_result.game_full": "Game is already full!", "text.plasmid.join_result.in_other_game": "You must %s before joining another game!", "text.plasmid.join_result.in_other_game.leave_this_game": "leave this game", + "text.plasmid.join_result.not_allowed": "You are not allowed to join this game!", "text.plasmid.map_workspace.workspace_not_found": "Map with id '%s' was not found!", "text.plasmid.map.bounds.get": "The bounds for the workspace are %s to %s", "text.plasmid.map.bounds.set": "Updated bounds for workspace", diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 719fef27..c0fbb3a2 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -22,6 +22,7 @@ "fabric": "*", "minecraft": ">=1.20.2-", "polymer-core": "*", + "fabric-permissions-api-v0": "*", "java": ">=17" } }