diff options
author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-01-01 22:11:34 +0700 |
---|---|---|
committer | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-01-01 22:11:34 +0700 |
commit | cc4a11c7943d9036dc71679eaa531832cd2a2f0c (patch) | |
tree | da242580d43fa6f26f0b0b04deab82c200a5bb16 /src/main/java/cc/woverflow/chattils/mixin/ClientCommandHandlerMixin.java | |
parent | 856df4d08d3c392b35f256966f6263da86fdb7ab (diff) | |
download | Chatting-cc4a11c7943d9036dc71679eaa531832cd2a2f0c.tar.gz Chatting-cc4a11c7943d9036dc71679eaa531832cd2a2f0c.tar.bz2 Chatting-cc4a11c7943d9036dc71679eaa531832cd2a2f0c.zip |
Chattils 1.0.0
Diffstat (limited to 'src/main/java/cc/woverflow/chattils/mixin/ClientCommandHandlerMixin.java')
-rw-r--r-- | src/main/java/cc/woverflow/chattils/mixin/ClientCommandHandlerMixin.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/main/java/cc/woverflow/chattils/mixin/ClientCommandHandlerMixin.java b/src/main/java/cc/woverflow/chattils/mixin/ClientCommandHandlerMixin.java new file mode 100644 index 0000000..0692342 --- /dev/null +++ b/src/main/java/cc/woverflow/chattils/mixin/ClientCommandHandlerMixin.java @@ -0,0 +1,34 @@ +package cc.woverflow.chattils.mixin; + +import cc.woverflow.chattils.chat.ChatShortcuts; +import cc.woverflow.chattils.config.ChattilsConfig; +import kotlin.Pair; +import net.minecraft.client.Minecraft; +import net.minecraft.command.CommandHandler; +import net.minecraft.command.ICommandSender; +import net.minecraft.util.BlockPos; +import net.minecraftforge.client.ClientCommandHandler; +import net.minecraftforge.fml.client.FMLClientHandler; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import java.util.Iterator; +import java.util.List; + +@Mixin(value = ClientCommandHandler.class, remap = false) +public class ClientCommandHandlerMixin extends CommandHandler { + @Redirect(method = "autoComplete", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/ClientCommandHandler;getTabCompletionOptions(Lnet/minecraft/command/ICommandSender;Ljava/lang/String;Lnet/minecraft/util/BlockPos;)Ljava/util/List;")) + private List<String> addChatShortcuts(ClientCommandHandler instance, ICommandSender iCommandSender, String leftOfCursor, BlockPos blockPos) { + Minecraft mc = FMLClientHandler.instance().getClient(); + List<String> autocompleteList = instance.getTabCompletionOptions(mc.thePlayer, leftOfCursor, mc.thePlayer.getPosition()); + if (ChattilsConfig.INSTANCE.getChatShortcuts()) { + for (Pair<String, String> pair : ChatShortcuts.INSTANCE.getShortcuts()) { + if (pair.getFirst().startsWith(leftOfCursor)) { + autocompleteList.add(pair.getFirst()); + } + } + } + return autocompleteList; + } +} |