-
Notifications
You must be signed in to change notification settings - Fork 11
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
37 additions
and
9 deletions.
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
25 changes: 25 additions & 0 deletions
25
src/main/java/io/github/gaming32/worldhost/mixin/MixinPlayerList.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,25 @@ | ||
package io.github.gaming32.worldhost.mixin; | ||
|
||
import com.mojang.authlib.GameProfile; | ||
import io.github.gaming32.worldhost.WorldHost; | ||
import net.minecraft.server.MinecraftServer; | ||
import net.minecraft.server.players.PlayerList; | ||
import org.spongepowered.asm.mixin.Final; | ||
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.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(PlayerList.class) | ||
public class MixinPlayerList { | ||
@Shadow @Final private MinecraftServer server; | ||
|
||
@Inject(method = "isWhiteListed", at = @At("HEAD"), cancellable = true) | ||
private void whitelistFriends(GameProfile profile, CallbackInfoReturnable<Boolean> cir) { | ||
if (!WorldHost.CONFIG.isWhitelistJoins()) return; | ||
if (!server.isSingleplayerOwner(profile) && !WorldHost.isFriend(profile.getId())) { | ||
cir.setReturnValue(false); | ||
} | ||
} | ||
} |
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