-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
4 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
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
40 changes: 40 additions & 0 deletions
40
src/main/java/io/github/rektroth/whiteout/mixin/mc171420/MinecraftServerMixin.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,40 @@ | ||
/* | ||
* Patch for MC-171420 | ||
* | ||
* Authored for CraftBukkit/Spigot by William Blake Galbreath <[email protected]> on October 3, 2020. | ||
* Ported to Fabric by Rektroth <[email protected]> on July 4, 2024. | ||
*/ | ||
|
||
package io.github.rektroth.whiteout.mixin.mc171420; | ||
|
||
import com.mojang.authlib.GameProfile; | ||
import net.minecraft.server.MinecraftServer; | ||
import net.minecraft.server.PlayerManager; | ||
import net.minecraft.server.Whitelist; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(MinecraftServer.class) | ||
public abstract class MinecraftServerMixin { | ||
@Shadow | ||
public abstract PlayerManager getPlayerManager(); | ||
|
||
/** | ||
* Checks if the player is whitelisted *or* is an operator. | ||
* @param instance The whitelist. | ||
* @param profile The player profile. | ||
* @return True if the player is whitelisted or an operator, false otherwise. | ||
*/ | ||
@Redirect( | ||
at = @At( | ||
target = "Lnet/minecraft/server/Whitelist;isAllowed(Lcom/mojang/authlib/GameProfile;)Z", | ||
value = "INVOKE" | ||
), | ||
method = "kickNonWhitelistedPlayers" | ||
) | ||
private boolean isAllowedOrOp(Whitelist instance, GameProfile profile) { | ||
return instance.isAllowed(profile) || this.getPlayerManager().isOperator(profile); | ||
} | ||
} |
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