Skip to content

Commit

Permalink
Fix whitelist check not being executed
Browse files Browse the repository at this point in the history
  • Loading branch information
Erdragh committed Dec 1, 2023
1 parent 208ab60 commit 56db912
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package dev.erdragh.astralbot.mixins;

import com.mojang.authlib.GameProfile;
import dev.erdragh.astralbot.handlers.WhitelistHandler;
import net.minecraft.server.dedicated.DedicatedPlayerList;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(DedicatedPlayerList.class)
public class DedicatedPlayerListMixin { @Inject(method = "isWhiteListed", at = @At("RETURN"), cancellable = true)
void astralbot$isWhiteListed(GameProfile profile, CallbackInfoReturnable<Boolean> cir) {
cir.setReturnValue(Boolean.TRUE.equals(cir.getReturnValue()) || WhitelistHandler.INSTANCE.checkWhitelist(profile.getId()) != null);
}
}
3 changes: 2 additions & 1 deletion common/src/main/resources/astralbot-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"package": "dev.erdragh.astralbot.mixins",
"compatibilityLevel": "JAVA_17",
"server": [
"PlayerListMixin"
"PlayerListMixin",
"DedicatedPlayerListMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 56db912

Please sign in to comment.