diff --git a/fabric/versions/1.20.2/src/main/java/cn/evole/mods/mcbot/init/mixins/MixinPlayerList.java b/fabric/versions/1.20.2/src/main/java/cn/evole/mods/mcbot/init/mixins/MixinPlayerList.java new file mode 100644 index 00000000..bf13128d --- /dev/null +++ b/fabric/versions/1.20.2/src/main/java/cn/evole/mods/mcbot/init/mixins/MixinPlayerList.java @@ -0,0 +1,32 @@ +package cn.evole.mods.mcbot.init.mixins; + + +import cn.evole.mods.mcbot.init.callbacks.IEvents; +import net.minecraft.network.Connection; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.CommonListenerCookie; +import net.minecraft.server.players.PlayerList; +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.CallbackInfo; + +/** + * Author cnlimiter + * CreateTime 2023/5/19 0:51 + * Name MixinPlayerList + * Description + */ + +@Mixin(value = PlayerList.class, priority = 1001) +public abstract class MixinPlayerList { + @Inject(method = "placeNewPlayer", at = @At(value = "TAIL")) + public void PlayerList_placeNewPlayer(Connection connection, ServerPlayer player, CommonListenerCookie commonListenerCookie, CallbackInfo ci) { + IEvents.PLAYER_LOGGED_IN.invoker().onPlayerLoggedIn(player.getCommandSenderWorld(), player); + } + + @Inject(method = "remove", at = @At(value = "HEAD")) + public void PlayerList_remove(ServerPlayer player, CallbackInfo ci) { + IEvents.PLAYER_LOGGED_OUT.invoker().onPlayerLoggedOut(player.getCommandSenderWorld(), player); + } +} \ No newline at end of file