Skip to content

Commit

Permalink
Fix #15
Browse files Browse the repository at this point in the history
  • Loading branch information
senseiwells committed Oct 16, 2024
1 parent f3a0620 commit 789955a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
13 changes: 13 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ group = "me.senseiwells"
repositories {
mavenCentral()
maven("https://maven.parchmentmc.org/")
maven("https://api.modrinth.com/maven")
}

dependencies {
Expand All @@ -25,13 +26,25 @@ dependencies {
modImplementation(libs.fabric.loader)
modImplementation(libs.fabric.api)

runtimeOnly(libs.luckperms)

includeModImplementation(libs.permissions) {
exclude(libs.fabric.api.get().group)
}
}

loom {
accessWidenerPath.set(file("src/main/resources/chunk-debug.accesswidener"))

runs {
getByName("server") {
runDir = "run/server"
}

getByName("client") {
runDir = "run/client"
}
}
}

java {
Expand Down
2 changes: 2 additions & 0 deletions libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ fabric-api = "0.103.0+1.21.1"
permissions = "0.3.1"
mod-publish = "0.7.0"
parchment = "1.21:2024.07.28"
luckperms = "v5.4.140-fabric"

[libraries]
minecraft = { module = "com.mojang:minecraft" , version.ref = "minecraft" }
fabric-loader = { module = "net.fabricmc:fabric-loader" , version.ref = "fabric-loader" }
fabric-api = { module = "net.fabricmc.fabric-api:fabric-api", version.ref = "fabric-api" }
permissions = { module = "me.lucko:fabric-permissions-api" , version.ref = "permissions" }
luckperms = { module = "maven.modrinth:luckperms" , version.ref = "luckperms" }

[plugins]
mod-publish = { id = "me.modmuss50.mod-publish-plugin", version.ref = "mod-publish" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.TickTask;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
Expand Down Expand Up @@ -66,9 +67,14 @@ public void onDeOpPlayer(ServerPlayer player) {
}

private void sendHelloPayload(ServerGamePacketListenerImpl connection, PacketSender sender, MinecraftServer server) {
if (this.isPermitted(connection.player)) {
sender.sendPacket(HelloPayload.INSTANCE);
}
// We have to do this later in the tick because luckperms uses the same
// event to load permissions, and we need that information to be loaded
// before we check whether the player is permitted or not.
server.tell(new TickTask(server.getTickCount(), () -> {
if (this.isPermitted(connection.player)) {
sender.sendPacket(HelloPayload.INSTANCE);
}
}));
}

private void sendUpdatesToWatching(MinecraftServer server) {
Expand Down

0 comments on commit 789955a

Please sign in to comment.