|
| 1 | +/* |
| 2 | + * Copyright (c) 2014-2026 Wurst-Imperium and contributors. |
| 3 | + * |
| 4 | + * This source code is subject to the terms of the GNU General Public |
| 5 | + * License, version 3. If a copy of the GPL was not distributed with this |
| 6 | + * file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt |
| 7 | + */ |
| 8 | +package net.wurstclient.mixin; |
| 9 | + |
| 10 | +import java.util.Map; |
| 11 | +import java.util.Set; |
| 12 | + |
| 13 | +import org.spongepowered.asm.mixin.Mixin; |
| 14 | +import org.spongepowered.asm.mixin.injection.At; |
| 15 | +import org.spongepowered.asm.mixin.injection.Inject; |
| 16 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
| 17 | + |
| 18 | +import com.mojang.authlib.minecraft.UserApiService.UserFlag; |
| 19 | +import com.mojang.authlib.minecraft.UserApiService.UserProperties; |
| 20 | +import com.mojang.authlib.yggdrasil.YggdrasilUserApiService; |
| 21 | + |
| 22 | +import net.wurstclient.WurstClient; |
| 23 | + |
| 24 | +@Mixin(value = YggdrasilUserApiService.class, remap = false) |
| 25 | +public class YggdrasilUserApiServiceMixin |
| 26 | +{ |
| 27 | + @Inject(method = "fetchProperties", |
| 28 | + at = @At("HEAD"), |
| 29 | + cancellable = true, |
| 30 | + remap = false) |
| 31 | + private void wurst$forceAllowChats( |
| 32 | + CallbackInfoReturnable<UserProperties> cir) |
| 33 | + { |
| 34 | + if(WurstClient.INSTANCE.getOtfs() == null) |
| 35 | + return; |
| 36 | + |
| 37 | + if(!WurstClient.INSTANCE.getOtfs().forceAllowChatsOtf |
| 38 | + .isForceAllowChatsEnabled()) |
| 39 | + return; |
| 40 | + |
| 41 | + cir.setReturnValue(new UserProperties(Set.of(UserFlag.CHAT_ALLOWED, |
| 42 | + UserFlag.REALMS_ALLOWED, UserFlag.SERVERS_ALLOWED), Map.of())); |
| 43 | + } |
| 44 | +} |
0 commit comments