Skip to content

Commit

Permalink
feat: add clicked commands to chat history
Browse files Browse the repository at this point in the history
closes #172
  • Loading branch information
Sychic committed Mar 16, 2024
1 parent d130368 commit ac807ba
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/main/java/club/sk1er/patcher/config/PatcherConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,13 @@ public static int getInventoryScale() {
)
public static boolean safeChatClicks;

@Property(
type = PropertyType.SWITCH, name = "Safe Chat Clicks History",
description = "Adds commands sent from clicking chat messages to the chat history.",
category = "Screens", subcategory = "Chat"
)
public static boolean safeChatClicksHistory;

@Property(
type = PropertyType.SWITCH, name = "Smart Disconnect",
description = "Choose between disconnecting or relogging when clicking the disconnect button.\n§eOnly works on Multiplayer servers.",
Expand Down Expand Up @@ -1311,6 +1318,8 @@ public PatcherConfig() {
addDependency("cacheFontData", "optimizedFontRenderer");
addDependency("chunkUpdateLimit", "limitChunks");

addDependency("safeChatClicksHistory", "safeChatClicks");

Arrays.asList(
"screenshotNoFeedback", "compactScreenshotResponse", "autoCopyScreenshot", "screenshotPreview",
"previewTime", "previewAnimationStyle", "previewScale", "favoriteScreenshot",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package club.sk1er.patcher.mixins.features;

import club.sk1er.patcher.config.PatcherConfig;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiChat;
import net.minecraft.client.gui.GuiScreen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;

@Mixin(GuiScreen.class)
public abstract class GuiChatMixin_SafeChatClicksHistory extends Gui {

@ModifyArg(method = "handleComponentClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiScreen;sendChatMessage(Ljava/lang/String;Z)V"), index = 1)
public boolean patcher$handleComponentClick(boolean addToChat) {

return addToChat || (PatcherConfig.safeChatClicksHistory && ((Object) this) instanceof GuiChat);
}
}
5 changes: 3 additions & 2 deletions src/main/resources/patcher.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
"accessors.KeyBindingAccessor",
"accessors.MinecraftAccessor",
"accessors.MinecraftForgeClientAccessor",
"accessors.optifine.ConfigAccessor",
"accessors.optifine.CustomColorsAccessor",
"accessors.PositionedSoundAccessor",
"accessors.RenderManagerAccessor",
"accessors.ResourcePackRepositoryAccessor",
"accessors.SoundHandlerAccessor",
"accessors.SoundManagerAccessor",
"accessors.SoundRegistryAccessor",
"accessors.WorldRendererAccessor",
"accessors.optifine.ConfigAccessor",
"accessors.optifine.CustomColorsAccessor",
"bugfixes.BlockFluidRendererMixin_FixStitching",
"bugfixes.BlockModelRendererMixin_SmoothLighting",
"bugfixes.CommandHandlerMixin_CaseCommands",
Expand Down Expand Up @@ -129,6 +129,7 @@
"features.FontRenderMixin_ShadowTypes",
"features.GuiAchievementMixin_CancelRender",
"features.GuiChatMixin_ExtendedChatLength",
"features.GuiChatMixin_SafeChatClicksHistory",
"features.GuiContainerMixin_ClickOutOfContainers",
"features.GuiContainerMixin_DropModifierKey",
"features.GuiIngameForgeMixin_ActionbarText",
Expand Down

0 comments on commit ac807ba

Please sign in to comment.